iagctl create repository

Create a new repository.

The iagctl create repository command creates a repository in the gateway data store. A repository is a reference to a Git repository on an external server. The gateway pulls the repository each time you run a service, so the content is always current.

For more information, see Git repositories in IAG.

To reference a specific branch or SHA in your Git repository, use the --reference flag.

Syntax

$iagctl create repository <name> --url <string> [flags]

Examples

Create a public repository

The following example creates a repository called my-public-repo. This command assumes the Git repository is publicly accessible and doesn’t require authentication:

$iagctl create repository my-public-repo \
>--url git@github.com:example/some-public-repo-with-automations.git

Create a repository with a specific branch

The following example creates a repository called my-branch-reference that pulls down the devel branch when you run services:

$iagctl create repository my-branch-reference \
>--url git@github.com:example/some-public-repo-with-automations.git \
>--reference devel

Create a private repository

The following example creates a repository called my-private-repo that references a secret called git-key in the gateway’s secret store. This example assumes you’ve already created the secret by following the steps in Set up a private repository:

$iagctl create repository my-private-repo \
>--url git@github.com:example/some-private-repo-with-automations.git \
>--private-key-name git-key

Set up a private repository

If your repository isn’t publicly accessible, you need to give the gateway access to a private SSH key with read access to the repository on your Git server. Itential recommends creating an SSH key exclusively for the gateway.

The following steps demonstrate how to add a key for use with GitLab, but your specific steps may vary.

  1. Generate a public/private SSH key pair. Don’t overwrite any existing keys.
$ ssh-keygen -t rsa -b 2048 \
> -C "<comment>" \
> -f /Users/gatewayuser/.ssh/gateway_git_rsa
  1. Upload the newly generated public key to your Git server. This process varies by Git provider.

  2. Set up secret storage in the gateway. This requires a separate encryption key, unrelated to SSH, for handling gateway secrets. For more information, see iagctl create secret.

  3. Encrypt the private key into the gateway secret store using the encryption key file from step 3:

$ iagctl create secret git-key \
> --value @/Users/gatewayuser/.ssh/gateway_git_rsa \
> --encryption-file /Users/gatewayuser/.gateway.d/gateway_secret.key
  1. Create the repository and reference the secret with the --private-key-name flag:
$ iagctl create repository my-private-repo \
> --url git@github.com:example/some-private-repo-with-automations.git \
> --private-key-name git-key

For more information, see Use SSH keys to clone git repositories.

Options

$ --description string A brief description of the repository
$ -h, --help Help for repository
$ --private-key-name string The secret name for the private key used to retrieve the repository
$ --reference string The reference to check out within the repository (for example, a branch or SHA)
$ --tag stringArray Metadata tags to associate with the repository
$ --url string The URL of the repository

Options inherited from parent commands

$ --config string Path to the configuration file
$ --raw Display the result of the command in raw format
$ --verbose Enable verbose output