- 12 Nov 2024
-
DarkLight
-
PDF
create repository
- Updated on 12 Nov 2024
-
DarkLight
-
PDF
iagctl create repository
Create a new repository
Synopsis
This command will create a repository reference in the gateway data store. A repository within gateway is a reference to a git repository that exists on an external server. Repositories are pulled down when a service is executed so that the reference is always fresh.
To reference a specific branch/SHA in your git repository, use the --reference
flag.
Setting Up Private Repositories
If the repository that you are trying to reference is not publicly accessible, you will need to give gateway access to a private ssh
key that has read access to the repository on your git server. For security reasons, it is recommended that you create an ssh
key exclusively for the gateway. The steps below demonstrate how a key can be added to gitlab but your specific steps may vary.
-
Generate a public/private
ssh
key pair. Be sure to not overwrite any keys that you are currently using elsewhere.>_ ssh-keygen -t rsa -b 2048 \ -C "<comment>" \ -f /Users/gatewayuser/.ssh/gateway_git_rsa
-
Upload the newly generated public key to your git server. This varies by git provider.
-
Setup secret storage within gateway. This requires you to create a separate encryption key that is unrelated to
ssh
for handling gateway secrets.- Run
iagctl create secret -h
for more information.
- Run
-
Once the encryption key file is setup from step 3, encrypt the private key into the gateway encrypted store.
>_ iagctl create secret git-key \ --value @/Users/gatewayuser/.ssh/gateway_git_rsa \ --encryption-file /Users/toerrouser/.gateway.d/gateway_secret.key
-
Create the repository and reference the newly created secret with the
--private-key-file
flag.>_ iagctl create repository my-private-repo \ --url git@github.com:example/some-private-repo-with-automations.git \ --private-key-name git-key
iagctl create repository <name> --url <string> [flags]
Examples
Create a Publicly Accessible Repository
Creates a repository called my-public-repo
. This command assumes the git repo is publicly accessible and no authentication is required to access it.
>_ iagctl create repository my-public-repo \
--url git@github.com:example/some-public-repo-with-automations.git
Create a Repository that References a Specific Branch
Creates a repository called my-branch-reference
that will pull down the devel
branch when executing services.
>_ iagctl create repository my-branch-reference \
--url git@github.com:example/some-public-repo-with-automations.git \
--reference devel
Create a Private Repository that Requires Authentication
Creates a repository called my-private-repo
that references a private-key-name
that exists in gateway's secret store. This example assumes the user had previously created a gateway secret called git-key
.
>_ iagctl create repository my-private-repo \
--url git@github.com:example/some-private-repo-with-automations.git \
--private-key-name git-key
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 for retrieving the repository
--reference string The reference to checkout within the repository, e.g., branch, SHA
--tag stringArray Metadata tags to associate with the service
--url string The url of the repository
Options Inherited from Parent Commands
--config string Path to the configuration file
--raw Displays the result of the command in its raw format
--verbose Enable verbose output
CLI References
See related create
commands:
- create
- create decorator
- create secret
- create service
- create service ansible playbook
- create service opentofu plan
- create service python script
- create user
For all CLI commands see → Command References Index