Add GitRepository namespace arg to flux create image update
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
@@ -49,12 +49,26 @@ mentioned in YAMLs in a git repository.`,
|
|||||||
--push-branch=image-updates \
|
--push-branch=image-updates \
|
||||||
--author-name=flux \
|
--author-name=flux \
|
||||||
--author-email=flux@example.com \
|
--author-email=flux@example.com \
|
||||||
--commit-template="{{range .Updated.Images}}{{println .}}{{end}}"`,
|
--commit-template="{{range .Updated.Images}}{{println .}}{{end}}"
|
||||||
|
|
||||||
|
# Configure image updates for a Git repository in a different namespace
|
||||||
|
flux create image update apps \
|
||||||
|
--namespace=apps \
|
||||||
|
--git-repo-ref=flux-system \
|
||||||
|
--git-repo-namespace=flux-system \
|
||||||
|
--git-repo-path="./clusters/my-cluster" \
|
||||||
|
--checkout-branch=main \
|
||||||
|
--push-branch=image-updates \
|
||||||
|
--author-name=flux \
|
||||||
|
--author-email=flux@example.com \
|
||||||
|
--commit-template="{{range .Updated.Images}}{{println .}}{{end}}"
|
||||||
|
`,
|
||||||
RunE: createImageUpdateRun,
|
RunE: createImageUpdateRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
type imageUpdateFlags struct {
|
type imageUpdateFlags struct {
|
||||||
gitRepoRef string
|
gitRepoName string
|
||||||
|
gitRepoNamespace string
|
||||||
gitRepoPath string
|
gitRepoPath string
|
||||||
checkoutBranch string
|
checkoutBranch string
|
||||||
pushBranch string
|
pushBranch string
|
||||||
@@ -67,7 +81,8 @@ var imageUpdateArgs = imageUpdateFlags{}
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flags := createImageUpdateCmd.Flags()
|
flags := createImageUpdateCmd.Flags()
|
||||||
flags.StringVar(&imageUpdateArgs.gitRepoRef, "git-repo-ref", "", "the name of a GitRepository resource with details of the upstream Git repository")
|
flags.StringVar(&imageUpdateArgs.gitRepoName, "git-repo-ref", "", "the name of a GitRepository resource with details of the upstream Git repository")
|
||||||
|
flags.StringVar(&imageUpdateArgs.gitRepoNamespace, "git-repo-namespace", "", "the namespace of the GitRepository resource, defaults to the ImageUpdateAutomation namespace")
|
||||||
flags.StringVar(&imageUpdateArgs.gitRepoPath, "git-repo-path", "", "path to the directory containing the manifests to be updated, defaults to the repository root")
|
flags.StringVar(&imageUpdateArgs.gitRepoPath, "git-repo-path", "", "path to the directory containing the manifests to be updated, defaults to the repository root")
|
||||||
flags.StringVar(&imageUpdateArgs.checkoutBranch, "checkout-branch", "", "the branch to checkout")
|
flags.StringVar(&imageUpdateArgs.checkoutBranch, "checkout-branch", "", "the branch to checkout")
|
||||||
flags.StringVar(&imageUpdateArgs.pushBranch, "push-branch", "", "the branch to push commits to, defaults to the checkout branch if not specified")
|
flags.StringVar(&imageUpdateArgs.pushBranch, "push-branch", "", "the branch to push commits to, defaults to the checkout branch if not specified")
|
||||||
@@ -84,7 +99,7 @@ func createImageUpdateRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
objectName := args[0]
|
objectName := args[0]
|
||||||
|
|
||||||
if imageUpdateArgs.gitRepoRef == "" {
|
if imageUpdateArgs.gitRepoName == "" {
|
||||||
return fmt.Errorf("a reference to a GitRepository is required (--git-repo-ref)")
|
return fmt.Errorf("a reference to a GitRepository is required (--git-repo-ref)")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +129,8 @@ func createImageUpdateRun(cmd *cobra.Command, args []string) error {
|
|||||||
Spec: autov1.ImageUpdateAutomationSpec{
|
Spec: autov1.ImageUpdateAutomationSpec{
|
||||||
SourceRef: autov1.CrossNamespaceSourceReference{
|
SourceRef: autov1.CrossNamespaceSourceReference{
|
||||||
Kind: sourcev1.GitRepositoryKind,
|
Kind: sourcev1.GitRepositoryKind,
|
||||||
Name: imageUpdateArgs.gitRepoRef,
|
Name: imageUpdateArgs.gitRepoName,
|
||||||
|
Namespace: imageUpdateArgs.gitRepoNamespace,
|
||||||
},
|
},
|
||||||
|
|
||||||
GitSpec: &autov1.GitSpec{
|
GitSpec: &autov1.GitSpec{
|
||||||
|
|||||||
Reference in New Issue
Block a user