Gestire i repository di esempi personalizzati in Cloud Code for VS Code
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Un repository di esempi è un repository Git che contiene esempi personalizzati creati dal tuo team e che possono essere utilizzati per sviluppare applicazioni.
Ciò significa che, all'interno di un'organizzazione o di un team, puoi configurare repository di esempio con Cloud Code, personalizzati per la tua organizzazione, per offrire un insieme standard di applicazioni di avvio, servizi e configurazione dell'infrastruttura che altri possono utilizzare. In questo modo, i nuovi progetti vengono allineati agli standard e allo stack tecnico preferiti della tua organizzazione e vengono incentivate le best practice all'inizio del ciclo di sviluppo.
Un repository di esempi può essere un repository esistente di applicazioni di esempio
che hai già creato o un nuovo insieme di esempi che vuoi che altri utilizzino.
Per importare un repository con Cloud Code, aggiungi un
file descrittore di esempio al repository.
Quando sono pronti, i repository di esempio sono facili da condividere con il team. Per utilizzarli, è necessario configurare Cloud Code e l'URL Git del repository di esempio. Per i repository Git privati, solo i membri che hanno accesso al repository possono utilizzare i sample personalizzati sottostanti.
Per un esempio di come potrebbe essere configurato un repository di esempio, consulta questo
repository.
Prima di iniziare
Assicurati che sulla tua macchina locale sia installata la versione 2.25.0 o successiva di Git.
Il tuo repository Git può essere ospitato da remoto o essere disponibile sulla tua macchina locale. Questo esempio utilizza un nuovo repository GitHub, "custom-sample-repo".
Aggiungi directory di esempio al repository.
Le directory di Sample possono contenere qualsiasi cosa e trovarsi ovunque nel repository. In questo esempio, sono state aggiunte due directory di esempio, "hello-world" e "kubernetes-custom-sample", a "custom-sample-repo".
È vivamente consigliato un file readme con istruzioni su come utilizzare al meglio i sample personalizzati.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-05 UTC."],[[["\u003cp\u003eA sample repository is a Git repository containing custom samples that teams can use to develop applications, ensuring alignment with the organization's technical standards and best practices.\u003c/p\u003e\n"],["\u003cp\u003eSample repositories can be existing or new, and require a \u003ccode\u003e.cctemplate\u003c/code\u003e sample descriptor file in the root directory to be properly imported and used by Cloud Code.\u003c/p\u003e\n"],["\u003cp\u003eSharing sample repositories involves providing the Git URL to team members with Cloud Code setup, and private repositories will restrict access to authorized members.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003e.cctemplate\u003c/code\u003e file contains metadata, such as the sample schema version and an array of samples, each with a specified path, name, and description.\u003c/p\u003e\n"],["\u003cp\u003eDeleting a custom sample repository involves removing its folder from the designated \u003ccode\u003elocalPath\u003c/code\u003e and deleting its entry in the \u003ccode\u003esettings.json\u003c/code\u003e file.\u003c/p\u003e\n"]]],[],null,["# Manage custom sample repositories in Cloud Code for VS Code\n\nA sample repository is a Git repository that contains custom samples you\ncreate that your team can use to develop applications.\n\nThis means that, within an organization or team, you can set up sample\nrepositories with Cloud Code, custom to your organization, to offer a\nstandard set of starter applications, services, and infrastructure configuration\nthat others can use. This helps align new projects with your organization's\npreferred technical stack and standards, and encourages best practices at the\nbeginning of the development cycle.\n\nA sample repository can be an existing repository of sample applications\nyou've already created or a new set of samples you'd like others to use.\nTo import a repository with Cloud Code, you add a\n[sample descriptor file](#sample_descriptor_schema) to the repository.\n\nWhen ready, sample repositories are easy to share with your team; they'll\nneed Cloud Code set up and the Git URL of the sample repository\nto use. For private Git repositories, only members that have access to the\nrepository can use the underlying custom samples.\n\nTo see an example of how a sample repository might be set up, reference this\n[repository](https://github.com/GoogleCloudPlatform/cloud-code-custom-samples-example/).\n\nBefore you begin\n----------------\n\nMake sure that Git version 2.25.0 or later is installed on your local\nmachine.\n\n\nCreating a sample repository\n----------------------------\n\nTo use an existing repository, skip to\n[creating a sample descriptor file](#sample_descriptor). To create a new\nrepository to use as a sample repository, follow these steps:\n\n1. Create a new Git repository.\n\n Your Git repository can be hosted remotely or live on your local\n machine. This example uses a new GitHub repository, 'custom-sample-repo'.\n\n2. Add sample directories to the repository.\n\n Your sample directories can contain anything and be located anywhere you\n want in the repository. In this example, two sample directories,\n 'hello-world' and 'kubernetes-custom-sample', have been added\n to 'custom-sample-repo'.\n\n A readme file with instructions on how best to use your custom samples\n is highly recommended.\n\n\n3. Create a sample descriptor file.\n\n A sample descriptor file provides Cloud Code with information\n on your sample to properly create your application. This file must be named\n `.cctemplate`, must be located in your root directory, and must have the\n schema defined in the\n [sample descriptor file schema](#sample_descriptor_schema) section.\n4. Test your custom sample by following the steps to\n [create an app from a custom sample](/code/docs/vscode/create-app-from-custom-sample).\n\nSample descriptor schema\n------------------------\n\n#### Example\n\n {\n \"metadata\":{\n \"version\":\"1\"\n },\n \"name\": \"My Sample Repository\",\n \"templates\":[\n {\n \"path\":\"/path/to/sample1_location\",\n \"name\":\"My Sample 1\",\n \"description\":\"The first sample of its name.\"\n },\n {\n \"path\":\"/path/to/sample2_location\",\n \"name\":\"My Sample 2\",\n \"description\":\"The sequel.\"\n }\n ]\n }\n\n### Sample schema\n\n#### Example\n\n {\n \"path\":\"path/to/sample1\",\n \"name\":\"My Sample 1\",\n \"description\":\"The first sample of its name.\"\n }\n\n### Metadata schema\n\n#### Example\n\n {\n \"version\":\"1\"\n }\n\nDeleting a custom sample repository\n-----------------------------------\n\nTo delete a custom sample, which removes it from the custom application\nselector flow and from users' machines:\n\n1. In the `settings.json` file, look up the `localPath` for the custom sample\n entry.\n\n \"cloudcode.customApplications\": [\n {\n \"repoUrl\": https://github.com/GoogleCloudPlatform/cloud-code-custom-samples-example.git,\n \"branchName\": \"\",\n \"localPath\": \"/Users/username/Library/cloud-code/custom-templates/https-github-com-google-cloud-platform-cloud-code-custom-samples-example-git\"\n }\n ],\n\n2. Delete the template folder at the path.\n\n | **Note:** On Macs, `Library` is a hidden folder.\n3. Delete the custom sample section from the `settings.json` file.\n\nGet Support\n-----------\n\nTo send feedback, report issues on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-vscode/issues), or ask a question on [Stack Overflow](https://stackoverflow.com/questions/ask?tags=cloud-code-vscode)."]]