Manage custom sample repositories in Cloud Code for Cloud Shell
Stay organized with collections
Save and categorize content based on your preferences.
A sample repository is a Git repository that contains custom samples you create that your team can use to develop applications.
This means that, within an organization or team, you can set up sample repositories with Cloud Code, custom to your organization, to offer a standard set of starter applications, services, and infrastructure configuration that others can use. This helps align new projects with your organization's preferred technical stack and standards, and encourages best practices at the beginning of the development cycle.
A sample repository can be an existing repository of sample applications you've already created or a new set of samples you'd like others to use. To import a repository with Cloud Code, you add a sample descriptor file to the repository.
When ready, sample repositories are easy to share with your team; they'll need Cloud Code set up and the Git URL of the sample repository to use. For private Git repositories, only members that have access to the repository can use the underlying custom samples.
To see an example of how a sample repository might be set up, reference this repository.
Creating a sample repository
To use an existing repository, skip to creating a sample descriptor file. To create a new repository to use as a sample repository, follow these steps:
Create a new Git repository.
Your Git repository can be hosted remotely or live on your local machine. This example uses a new GitHub repository, 'custom-sample-repo'.
GitHub repository creation interface with repository name field filled with 'custom-sample-repo'
Add sample directories to the repository.
Your sample directories can contain anything and be located anywhere you want in the repository. In this example, two sample directories, 'hello-world' and 'kubernetes-custom-sample', have been added to 'custom-sample-repo'.
A readme file with instructions on how best to use your custom samples is highly recommended.
Create a sample descriptor file.
A sample descriptor file provides Cloud Code with information on your sample to properly create your application. This file must be named
.cctemplate, must be located in your root directory, and must have the schema defined in the sample descriptor file schema section.Test your custom sample by following the steps to create an app from a custom sample.
Sample descriptor schema
Example
{
"metadata":{
"version":"1"
},
"name": "My Sample Repository",
"templates":[
{
"path":"/path/to/sample1_location",
"name":"My Sample 1",
"description":"The first sample of its name."
},
{
"path":"/path/to/sample2_location",
"name":"My Sample 2",
"description":"The sequel."
}
]
}
Sample schema
The path is relative to the root of the repository. String
The name is displayed in an IDE when selecting a sample to base an application on. String
The description is displayed in an IDE when selecting a sample to base an application on. String
Example
{
"path":"path/to/sample1",
"name":"My Sample 1",
"description":"The first sample of its name."
}
Metadata schema
1.
String
Example
{
"version":"1"
}
Deleting a custom sample repository
To delete a custom sample, which removes it from the custom application selector flow and from users' machines:
In the
settings.jsonfile, look up thelocalPathfor the custom sample entry."cloudcode.customApplications": [ { "repoUrl": https://github.com/GoogleCloudPlatform/cloud-code-custom-samples-example.git, "branchName": "", "localPath": "/Users/username/Library/cloud-code/custom-templates/https-github-com-google-cloud-platform-cloud-code-custom-samples-example-git" } ],Delete the template folder at the path.
Delete the custom sample section from the
settings.jsonfile.