Shape the future of software delivery and make your voice heard by taking the 2021 State of DevOps survey.

Setting up a sample repository

A sample repository is a Git repository that contains custom samples you created 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 the incorporation of 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 brand new set of samples you'd like others to use. You'll only need to add a Sample Descriptor file to the repository to import it with Cloud Code.

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 new sample repository

If you'd like to create a brand new sample repository to use, follow these steps:

  1. Create a new Git repository.

    Your Git repository can be hosted either remotely or live on your local machine. This example uses a brand new GitHub repository, 'custom-sample-repo'.

    GitHub repository creation interface with repository name field filled with 'custom-sample-repo'

  2. Add sample directories to this repository.

    Your sample directories can contain anything and be located anywhere you want within 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.

    'custom-sample-repo' with two underlying sample directories, 'hello-world' and 'kubernetes-custom-sample'

  3. 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, located in your root directory, and must have the schema defined in the Sample Descriptor file schema section.

Using an existing repository

If you'd like to use an existing repository, you'll still need to create a Sample Descriptor file. This file provides Cloud Code with information on your sample to properly create your application.

Your Sample Descriptor file must be named .cctemplate, located in your root directory, and must have the schema defined in the Sample Descriptor file schema section.

Sample Descriptor schema

Key Description Type
metadata Metadata used by Cloud Code to read. Conforms to the Metadata Schema. Metadata
templates Array of samples contained in a repository. Objects in this array should conform to the Sample Schema. Array<Sample>
name (optional) Name of the sample repository. String

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

Key Description Type
path Where the sample is located within a repository.

The path is interpreted as being from the root of the repository.

String
name Name of a sample.

This is displayed in an IDE when selecting a sample to base an application on.

String
description (optional) Description of a sample.

This 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

Key Description Type
version The version of the sample schema being used. Currently, the only valid version is 1. String

Example

{
   "version":"1"
}