diff --git a/api/v1alpha1/imageupdateautomation_types.go b/api/v1alpha1/imageupdateautomation_types.go index ffc24f7d..108f500d 100644 --- a/api/v1alpha1/imageupdateautomation_types.go +++ b/api/v1alpha1/imageupdateautomation_types.go @@ -30,15 +30,18 @@ type ImageUpdateAutomationSpec struct { // ready to make changes. // +required Checkout GitCheckoutSpec `json:"checkout"` + // Interval gives an lower bound for how often the automation // run should be attempted. // +required Interval metav1.Duration `json:"interval"` + // Update gives the specification for how to update the files in // the repository. This can be left empty, to use the default // value. // +kubebuilder:default={"strategy":"Setters"} Update *UpdateStrategy `json:"update,omitempty"` + // Commit specifies how to commit to the git repository. // +required Commit CommitSpec `json:"commit"` @@ -87,6 +90,12 @@ type UpdateStrategy struct { // +required // +kubebuilder:default=Setters Strategy UpdateStrategyName `json:"strategy"` + + // Path to the directory containing the manifests to be updated. + // Defaults to 'None', which translates to the root path + // of the GitRepositoryRef. + // +optional + Path string `json:"path,omitempty"` } // CommitSpec specifies how to commit changes to the git repository diff --git a/config/crd/bases/image.toolkit.fluxcd.io_imageupdateautomations.yaml b/config/crd/bases/image.toolkit.fluxcd.io_imageupdateautomations.yaml index 0dd9f04e..629548ea 100644 --- a/config/crd/bases/image.toolkit.fluxcd.io_imageupdateautomations.yaml +++ b/config/crd/bases/image.toolkit.fluxcd.io_imageupdateautomations.yaml @@ -111,6 +111,11 @@ spec: files in the repository. This can be left empty, to use the default value. properties: + path: + description: Path to the directory containing the manifests to + be updated. Defaults to 'None', which translates to the root + path of the GitRepositoryRef. + type: string strategy: default: Setters description: Strategy names the strategy to be used. diff --git a/controllers/imageupdateautomation_controller.go b/controllers/imageupdateautomation_controller.go index b0591332..903eaf77 100644 --- a/controllers/imageupdateautomation_controller.go +++ b/controllers/imageupdateautomation_controller.go @@ -30,6 +30,7 @@ import ( gogit "github.com/go-git/go-git/v5" libgit2 "github.com/libgit2/git2go/v31" + securejoin "github.com/cyphar/filepath-securejoin" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" "github.com/go-logr/logr" @@ -196,7 +197,16 @@ func (r *ImageUpdateAutomationReconciler) Reconcile(ctx context.Context, req ctr return failWithError(err) } - if result, err := updateAccordingToSetters(ctx, tmp, policies.Items); err != nil { + manifestsPath := tmp + if auto.Spec.Update.Path != "" { + if p, err := securejoin.SecureJoin(tmp, auto.Spec.Update.Path); err != nil { + return failWithError(err) + } else { + manifestsPath = p + } + } + + if result, err := updateAccordingToSetters(ctx, manifestsPath, policies.Items); err != nil { return failWithError(err) } else { templateValues.Updated = result diff --git a/docs/api/image-automation.md b/docs/api/image-automation.md index 2ca9543c..1446b195 100644 --- a/docs/api/image-automation.md +++ b/docs/api/image-automation.md @@ -88,8 +88,8 @@ into which will be interpolated the details of the change made.
gitRepositoryRef
Branch gives the branch to clone from the git repository.
+Branch gives the branch to clone from the git repository. If
+.spec.push
is not supplied, commits will also be pushed to
+this branch.
Commit specifies how to commit to the git repo
+Commit specifies how to commit to the git repository.
+push
Push specifies how and where to push commits made by the
+automation. If missing, commits are pushed (back) to
+.spec.checkout.branch
.
Commit specifies how to commit to the git repo
+Commit specifies how to commit to the git repository.
+push
Push specifies how and where to push commits made by the
+automation. If missing, commits are pushed (back) to
+.spec.checkout.branch
.
+(Appears on: +ImageUpdateAutomationSpec) +
+PushSpec specifies how and where to push commits.
+Field | +Description | +
---|---|
+branch + +string + + |
+
+ Branch specifies that commits should be pushed to the branch
+named. The branch is created using |
+
@@ -466,6 +534,20 @@ UpdateStrategyName
Strategy names the strategy to be used.
path
Path to the directory containing the manifests to be updated. +Defaults to ‘None’, which translates to the root path +of the GitRepositoryRef.
+