Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added linter for checking if latest changes to Argo CD are already available in the PR #1587

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/lint-argocd-crd.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)/
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ kind: Service
metadata:
creationTimestamp: null
labels:
control-plane: controller-manager
control-plane: argocd-operator
name: argocd-operator-controller-manager-metrics-service
spec:
ports:
- name: https
port: 8443
targetPort: 8080
selector:
control-plane: controller-manager
control-plane: argocd-operator
status:
loadBalancer: {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ spec:
protocol: TCP
targetPort: 9443
selector:
control-plane: controller-manager
control-plane: argocd-operator
status:
loadBalancer: {}
8 changes: 4 additions & 4 deletions bundle/manifests/argocd-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 0 additions & 7 deletions bundle/manifests/argoproj.io_applications.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -4998,9 +4997,3 @@ spec:
served: true
storage: true
subresources: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: null
storedVersions: null
7 changes: 0 additions & 7 deletions bundle/manifests/argoproj.io_applicationsets.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -15378,9 +15377,3 @@ spec:
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: null
storedVersions: null
7 changes: 0 additions & 7 deletions bundle/manifests/argoproj.io_appprojects.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -329,9 +328,3 @@ spec:
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: null
storedVersions: null
58 changes: 58 additions & 0 deletions hack/manage-argocd-crds.sh
Original file line number Diff line number Diff line change
@@ -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
Loading