1
0
mirror of synced 2026-02-13 13:06:56 +00:00

Flux CLI change to add provider field to GitRepository spec.

- Add provider flag to `flux create source git` command with supported values: azure, generic.

- Unit tests validating the generated yaml and error conditions.

Signed-off-by: Dipti Pai <diptipai89@outlook.com>
This commit is contained in:
Dipti Pai
2024-09-16 12:08:14 -07:00
committed by Sunny
parent 055d85fc18
commit a4ef1f6992
5 changed files with 119 additions and 1 deletions

View File

@@ -56,6 +56,7 @@ type sourceGitFlags struct {
keyRSABits flags.RSAKeyBits
keyECDSACurve flags.ECDSACurve
secretRef string
provider flags.SourceGitProvider
caFile string
privateKeyFile string
recurseSubmodules bool
@@ -119,7 +120,13 @@ For private Git repositories, the basic authentication credentials are stored in
--url=https://github.com/stefanprodan/podinfo \
--branch=master \
--username=username \
--password=password`,
--password=password
# Create a source for a Git repository using azure provider
flux create source git podinfo \
--url=https://dev.azure.com/foo/bar/_git/podinfo \
--branch=master \
--provider=azure`,
RunE: createSourceGitCmdRun,
}
@@ -138,6 +145,7 @@ func init() {
createSourceGitCmd.Flags().Var(&sourceGitArgs.keyRSABits, "ssh-rsa-bits", sourceGitArgs.keyRSABits.Description())
createSourceGitCmd.Flags().Var(&sourceGitArgs.keyECDSACurve, "ssh-ecdsa-curve", sourceGitArgs.keyECDSACurve.Description())
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.secretRef, "secret-ref", "", "the name of an existing secret containing SSH or basic credentials")
createSourceGitCmd.Flags().Var(&sourceGitArgs.provider, "provider", sourceGitArgs.provider.Description())
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.caFile, "ca-file", "", "path to TLS CA file used for validating self-signed certificates")
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.privateKeyFile, "private-key-file", "", "path to a passwordless private key file used for authenticating to the Git SSH server")
createSourceGitCmd.Flags().BoolVar(&sourceGitArgs.recurseSubmodules, "recurse-submodules", false,
@@ -236,6 +244,10 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
}
}
if provider := sourceGitArgs.provider.String(); provider != "" {
gitRepository.Spec.Provider = provider
}
if createArgs.export {
return printExport(exportGit(&gitRepository))
}