From f740d434dcc46a324b67c055540aab561421613a Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Sun, 5 Apr 2020 18:10:30 +0300 Subject: [PATCH] Add repository sync interval to API --- api/v1alpha1/gitrepository_types.go | 5 ++++- api/v1alpha1/helmrepository_types.go | 5 ++++- api/v1alpha1/zz_generated.deepcopy.go | 2 ++ config/crd/bases/sourcer.fluxcd.io_gitrepositories.yaml | 6 ++++++ config/crd/bases/sourcer.fluxcd.io_helmrepositories.yaml | 6 ++++++ controllers/helmrepository_controller.go | 2 +- 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/api/v1alpha1/gitrepository_types.go b/api/v1alpha1/gitrepository_types.go index da962e52..cbf53f5a 100644 --- a/api/v1alpha1/gitrepository_types.go +++ b/api/v1alpha1/gitrepository_types.go @@ -25,7 +25,10 @@ type GitRepositorySpec struct { // +kubebuilder:validation:MinLength=4 // The repository address - Url string `json:"url,omitempty"` + Url string `json:"url"` + + // The interval at which to check for repository updates + Interval metav1.Duration `json:"interval"` } // GitRepositoryStatus defines the observed state of GitRepository diff --git a/api/v1alpha1/helmrepository_types.go b/api/v1alpha1/helmrepository_types.go index da7f2d2c..0c659b1c 100644 --- a/api/v1alpha1/helmrepository_types.go +++ b/api/v1alpha1/helmrepository_types.go @@ -25,7 +25,10 @@ type HelmRepositorySpec struct { // +kubebuilder:validation:MinLength=4 // The repository address - Url string `json:"url,omitempty"` + Url string `json:"url"` + + // The interval at which to check for repository updates + Interval metav1.Duration `json:"interval"` } // HelmRepositoryStatus defines the observed state of HelmRepository diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index fd12faaf..0aae9134 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -86,6 +86,7 @@ func (in *GitRepositoryList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GitRepositorySpec) DeepCopyInto(out *GitRepositorySpec) { *out = *in + out.Interval = in.Interval } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitRepositorySpec. @@ -182,6 +183,7 @@ func (in *HelmRepositoryList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HelmRepositorySpec) DeepCopyInto(out *HelmRepositorySpec) { *out = *in + out.Interval = in.Interval } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmRepositorySpec. diff --git a/config/crd/bases/sourcer.fluxcd.io_gitrepositories.yaml b/config/crd/bases/sourcer.fluxcd.io_gitrepositories.yaml index b1ba1a58..db82e1c3 100644 --- a/config/crd/bases/sourcer.fluxcd.io_gitrepositories.yaml +++ b/config/crd/bases/sourcer.fluxcd.io_gitrepositories.yaml @@ -49,10 +49,16 @@ spec: spec: description: GitRepositorySpec defines the desired state of GitRepository properties: + interval: + description: The interval at which to check for repository updates + type: string url: description: The repository address minLength: 4 type: string + required: + - interval + - url type: object status: description: GitRepositoryStatus defines the observed state of GitRepository diff --git a/config/crd/bases/sourcer.fluxcd.io_helmrepositories.yaml b/config/crd/bases/sourcer.fluxcd.io_helmrepositories.yaml index 9e4ea8b7..fabeb1c4 100644 --- a/config/crd/bases/sourcer.fluxcd.io_helmrepositories.yaml +++ b/config/crd/bases/sourcer.fluxcd.io_helmrepositories.yaml @@ -49,10 +49,16 @@ spec: spec: description: HelmRepositorySpec defines the desired state of HelmRepository properties: + interval: + description: The interval at which to check for repository updates + type: string url: description: The repository address minLength: 4 type: string + required: + - interval + - url type: object status: description: HelmRepositoryStatus defines the observed state of HelmRepository diff --git a/controllers/helmrepository_controller.go b/controllers/helmrepository_controller.go index c3d98ece..218a5c15 100644 --- a/controllers/helmrepository_controller.go +++ b/controllers/helmrepository_controller.go @@ -101,7 +101,7 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err return ctrl.Result{}, err } - return ctrl.Result{RequeueAfter: time.Minute}, nil + return ctrl.Result{RequeueAfter: repo.Spec.Interval.Duration}, nil } func (r *HelmRepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error {