From 4d30a82ef4ff8ab3a22f32c4f9f49a24b0971bdb Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Wed, 8 Apr 2020 12:06:23 +0200 Subject: [PATCH] Rename project to source-controller --- .github/workflows/e2e.yaml | 8 +-- Dockerfile | 6 +- Makefile | 6 +- PROJECT | 6 +- README.md | 5 +- api/v1alpha1/groupversion_info.go | 6 +- ... => source.fluxcd.io_gitrepositories.yaml} | 4 +- ...=> source.fluxcd.io_helmrepositories.yaml} | 4 +- config/crd/kustomization.yaml | 4 +- config/default/kustomization.yaml | 4 +- config/manager/deployment.yaml | 6 +- config/manager/kustomization.yaml | 2 +- config/manager/service.yaml | 2 +- config/rbac/gitrepository_editor_role.yaml | 4 +- config/rbac/gitrepository_viewer_role.yaml | 4 +- config/rbac/helmrepository_editor_role.yaml | 4 +- config/rbac/helmrepository_viewer_role.yaml | 4 +- config/rbac/role.yaml | 8 +-- ...aml => source_v1alpha1_gitrepository.yaml} | 4 +- ...ml => source_v1alpha1_helmrepository.yaml} | 3 +- controllers/gitrepository_controller.go | 64 +++++++++---------- controllers/helmrepository_controller.go | 25 ++++---- controllers/predicate.go | 2 +- controllers/suite_test.go | 6 +- go.mod | 2 +- main.go | 6 +- 26 files changed, 100 insertions(+), 99 deletions(-) rename config/crd/bases/{sourcer.fluxcd.io_gitrepositories.yaml => source.fluxcd.io_gitrepositories.yaml} (98%) rename config/crd/bases/{sourcer.fluxcd.io_helmrepositories.yaml => source.fluxcd.io_helmrepositories.yaml} (98%) rename config/samples/{sourcer_v1alpha1_gitrepository.yaml => source_v1alpha1_gitrepository.yaml} (62%) rename config/samples/{sourcer_v1alpha1_helmrepository.yaml => source_v1alpha1_helmrepository.yaml} (74%) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 3ef2c0d4..20a8b008 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -42,14 +42,14 @@ jobs: - name: Run smoke tests run: | kubectl apply -f ./config/samples - kubectl -n sourcer-system rollout status deploy/sourcer-controller --timeout=1m + kubectl -n source-system rollout status deploy/source-controller --timeout=1m kubectl wait gitrepository/podinfo --for=condition=ready --timeout=1m kubectl wait helmrepository/podinfo --for=condition=ready --timeout=1m - kubectl -n sourcer-system logs deploy/sourcer-controller + kubectl -n source-system logs deploy/source-controller - name: Debug failure if: failure() run: | kubectl get gitrepositories -oyaml kubectl get helmrepositories -oyaml - kubectl -n sourcer-system get all - kubectl -n sourcer-system logs deploy/sourcer-controller + kubectl -n source-system get all + kubectl -n source-system logs deploy/source-controller diff --git a/Dockerfile b/Dockerfile index 28eafea7..eaa5d09f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,12 +15,12 @@ COPY api/ api/ COPY controllers/ controllers/ # build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o sourcer main.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o source-controller main.go FROM alpine:3.11 RUN apk add --no-cache openssh-client ca-certificates tini 'git>=2.12.0' socat curl bash -COPY --from=builder /workspace/sourcer /usr/local/bin/ +COPY --from=builder /workspace/source-controller /usr/local/bin/ -ENTRYPOINT [ "/sbin/tini", "--", "sourcer" ] +ENTRYPOINT [ "/sbin/tini", "--", "source-controller" ] diff --git a/Makefile b/Makefile index efd4ac40..5fa45923 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Image URL to use all building/pushing image targets -IMG ?= fluxcd/sourcer:latest +IMG ?= fluxcd/source-controller:latest # Produce CRDs that work back to Kubernetes 1.13 CRD_OPTIONS ?= crd @@ -35,13 +35,13 @@ uninstall: manifests # Deploy controller in the configured Kubernetes cluster in ~/.kube/config deploy: manifests - cd config/manager && kustomize edit set image fluxcd/sourcer=${IMG} + cd config/manager && kustomize edit set image fluxcd/source-controller=${IMG} kustomize build config/default | kubectl apply -f - # Deploy controller dev image in the configured Kubernetes cluster in ~/.kube/config dev-deploy: manifests mkdir -p config/dev && cp config/default/* config/dev - cd config/dev && kustomize edit set image fluxcd/sourcer=${IMG} + cd config/dev && kustomize edit set image fluxcd/source-controller=${IMG} kustomize build config/dev | kubectl apply -f - rm -rf config/dev diff --git a/PROJECT b/PROJECT index e48f0244..02c03e29 100644 --- a/PROJECT +++ b/PROJECT @@ -1,10 +1,10 @@ domain: fluxcd.io -repo: github.com/fluxcd/sourcer +repo: github.com/fluxcd/source-controller resources: -- group: sourcer +- group: source kind: GitRepository version: v1alpha1 -- group: sourcer +- group: source kind: HelmRepository version: v1alpha1 version: "2" diff --git a/README.md b/README.md index 7132595a..4e94fbba 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -# sourcer -Experimental source manager +# Source controller + +Experimental source manager and artifact provider. diff --git a/api/v1alpha1/groupversion_info.go b/api/v1alpha1/groupversion_info.go index 771b5297..57a0cbd3 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/api/v1alpha1/groupversion_info.go @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1alpha1 contains API Schema definitions for the sourcer v1alpha1 API group +// Package v1alpha1 contains API Schema definitions for the source v1alpha1 API group // +kubebuilder:object:generate=true -// +groupName=sourcer.fluxcd.io +// +groupName=source.fluxcd.io package v1alpha1 import ( @@ -26,7 +26,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "sourcer.fluxcd.io", Version: "v1alpha1"} + GroupVersion = schema.GroupVersion{Group: "source.fluxcd.io", Version: "v1alpha1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/config/crd/bases/sourcer.fluxcd.io_gitrepositories.yaml b/config/crd/bases/source.fluxcd.io_gitrepositories.yaml similarity index 98% rename from config/crd/bases/sourcer.fluxcd.io_gitrepositories.yaml rename to config/crd/bases/source.fluxcd.io_gitrepositories.yaml index 02a4395e..bef14846 100644 --- a/config/crd/bases/sourcer.fluxcd.io_gitrepositories.yaml +++ b/config/crd/bases/source.fluxcd.io_gitrepositories.yaml @@ -6,7 +6,7 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.2.5 creationTimestamp: null - name: gitrepositories.sourcer.fluxcd.io + name: gitrepositories.source.fluxcd.io spec: additionalPrinterColumns: - JSONPath: .spec.url @@ -21,7 +21,7 @@ spec: - JSONPath: .metadata.creationTimestamp name: Age type: date - group: sourcer.fluxcd.io + group: source.fluxcd.io names: kind: GitRepository listKind: GitRepositoryList diff --git a/config/crd/bases/sourcer.fluxcd.io_helmrepositories.yaml b/config/crd/bases/source.fluxcd.io_helmrepositories.yaml similarity index 98% rename from config/crd/bases/sourcer.fluxcd.io_helmrepositories.yaml rename to config/crd/bases/source.fluxcd.io_helmrepositories.yaml index fabeb1c4..c6ae8d03 100644 --- a/config/crd/bases/sourcer.fluxcd.io_helmrepositories.yaml +++ b/config/crd/bases/source.fluxcd.io_helmrepositories.yaml @@ -6,7 +6,7 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.2.5 creationTimestamp: null - name: helmrepositories.sourcer.fluxcd.io + name: helmrepositories.source.fluxcd.io spec: additionalPrinterColumns: - JSONPath: .spec.url @@ -21,7 +21,7 @@ spec: - JSONPath: .metadata.creationTimestamp name: Age type: date - group: sourcer.fluxcd.io + group: source.fluxcd.io names: kind: HelmRepository listKind: HelmRepositoryList diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 904adb68..a9d6ae22 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -1,7 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- bases/sourcer.fluxcd.io_gitrepositories.yaml -- bases/sourcer.fluxcd.io_helmrepositories.yaml +- bases/source.fluxcd.io_gitrepositories.yaml +- bases/source.fluxcd.io_helmrepositories.yaml # +kubebuilder:scaffold:crdkustomizeresource diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index ddc00689..f9dba8ba 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -1,7 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization -namespace: sourcer-system -namePrefix: sourcer- +namespace: source-system +namePrefix: source- bases: - ../crd - ../rbac diff --git a/config/manager/deployment.yaml b/config/manager/deployment.yaml index 4722eba7..425fca39 100644 --- a/config/manager/deployment.yaml +++ b/config/manager/deployment.yaml @@ -8,12 +8,12 @@ metadata: spec: selector: matchLabels: - app: sourcer + app: source-controller replicas: 1 template: metadata: labels: - app: sourcer + app: source-controller annotations: prometheus.io/scrape: "true" prometheus.io/port: "9090" @@ -21,7 +21,7 @@ spec: terminationGracePeriodSeconds: 10 containers: - name: manager - image: fluxcd/sourcer + image: fluxcd/source-controller imagePullPolicy: IfNotPresent ports: - containerPort: 8080 diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index fee50a12..adf766d2 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -5,5 +5,5 @@ resources: - service.yaml - deployment.yaml images: -- name: fluxcd/sourcer +- name: fluxcd/source-controller newTag: 0.0.1-alpha.1 diff --git a/config/manager/service.yaml b/config/manager/service.yaml index 4ebd3dd7..e03b237b 100644 --- a/config/manager/service.yaml +++ b/config/manager/service.yaml @@ -8,7 +8,7 @@ metadata: spec: type: ClusterIP selector: - app: sourcer + app: source-controller ports: - name: http port: 80 diff --git a/config/rbac/gitrepository_editor_role.yaml b/config/rbac/gitrepository_editor_role.yaml index 9f9c19b1..a736627a 100644 --- a/config/rbac/gitrepository_editor_role.yaml +++ b/config/rbac/gitrepository_editor_role.yaml @@ -5,7 +5,7 @@ metadata: name: gitrepository-editor-role rules: - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - gitrepositories verbs: @@ -17,7 +17,7 @@ rules: - update - watch - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - gitrepositories/status verbs: diff --git a/config/rbac/gitrepository_viewer_role.yaml b/config/rbac/gitrepository_viewer_role.yaml index f22a109f..46fa3efc 100644 --- a/config/rbac/gitrepository_viewer_role.yaml +++ b/config/rbac/gitrepository_viewer_role.yaml @@ -5,7 +5,7 @@ metadata: name: gitrepository-viewer-role rules: - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - gitrepositories verbs: @@ -13,7 +13,7 @@ rules: - list - watch - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - gitrepositories/status verbs: diff --git a/config/rbac/helmrepository_editor_role.yaml b/config/rbac/helmrepository_editor_role.yaml index adfc23ed..45448649 100644 --- a/config/rbac/helmrepository_editor_role.yaml +++ b/config/rbac/helmrepository_editor_role.yaml @@ -5,7 +5,7 @@ metadata: name: helmrepository-editor-role rules: - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - helmrepositories verbs: @@ -17,7 +17,7 @@ rules: - update - watch - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - helmrepositories/status verbs: diff --git a/config/rbac/helmrepository_viewer_role.yaml b/config/rbac/helmrepository_viewer_role.yaml index 9dc0c7a5..2a869465 100644 --- a/config/rbac/helmrepository_viewer_role.yaml +++ b/config/rbac/helmrepository_viewer_role.yaml @@ -5,7 +5,7 @@ metadata: name: helmrepository-viewer-role rules: - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - helmrepositories verbs: @@ -13,7 +13,7 @@ rules: - list - watch - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - helmrepositories/status verbs: diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 249850dc..4e72e864 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -7,7 +7,7 @@ metadata: name: manager-role rules: - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - gitrepositories verbs: @@ -19,7 +19,7 @@ rules: - update - watch - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - gitrepositories/status verbs: @@ -27,7 +27,7 @@ rules: - patch - update - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - helmrepositories verbs: @@ -39,7 +39,7 @@ rules: - update - watch - apiGroups: - - sourcer.fluxcd.io + - source.fluxcd.io resources: - helmrepositories/status verbs: diff --git a/config/samples/sourcer_v1alpha1_gitrepository.yaml b/config/samples/source_v1alpha1_gitrepository.yaml similarity index 62% rename from config/samples/sourcer_v1alpha1_gitrepository.yaml rename to config/samples/source_v1alpha1_gitrepository.yaml index fa37b11f..df84d650 100644 --- a/config/samples/sourcer_v1alpha1_gitrepository.yaml +++ b/config/samples/source_v1alpha1_gitrepository.yaml @@ -1,9 +1,9 @@ -apiVersion: sourcer.fluxcd.io/v1alpha1 +apiVersion: source.fluxcd.io/v1alpha1 kind: GitRepository metadata: name: podinfo annotations: - sourcer.fluxcd.io/syncAt: "2020-04-06T15:39:52+03:00" + source.fluxcd.io/syncAt: "2020-04-06T15:39:52+03:00" spec: interval: 1m url: https://github.com/stefanprodan/podinfo diff --git a/config/samples/sourcer_v1alpha1_helmrepository.yaml b/config/samples/source_v1alpha1_helmrepository.yaml similarity index 74% rename from config/samples/sourcer_v1alpha1_helmrepository.yaml rename to config/samples/source_v1alpha1_helmrepository.yaml index 0bdbb29b..05257b5c 100644 --- a/config/samples/sourcer_v1alpha1_helmrepository.yaml +++ b/config/samples/source_v1alpha1_helmrepository.yaml @@ -1,8 +1,7 @@ -apiVersion: sourcer.fluxcd.io/v1alpha1 +apiVersion: source.fluxcd.io/v1alpha1 kind: HelmRepository metadata: name: podinfo spec: interval: 1m url: https://stefanprodan.github.io/podinfo - diff --git a/controllers/gitrepository_controller.go b/controllers/gitrepository_controller.go index 05c8d269..92f25485 100644 --- a/controllers/gitrepository_controller.go +++ b/controllers/gitrepository_controller.go @@ -38,7 +38,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" - sourcerv1 "github.com/fluxcd/sourcer/api/v1alpha1" + sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" ) // GitRepositoryReconciler reconciles a GitRepository object @@ -49,8 +49,8 @@ type GitRepositoryReconciler struct { StoragePath string } -// +kubebuilder:rbac:groups=sourcer.fluxcd.io,resources=gitrepositories,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=sourcer.fluxcd.io,resources=gitrepositories/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=source.fluxcd.io,resources=gitrepositories,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=source.fluxcd.io,resources=gitrepositories/status,verbs=get;update;patch func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) @@ -58,7 +58,7 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro log := r.Log.WithValues("gitrepository", req.NamespacedName) - var repo sourcerv1.GitRepository + var repo sourcev1.GitRepository if err := r.Get(ctx, req.NamespacedName, &repo); err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) } @@ -70,9 +70,9 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro log.Info("Initialising repository") repo.Status.Artifacts = "" repo.Status.LastUpdateTime = nil - repo.Status.Conditions = []sourcerv1.RepositoryCondition{ + repo.Status.Conditions = []sourcev1.RepositoryCondition{ { - Type: sourcerv1.RepositoryConditionReady, + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionUnknown, }, } @@ -99,7 +99,7 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro // update status timeNew := metav1.Now() readyCondition.LastTransitionTime = &timeNew - repo.Status.Conditions = []sourcerv1.RepositoryCondition{readyCondition} + repo.Status.Conditions = []sourcev1.RepositoryCondition{readyCondition} if err := r.Status().Update(ctx, &repo); err != nil { log.Error(err, "unable to update GitRepository status") @@ -112,7 +112,7 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro func (r *GitRepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&sourcerv1.GitRepository{}). + For(&sourcev1.GitRepository{}). WithEventFilter(RepositoryChangePredicate{}). WithEventFilter(predicate.Funcs{ DeleteFunc: func(e event.DeleteEvent) bool { @@ -132,7 +132,7 @@ func (r *GitRepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error { Complete(r) } -func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.RepositoryCondition, string, error) { +func (r *GitRepositoryReconciler) sync(gr sourcev1.GitRepository) (sourcev1.RepositoryCondition, string, error) { // determine ref refName := plumbing.NewBranchReferenceName("master") if gr.Spec.Branch != "" { @@ -146,8 +146,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re dir, err := ioutil.TempDir("", gr.Name) if err != nil { ex := fmt.Errorf("tmp dir error %w", err) - return sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + return sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionFalse, Reason: "ExecFailed", Message: ex.Error(), @@ -165,8 +165,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re }) if err != nil { ex := fmt.Errorf("git clone error %w", err) - return sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + return sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionFalse, Reason: "GitCloneFailed", Message: ex.Error(), @@ -178,8 +178,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re rng, err := semver.ParseRange(gr.Spec.SemVer) if err != nil { ex := fmt.Errorf("semver parse range error %w", err) - return sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + return sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionFalse, Reason: "GitCloneFailed", Message: ex.Error(), @@ -189,8 +189,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re repoTags, err := repo.Tags() if err != nil { ex := fmt.Errorf("git list tags error %w", err) - return sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + return sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionFalse, Reason: "GitCloneFailed", Message: ex.Error(), @@ -222,8 +222,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re w, err := repo.Worktree() if err != nil { ex := fmt.Errorf("git worktree error %w", err) - return sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + return sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionFalse, Reason: "GitCheckoutFailed", Message: ex.Error(), @@ -235,8 +235,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re }) if err != nil { ex := fmt.Errorf("git checkout error %w", err) - return sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + return sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionFalse, Reason: "GitCheckoutFailed", Message: ex.Error(), @@ -244,8 +244,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re } } else { ex := fmt.Errorf("no match found for semver %s", gr.Spec.SemVer) - return sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + return sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionFalse, Reason: "GitCheckoutFailed", Message: ex.Error(), @@ -257,8 +257,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re ref, err := repo.Head() if err != nil { ex := fmt.Errorf("git resolve HEAD error %w", err) - return sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + return sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionFalse, Reason: "GitHeadFailed", Message: ex.Error(), @@ -271,8 +271,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re err = os.MkdirAll(storage, 0777) if err != nil { ex := fmt.Errorf("mkdir dir error %w", err) - return sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + return sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionFalse, Reason: "ExecFailed", Message: ex.Error(), @@ -287,8 +287,8 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re err = command.Run() if err != nil { ex := fmt.Errorf("tar %s error %w", artifacts, err) - return sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + return sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionFalse, Reason: "ExecFailed", Message: ex.Error(), @@ -305,15 +305,15 @@ func (r *GitRepositoryReconciler) sync(gr sourcerv1.GitRepository) (sourcerv1.Re artifactsURL := fmt.Sprintf("http://%s/repositories/%s-%s/%s.tar.gz", hostname, gr.Name, gr.Namespace, ref.Hash().String()) - return sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + return sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionTrue, Reason: "GitCloneSucceed", Message: fmt.Sprintf("Fetched artifacts are available at %s", artifacts), }, artifactsURL, nil } -func (r *GitRepositoryReconciler) shouldResetStatus(gr sourcerv1.GitRepository) bool { +func (r *GitRepositoryReconciler) shouldResetStatus(gr sourcev1.GitRepository) bool { resetStatus := false if gr.Status.Artifacts != "" { pathParts := strings.Split(gr.Status.Artifacts, "/") diff --git a/controllers/helmrepository_controller.go b/controllers/helmrepository_controller.go index 1aeba61a..4b2e16c6 100644 --- a/controllers/helmrepository_controller.go +++ b/controllers/helmrepository_controller.go @@ -25,7 +25,6 @@ import ( "path" "time" - sourcerv1 "github.com/fluxcd/sourcer/api/v1alpha1" "github.com/go-logr/logr" "gopkg.in/yaml.v2" corev1 "k8s.io/api/core/v1" @@ -33,6 +32,8 @@ import ( "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + + sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" ) // HelmRepositoryReconciler reconciles a HelmRepository object @@ -42,8 +43,8 @@ type HelmRepositoryReconciler struct { Scheme *runtime.Scheme } -// +kubebuilder:rbac:groups=sourcer.fluxcd.io,resources=helmrepositories,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=sourcer.fluxcd.io,resources=helmrepositories/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=source.fluxcd.io,resources=helmrepositories,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=source.fluxcd.io,resources=helmrepositories/status,verbs=get;update;patch func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) @@ -51,27 +52,27 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err log := r.Log.WithValues("helmrepository", req.NamespacedName) - var repo sourcerv1.HelmRepository + var repo sourcev1.HelmRepository if err := r.Get(ctx, req.NamespacedName, &repo); err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) } - readyCondition := sourcerv1.RepositoryCondition{ - Type: sourcerv1.RepositoryConditionReady, + readyCondition := sourcev1.RepositoryCondition{ + Type: sourcev1.RepositoryConditionReady, Status: corev1.ConditionUnknown, } if len(repo.Status.Conditions) == 0 { log.Info("Starting index download") - repo.Status.Conditions = []sourcerv1.RepositoryCondition{readyCondition} + repo.Status.Conditions = []sourcev1.RepositoryCondition{readyCondition} if err := r.Status().Update(ctx, &repo); err != nil { log.Error(err, "unable to update HelmRepository status") return ctrl.Result{}, err } } else { for _, condition := range repo.Status.Conditions { - if condition.Type == sourcerv1.RepositoryConditionReady { + if condition.Type == sourcev1.RepositoryConditionReady { readyCondition = condition break } @@ -80,19 +81,19 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err if err := r.downloadIndex(repo.Spec.Url); err != nil { log.Info("Index download error", "error", err.Error()) - readyCondition.Reason = sourcerv1.IndexDownloadFailedReason + readyCondition.Reason = sourcev1.IndexDownloadFailedReason readyCondition.Message = err.Error() readyCondition.Status = corev1.ConditionFalse } else { log.Info("Index download successful") - readyCondition.Reason = sourcerv1.IndexDownloadSucceedReason + readyCondition.Reason = sourcev1.IndexDownloadSucceedReason readyCondition.Message = "Repository is ready" readyCondition.Status = corev1.ConditionTrue } timeNew := metav1.Now() readyCondition.LastTransitionTime = &timeNew - repo.Status.Conditions = []sourcerv1.RepositoryCondition{readyCondition} + repo.Status.Conditions = []sourcev1.RepositoryCondition{readyCondition} if err := r.Status().Update(ctx, &repo); err != nil { log.Error(err, "unable to update HelmRepository status") @@ -104,7 +105,7 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err func (r *HelmRepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&sourcerv1.HelmRepository{}). + For(&sourcev1.HelmRepository{}). WithEventFilter(RepositoryChangePredicate{}). Complete(r) } diff --git a/controllers/predicate.go b/controllers/predicate.go index 88dc2ebd..8ede12a9 100644 --- a/controllers/predicate.go +++ b/controllers/predicate.go @@ -35,5 +35,5 @@ func (RepositoryChangePredicate) Update(e event.UpdateEvent) bool { } const ( - ForceSyncAnnotation string = "sourcer.fluxcd.io/syncAt" + ForceSyncAnnotation string = "source.fluxcd.io/syncAt" ) diff --git a/controllers/suite_test.go b/controllers/suite_test.go index ebeec4df..3bce0d52 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -30,7 +30,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - sourcerv1alpha1 "github.com/fluxcd/sourcer/api/v1alpha1" + sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" // +kubebuilder:scaffold:imports ) @@ -62,10 +62,10 @@ var _ = BeforeSuite(func(done Done) { Expect(err).ToNot(HaveOccurred()) Expect(cfg).ToNot(BeNil()) - err = sourcerv1alpha1.AddToScheme(scheme.Scheme) + err = sourcev1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) - err = sourcerv1alpha1.AddToScheme(scheme.Scheme) + err = sourcev1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) // +kubebuilder:scaffold:scheme diff --git a/go.mod b/go.mod index ee135590..f30e5bfb 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/fluxcd/sourcer +module github.com/fluxcd/source-controller go 1.13 diff --git a/main.go b/main.go index 206750ef..688a3b50 100644 --- a/main.go +++ b/main.go @@ -29,8 +29,8 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log/zap" - sourcerv1alpha1 "github.com/fluxcd/sourcer/api/v1alpha1" - "github.com/fluxcd/sourcer/controllers" + sourcev1alpha1 "github.com/fluxcd/source-controller/api/v1alpha1" + "github.com/fluxcd/source-controller/controllers" // +kubebuilder:scaffold:imports ) @@ -42,7 +42,7 @@ var ( func init() { _ = clientgoscheme.AddToScheme(scheme) - _ = sourcerv1alpha1.AddToScheme(scheme) + _ = sourcev1alpha1.AddToScheme(scheme) // +kubebuilder:scaffold:scheme }