Skip to content

Commit fdbd71b

Browse files
authored
Merge pull request #215 from fluxcd/suspend
Implement source suspension
2 parents 32d4e77 + 5579dc8 commit fdbd71b

18 files changed

+172
-2
lines changed

api/v1beta1/bucket_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ type BucketSpec struct {
7171
// consult the documentation for your version to find out what those are.
7272
// +optional
7373
Ignore *string `json:"ignore,omitempty"`
74+
75+
// This flag tells the controller to suspend the reconciliation of this source.
76+
// +optional
77+
Suspend bool `json:"suspend,omitempty"`
7478
}
7579

7680
const (

api/v1beta1/gitrepository_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ type GitRepositorySpec struct {
6666
// consult the documentation for your version to find out what those are.
6767
// +optional
6868
Ignore *string `json:"ignore,omitempty"`
69+
70+
// This flag tells the controller to suspend the reconciliation of this source.
71+
// +optional
72+
Suspend bool `json:"suspend,omitempty"`
6973
}
7074

7175
// GitRepositoryRef defines the Git ref used for pull and checkout operations.

api/v1beta1/helmchart_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ type HelmChartSpec struct {
4949
// relative path in the SourceRef. Ignored when omitted.
5050
// +optional
5151
ValuesFile string `json:"valuesFile,omitempty"`
52+
53+
// This flag tells the controller to suspend the reconciliation of this source.
54+
// +optional
55+
Suspend bool `json:"suspend,omitempty"`
5256
}
5357

5458
// LocalHelmChartSourceReference contains enough information to let you locate

api/v1beta1/helmrepository_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ type HelmRepositorySpec struct {
5454
// +kubebuilder:default:="60s"
5555
// +optional
5656
Timeout *metav1.Duration `json:"timeout,omitempty"`
57+
58+
// This flag tells the controller to suspend the reconciliation of this source.
59+
// +optional
60+
Suspend bool `json:"suspend,omitempty"`
5761
}
5862

5963
// HelmRepositoryStatus defines the observed state of the HelmRepository.

config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ spec:
8787
TODO: Add other useful fields. apiVersion, kind, uid?'
8888
type: string
8989
type: object
90+
suspend:
91+
description: This flag tells the controller to suspend the reconciliation
92+
of this source.
93+
type: boolean
9094
timeout:
9195
default: 20s
9296
description: The timeout for download operations, defaults to 20s.

config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ spec:
8989
TODO: Add other useful fields. apiVersion, kind, uid?'
9090
type: string
9191
type: object
92+
suspend:
93+
description: This flag tells the controller to suspend the reconciliation
94+
of this source.
95+
type: boolean
9296
timeout:
9397
default: 20s
9498
description: The timeout for remote Git operations like cloning, defaults

config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ spec:
8686
- kind
8787
- name
8888
type: object
89+
suspend:
90+
description: This flag tells the controller to suspend the reconciliation
91+
of this source.
92+
type: boolean
8993
valuesFile:
9094
description: Alternative values file to use as the default chart values,
9195
expected to be a relative path in the SourceRef. Ignored when omitted.

config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ spec:
6363
TODO: Add other useful fields. apiVersion, kind, uid?'
6464
type: string
6565
type: object
66+
suspend:
67+
description: This flag tells the controller to suspend the reconciliation
68+
of this source.
69+
type: boolean
6670
timeout:
6771
default: 60s
6872
description: The timeout of index downloading, defaults to 60s.

controllers/bucket_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ func (r *BucketReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
9090
return r.reconcileDelete(ctx, bucket)
9191
}
9292

93+
// Return early if the object is suspended.
94+
if bucket.Spec.Suspend {
95+
log.Info("Reconciliation is suspended for this object")
96+
return ctrl.Result{}, nil
97+
}
98+
9399
// record reconciliation duration
94100
if r.MetricsRecorder != nil {
95101
objRef, err := reference.GetReference(r.Scheme, &bucket)

controllers/gitrepository_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
8989
return r.reconcileDelete(ctx, repository)
9090
}
9191

92+
// Return early if the object is suspended.
93+
if repository.Spec.Suspend {
94+
log.Info("Reconciliation is suspended for this object")
95+
return ctrl.Result{}, nil
96+
}
97+
9298
// record reconciliation duration
9399
if r.MetricsRecorder != nil {
94100
objRef, err := reference.GetReference(r.Scheme, &repository)

0 commit comments

Comments
 (0)