Skip to content

Commit b5ac7f1

Browse files
committed
add aws codecommit example and validation
Signed-off-by: Sanskar Jaiswal <[email protected]>
1 parent 2a70072 commit b5ac7f1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cmd/flux/bootstrap_git.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ command will perform an upgrade if needed.`,
6060
6161
# Run bootstrap for a Git repository with a private key and password
6262
flux bootstrap git --url=ssh://[email protected]/repository.git --private-key-file=<path/to/private.key> --password=<password>
63+
64+
# Run bootstrap for a Git repository on AWS CodeCommit
65+
flux bootstrap git --url=ssh://<SSH-Key-ID>@git-codecommit.<region>.amazonaws.com/v1/repos/<repository> --private-key-file=<path/to/private.key> --password=<SSH-passphrase>
6366
`,
6467
RunE: bootstrapGitCmdRun,
6568
}
@@ -115,6 +118,23 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
115118
return err
116119
}
117120

121+
if strings.Contains(repositoryURL.Hostname(), "git-codecommit") && strings.Contains(repositoryURL.Hostname(), "amazonaws.com") {
122+
if repositoryURL.Scheme == "ssh" {
123+
if repositoryURL.User == nil {
124+
return fmt.Errorf("invalid AWS CodeCommit url: ssh username should be specified in the url")
125+
}
126+
if repositoryURL.User.Username() == "git" {
127+
return fmt.Errorf("invalid AWS CodeCommit url: ssh username should be the SSH key ID for the provided private key")
128+
}
129+
if bootstrapArgs.privateKeyFile == "" {
130+
return fmt.Errorf("private key file is required for bootstrapping against AWS CodeCommit using ssh")
131+
}
132+
}
133+
if repositoryURL.Scheme == "https" && !bootstrapArgs.tokenAuth {
134+
return fmt.Errorf("--token-auth=true must be specified for using a HTTPS AWS CodeCommit url")
135+
}
136+
}
137+
118138
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
119139
defer cancel()
120140

0 commit comments

Comments
 (0)