diff --git a/api/v1beta1/bucket_types.go b/api/v1beta1/bucket_types.go index 2c10960c4..32d196406 100644 --- a/api/v1beta1/bucket_types.go +++ b/api/v1beta1/bucket_types.go @@ -71,6 +71,10 @@ type BucketSpec struct { // consult the documentation for your version to find out what those are. // +optional Ignore *string `json:"ignore,omitempty"` + + // This flag tells the controller to suspend the reconciliation of this source. + // +optional + Suspend bool `json:"suspend,omitempty"` } const ( diff --git a/api/v1beta1/gitrepository_types.go b/api/v1beta1/gitrepository_types.go index ce2ea8d91..205667d06 100644 --- a/api/v1beta1/gitrepository_types.go +++ b/api/v1beta1/gitrepository_types.go @@ -66,6 +66,10 @@ type GitRepositorySpec struct { // consult the documentation for your version to find out what those are. // +optional Ignore *string `json:"ignore,omitempty"` + + // This flag tells the controller to suspend the reconciliation of this source. + // +optional + Suspend bool `json:"suspend,omitempty"` } // GitRepositoryRef defines the Git ref used for pull and checkout operations. diff --git a/api/v1beta1/helmchart_types.go b/api/v1beta1/helmchart_types.go index 6a7e6af5a..aa19edfee 100644 --- a/api/v1beta1/helmchart_types.go +++ b/api/v1beta1/helmchart_types.go @@ -49,6 +49,10 @@ type HelmChartSpec struct { // relative path in the SourceRef. Ignored when omitted. // +optional ValuesFile string `json:"valuesFile,omitempty"` + + // This flag tells the controller to suspend the reconciliation of this source. + // +optional + Suspend bool `json:"suspend,omitempty"` } // LocalHelmChartSourceReference contains enough information to let you locate diff --git a/api/v1beta1/helmrepository_types.go b/api/v1beta1/helmrepository_types.go index c8f7a76db..655f1e57f 100644 --- a/api/v1beta1/helmrepository_types.go +++ b/api/v1beta1/helmrepository_types.go @@ -54,6 +54,10 @@ type HelmRepositorySpec struct { // +kubebuilder:default:="60s" // +optional Timeout *metav1.Duration `json:"timeout,omitempty"` + + // This flag tells the controller to suspend the reconciliation of this source. + // +optional + Suspend bool `json:"suspend,omitempty"` } // HelmRepositoryStatus defines the observed state of the HelmRepository. diff --git a/config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml b/config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml index 5665a6a53..6e95950f4 100644 --- a/config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml +++ b/config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml @@ -87,6 +87,10 @@ spec: TODO: Add other useful fields. apiVersion, kind, uid?' type: string type: object + suspend: + description: This flag tells the controller to suspend the reconciliation + of this source. + type: boolean timeout: default: 20s description: The timeout for download operations, defaults to 20s. diff --git a/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml b/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml index 48c16056b..8478e39fc 100644 --- a/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml +++ b/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml @@ -89,6 +89,10 @@ spec: TODO: Add other useful fields. apiVersion, kind, uid?' type: string type: object + suspend: + description: This flag tells the controller to suspend the reconciliation + of this source. + type: boolean timeout: default: 20s description: The timeout for remote Git operations like cloning, defaults diff --git a/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml b/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml index 39af34b5e..c7da4899b 100644 --- a/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml +++ b/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml @@ -86,6 +86,10 @@ spec: - kind - name type: object + suspend: + description: This flag tells the controller to suspend the reconciliation + of this source. + type: boolean valuesFile: description: Alternative values file to use as the default chart values, expected to be a relative path in the SourceRef. Ignored when omitted. diff --git a/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml b/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml index 8cae509a5..00868c6ad 100644 --- a/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml +++ b/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml @@ -63,6 +63,10 @@ spec: TODO: Add other useful fields. apiVersion, kind, uid?' type: string type: object + suspend: + description: This flag tells the controller to suspend the reconciliation + of this source. + type: boolean timeout: default: 60s description: The timeout of index downloading, defaults to 60s. diff --git a/controllers/bucket_controller.go b/controllers/bucket_controller.go index 4ac120d39..7000c30ee 100644 --- a/controllers/bucket_controller.go +++ b/controllers/bucket_controller.go @@ -90,6 +90,12 @@ func (r *BucketReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { return r.reconcileDelete(ctx, bucket) } + // Return early if the object is suspended. + if bucket.Spec.Suspend { + log.Info("Reconciliation is suspended for this object") + return ctrl.Result{}, nil + } + // record reconciliation duration if r.MetricsRecorder != nil { objRef, err := reference.GetReference(r.Scheme, &bucket) diff --git a/controllers/gitrepository_controller.go b/controllers/gitrepository_controller.go index 88ef0e766..ae9f621d8 100644 --- a/controllers/gitrepository_controller.go +++ b/controllers/gitrepository_controller.go @@ -89,6 +89,12 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro return r.reconcileDelete(ctx, repository) } + // Return early if the object is suspended. + if repository.Spec.Suspend { + log.Info("Reconciliation is suspended for this object") + return ctrl.Result{}, nil + } + // record reconciliation duration if r.MetricsRecorder != nil { objRef, err := reference.GetReference(r.Scheme, &repository) diff --git a/controllers/helmchart_controller.go b/controllers/helmchart_controller.go index 995e203f0..2188e0091 100644 --- a/controllers/helmchart_controller.go +++ b/controllers/helmchart_controller.go @@ -95,6 +95,12 @@ func (r *HelmChartReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { return r.reconcileDelete(ctx, chart) } + // Return early if the object is suspended. + if chart.Spec.Suspend { + log.Info("Reconciliation is suspended for this object") + return ctrl.Result{}, nil + } + // Record reconciliation duration if r.MetricsRecorder != nil { objRef, err := reference.GetReference(r.Scheme, &chart) diff --git a/controllers/helmrepository_controller.go b/controllers/helmrepository_controller.go index fc889660c..06641ec61 100644 --- a/controllers/helmrepository_controller.go +++ b/controllers/helmrepository_controller.go @@ -90,6 +90,12 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err return r.reconcileDelete(ctx, repository) } + // Return early if the object is suspended. + if repository.Spec.Suspend { + log.Info("Reconciliation is suspended for this object") + return ctrl.Result{}, nil + } + // record reconciliation duration if r.MetricsRecorder != nil { objRef, err := reference.GetReference(r.Scheme, &repository) diff --git a/docs/api/source.md b/docs/api/source.md index 5ac019624..6e098a0fb 100644 --- a/docs/api/source.md +++ b/docs/api/source.md @@ -188,6 +188,18 @@ string consult the documentation for your version to find out what those are.
+suspendThis flag tells the controller to suspend the reconciliation of this source.
+suspendThis flag tells the controller to suspend the reconciliation of this source.
+suspendThis flag tells the controller to suspend the reconciliation of this source.
+The timeout of index downloading, defaults to 60s.
+suspendThis flag tells the controller to suspend the reconciliation of this source.
+suspendThis flag tells the controller to suspend the reconciliation of this source.
+suspendThis flag tells the controller to suspend the reconciliation of this source.
+suspendThis flag tells the controller to suspend the reconciliation of this source.
+The timeout of index downloading, defaults to 60s.
+suspendThis flag tells the controller to suspend the reconciliation of this source.
+