diff --git a/.github/workflows/lint-argocd-crd.yml b/.github/workflows/lint-argocd-crd.yml new file mode 100644 index 000000000..f8136b723 --- /dev/null +++ b/.github/workflows/lint-argocd-crd.yml @@ -0,0 +1,16 @@ +name: Lint Argo CD CRDs +on: + pull_request: + branches: + - 'master' + - 'release-*' + - 'rhos-*' +jobs: + lint_code: + name: Run golangci-lint on PR + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Run linter + run: make lint-argocd-crds \ No newline at end of file diff --git a/Makefile b/Makefile index 45c02a62f..afd69a8f7 100644 --- a/Makefile +++ b/Makefile @@ -199,7 +199,6 @@ bundle: operator-sdk manifests kustomize ## Generate bundle manifests and metada cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) $(OPERATOR_SDK) bundle validate ./bundle - sed -i 's/control-plane: argocd-operator/control-plane: controller-manager/g' bundle/manifests/argocd-operator-webhook-service_v1_service.yaml bundle/manifests/argocd-operator-controller-manager-metrics-service_v1_service.yaml bundle/manifests/argocd-operator.clusterserviceversion.yaml rm -fr deploy/olm-catalog/argocd-operator/$(VERSION) mkdir -p deploy/olm-catalog/argocd-operator/$(VERSION) cp -r bundle/manifests/* deploy/olm-catalog/argocd-operator/$(VERSION)/ @@ -282,3 +281,13 @@ catalog-build: opm ## Build a catalog image. .PHONY: catalog-push catalog-push: ## Push a catalog image. $(MAKE) docker-push IMG=$(CATALOG_IMG) + +# Lint Argo CD CRDs for the version specified in go.mod. +.PHONY: lint-argocd-crds +lint-argocd-crds: + $(SHELL) hack/manage-argocd-crds.sh lint + +# Update Argo CD CRDs for the version specified in go.mod. +.PHONY: update-argocd-crds +update-argocd-crds: + $(SHELL) hack/manage-argocd-crds.sh diff --git a/bundle/manifests/argocd-operator-controller-manager-metrics-service_v1_service.yaml b/bundle/manifests/argocd-operator-controller-manager-metrics-service_v1_service.yaml index f23604e16..8d1547d9a 100644 --- a/bundle/manifests/argocd-operator-controller-manager-metrics-service_v1_service.yaml +++ b/bundle/manifests/argocd-operator-controller-manager-metrics-service_v1_service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: creationTimestamp: null labels: - control-plane: controller-manager + control-plane: argocd-operator name: argocd-operator-controller-manager-metrics-service spec: ports: @@ -11,6 +11,6 @@ spec: port: 8443 targetPort: 8080 selector: - control-plane: controller-manager + control-plane: argocd-operator status: loadBalancer: {} diff --git a/bundle/manifests/argocd-operator-webhook-service_v1_service.yaml b/bundle/manifests/argocd-operator-webhook-service_v1_service.yaml index 101e0db27..f5dda7bc9 100644 --- a/bundle/manifests/argocd-operator-webhook-service_v1_service.yaml +++ b/bundle/manifests/argocd-operator-webhook-service_v1_service.yaml @@ -9,6 +9,6 @@ spec: protocol: TCP targetPort: 9443 selector: - control-plane: controller-manager + control-plane: argocd-operator status: loadBalancer: {} diff --git a/bundle/manifests/argocd-operator.clusterserviceversion.yaml b/bundle/manifests/argocd-operator.clusterserviceversion.yaml index a924e19ed..7f90f5145 100644 --- a/bundle/manifests/argocd-operator.clusterserviceversion.yaml +++ b/bundle/manifests/argocd-operator.clusterserviceversion.yaml @@ -247,7 +247,7 @@ metadata: capabilities: Deep Insights categories: Integration & Delivery certified: "false" - createdAt: "2024-10-16T08:53:24Z" + createdAt: "2024-10-30T17:57:12Z" description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. operators.operatorframework.io/builder: operator-sdk-v1.35.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v4 @@ -1874,20 +1874,20 @@ spec: serviceAccountName: argocd-operator-controller-manager deployments: - label: - control-plane: controller-manager + control-plane: argocd-operator name: argocd-operator-controller-manager spec: replicas: 1 selector: matchLabels: - control-plane: controller-manager + control-plane: argocd-operator strategy: {} template: metadata: annotations: kubectl.kubernetes.io/default-container: manager labels: - control-plane: controller-manager + control-plane: argocd-operator spec: containers: - args: diff --git a/bundle/manifests/argoproj.io_applications.yaml b/bundle/manifests/argoproj.io_applications.yaml index fc06983e5..55abcb203 100644 --- a/bundle/manifests/argoproj.io_applications.yaml +++ b/bundle/manifests/argoproj.io_applications.yaml @@ -1,7 +1,6 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - creationTimestamp: null labels: app.kubernetes.io/name: applications.argoproj.io app.kubernetes.io/part-of: argocd @@ -4998,9 +4997,3 @@ spec: served: true storage: true subresources: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: null - storedVersions: null diff --git a/bundle/manifests/argoproj.io_applicationsets.yaml b/bundle/manifests/argoproj.io_applicationsets.yaml index cc4e2130e..8b33949da 100644 --- a/bundle/manifests/argoproj.io_applicationsets.yaml +++ b/bundle/manifests/argoproj.io_applicationsets.yaml @@ -1,7 +1,6 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - creationTimestamp: null labels: app.kubernetes.io/name: applicationsets.argoproj.io app.kubernetes.io/part-of: argocd @@ -15378,9 +15377,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: null - storedVersions: null diff --git a/bundle/manifests/argoproj.io_appprojects.yaml b/bundle/manifests/argoproj.io_appprojects.yaml index a9d3b475d..2ebe3c2f4 100644 --- a/bundle/manifests/argoproj.io_appprojects.yaml +++ b/bundle/manifests/argoproj.io_appprojects.yaml @@ -1,7 +1,6 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - creationTimestamp: null labels: app.kubernetes.io/name: appprojects.argoproj.io app.kubernetes.io/part-of: argocd @@ -329,9 +328,3 @@ spec: type: object served: true storage: true -status: - acceptedNames: - kind: "" - plural: "" - conditions: null - storedVersions: null diff --git a/hack/manage-argocd-crds.sh b/hack/manage-argocd-crds.sh new file mode 100755 index 000000000..5edb35314 --- /dev/null +++ b/hack/manage-argocd-crds.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Pre-requisites +# go +# awk +# bash +# wget + +set -e + +ARGOCD_VERSION=$(go list -mod=readonly -m github.com/argoproj/argo-cd/v2 | awk '{print $2}') +ARGOCD_CRD_FILES="application-crd.yaml applicationset-crd.yaml appproject-crd.yaml" + +check_for_sem_ver() { + if [[ $ARGOCD_VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9])?$ ]]; then + echo "argo-cd version from go.mod: $ARGOCD_VERSION" + return + else + echo "[WARN] argo-cd module version from go.mod does not match the semver pattern." + exit 1 + fi +} + +download_manifests() { + for argocd_crd_file in $ARGOCD_CRD_FILES;do + output_file=argoproj.io_$(echo "${argocd_crd_file}" | sed -e s/-crd.yaml/s.yaml/g) + wget -q "https://raw.githubusercontent.com/argoproj/argo-cd/refs/tags/${ARGOCD_VERSION}/manifests/crds/${argocd_crd_file}" -O bundle/manifests/${output_file} + done +} + +check_for_local_changes() { + local_modified_files=$(git status --porcelain) + if [[ ! -z "${local_modified_files}" && "${local_modified_files}}" =~ "bundle/manifests/argoproj.io_app" ]]; then + echo "[WARN] There are unexpected local changes to the argo-cd CRD manifests." + echo "${local_modified_files}" + echo "Please update the CRDs from the argo-cd repository, ensure that there are no diffs and re-submit" + exit 1 + else + echo "No local changes to argo-cd CRD manifests" + return + fi +} + +LINT="false" +if [[ $# > 0 ]]; then + if [[ $1 == "lint" ]];then + LINT="true" + else + echo "Invalid option $1" + exit 0 + fi +fi + +check_for_sem_ver +download_manifests +if [[ "${LINT}" == "true" ]]; then + check_for_local_changes +fi