You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ho...@apache.org on 2022/03/08 21:47:08 UTC

[solr-operator] branch release-0.5 updated: Add operator version & ArgoCD annotations to CRDs (#411)

This is an automated email from the ASF dual-hosted git repository.

houston pushed a commit to branch release-0.5
in repository https://gitbox.apache.org/repos/asf/solr-operator.git


The following commit(s) were added to refs/heads/release-0.5 by this push:
     new 742d459  Add operator version & ArgoCD annotations to CRDs (#411)
742d459 is described below

commit 742d4599cf794f00b06d67f87f11a41538d1e058
Author: Jan Høydahl <ja...@users.noreply.github.com>
AuthorDate: Tue Mar 8 22:37:43 2022 +0100

    Add operator version & ArgoCD annotations to CRDs (#411)
    
    Fixes #410
    
    Co-authored-by: Houston Putman <ho...@apache.org>
---
 Makefile                                                     |  1 +
 config/crd/bases/solr.apache.org_solrbackups.yaml            |  2 ++
 config/crd/bases/solr.apache.org_solrclouds.yaml             |  2 ++
 .../crd/bases/solr.apache.org_solrprometheusexporters.yaml   |  2 ++
 config/dependencies/zookeeper_cluster_crd.yaml               |  3 +++
 .../{add_crds_roles_headers.sh => add_crds_annotations.sh}   | 12 +++++++-----
 hack/config/add_crds_roles_headers.sh                        |  2 ++
 hack/release/artifacts/create_crds.sh                        |  7 ++-----
 hack/release/version/propagate_version.sh                    |  2 ++
 hack/release/wizard/scriptutil.py                            |  4 ++--
 hack/zk-operator/update-crd.sh                               |  8 ++++++--
 helm/solr-operator/crds/crds.yaml                            |  6 ++++++
 12 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index 376574b..856250a 100644
--- a/Makefile
+++ b/Makefile
@@ -95,6 +95,7 @@ prepare: fmt generate manifests fetch-licenses-list mod-tidy ## Prepare the code
 manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects
 	rm -rf generated-check/api
 	$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=solr-operator-role webhook paths="./api/..." paths="./controllers/." output:rbac:artifacts:config=$(or $(TMP_CONFIG_OUTPUT_DIRECTORY),config)/rbac output:crd:artifacts:config=$(or $(TMP_CONFIG_OUTPUT_DIRECTORY),config)/crd/bases
+	CONFIG_DIRECTORY=$(or $(TMP_CONFIG_OUTPUT_DIRECTORY),config) VERSION=$(VERSION) ./hack/config/add_crds_annotations.sh
 	CONFIG_DIRECTORY=$(or $(TMP_CONFIG_OUTPUT_DIRECTORY),config) HELM_DIRECTORY=$(or $(TMP_HELM_OUTPUT_DIRECTORY),helm) ./hack/config/copy_crds_roles_helm.sh
 	CONFIG_DIRECTORY=$(or $(TMP_CONFIG_OUTPUT_DIRECTORY),config) ./hack/config/add_crds_roles_headers.sh
 
diff --git a/config/crd/bases/solr.apache.org_solrbackups.yaml b/config/crd/bases/solr.apache.org_solrbackups.yaml
index 0032d4c..5fdb2ad 100644
--- a/config/crd/bases/solr.apache.org_solrbackups.yaml
+++ b/config/crd/bases/solr.apache.org_solrbackups.yaml
@@ -19,6 +19,8 @@ kind: CustomResourceDefinition
 metadata:
   annotations:
     controller-gen.kubebuilder.io/version: v0.5.0
+    operator.solr.apache.org/version: v0.5.1-prerelease
+    argocd.argoproj.io/sync-options: Replace=true
   creationTimestamp: null
   name: solrbackups.solr.apache.org
 spec:
diff --git a/config/crd/bases/solr.apache.org_solrclouds.yaml b/config/crd/bases/solr.apache.org_solrclouds.yaml
index 9628d5c..2f830d0 100644
--- a/config/crd/bases/solr.apache.org_solrclouds.yaml
+++ b/config/crd/bases/solr.apache.org_solrclouds.yaml
@@ -19,6 +19,8 @@ kind: CustomResourceDefinition
 metadata:
   annotations:
     controller-gen.kubebuilder.io/version: v0.5.0
+    operator.solr.apache.org/version: v0.5.1-prerelease
+    argocd.argoproj.io/sync-options: Replace=true
   creationTimestamp: null
   name: solrclouds.solr.apache.org
 spec:
diff --git a/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml b/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml
index 8e5b6d4..62fc87e 100644
--- a/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml
+++ b/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml
@@ -19,6 +19,8 @@ kind: CustomResourceDefinition
 metadata:
   annotations:
     controller-gen.kubebuilder.io/version: v0.5.0
+    operator.solr.apache.org/version: v0.5.1-prerelease
+    argocd.argoproj.io/sync-options: Replace=true
   creationTimestamp: null
   name: solrprometheusexporters.solr.apache.org
 spec:
diff --git a/config/dependencies/zookeeper_cluster_crd.yaml b/config/dependencies/zookeeper_cluster_crd.yaml
index aa3d8b3..1ca7fa4 100644
--- a/config/dependencies/zookeeper_cluster_crd.yaml
+++ b/config/dependencies/zookeeper_cluster_crd.yaml
@@ -13,6 +13,9 @@ apiVersion: apiextensions.k8s.io/v1
 kind: CustomResourceDefinition
 metadata:
   name: zookeeperclusters.zookeeper.pravega.io
+  annotations:
+    operator.zookeeper.pravega.io/version: v0.2.12
+    argocd.argoproj.io/sync-options: Replace=true
 spec:
   group: zookeeper.pravega.io
   names:
diff --git a/hack/config/add_crds_roles_headers.sh b/hack/config/add_crds_annotations.sh
similarity index 77%
copy from hack/config/add_crds_roles_headers.sh
copy to hack/config/add_crds_annotations.sh
index 13f31e9..18d3431 100755
--- a/hack/config/add_crds_roles_headers.sh
+++ b/hack/config/add_crds_annotations.sh
@@ -21,15 +21,17 @@ set -o pipefail
 # error on unset variables
 set -u
 
-echo "Add headers to CRDs and Role files"
+echo "Add annotations to CRDs"
 
-files=("${CONFIG_DIRECTORY:-config}"/crd/bases/* "${CONFIG_DIRECTORY:-config}"/rbac/role.yaml)
+rm -f "${CONFIG_DIRECTORY:-config}"/crd/bases/*.tmp
+
+files=("${CONFIG_DIRECTORY:-config}"/crd/bases/*)
 
 # Copy and package CRDs
 for file in "${files[@]}"; do
   {
-    cat hack/headers/header.yaml.txt
-    printf "\n"
-    cat "${file}"
+    cat "${file}" | sed -e "/^    controller-gen.kubebuilder.io.version.*/a \\
+    operator.solr.apache.org\\/version: ${VERSION}\\
+    argocd.argoproj.io\\/sync-options: Replace=true"
   } > "${file}.tmp" && mv "${file}.tmp" "${file}"
 done
diff --git a/hack/config/add_crds_roles_headers.sh b/hack/config/add_crds_roles_headers.sh
index 13f31e9..080ea37 100755
--- a/hack/config/add_crds_roles_headers.sh
+++ b/hack/config/add_crds_roles_headers.sh
@@ -23,6 +23,8 @@ set -u
 
 echo "Add headers to CRDs and Role files"
 
+rm -f "${CONFIG_DIRECTORY:-config}"/crd/bases/*.tmp "${CONFIG_DIRECTORY:-config}"/rbac/role.yaml.tmp
+
 files=("${CONFIG_DIRECTORY:-config}"/crd/bases/* "${CONFIG_DIRECTORY:-config}"/rbac/role.yaml)
 
 # Copy and package CRDs
diff --git a/hack/release/artifacts/create_crds.sh b/hack/release/artifacts/create_crds.sh
index 6a1a77b..894dba3 100755
--- a/hack/release/artifacts/create_crds.sh
+++ b/hack/release/artifacts/create_crds.sh
@@ -85,11 +85,8 @@ for filename in config/crd/bases/*.yaml; do
 done
 
 # Fetch the correct dependency Zookeeper CRD, package with other CRDS
-{
-  cat hack/headers/zookeeper-operator-header.yaml.txt;
-  printf "\n\n---\n"
-  curl -sL "https://raw.githubusercontent.com/pravega/zookeeper-operator/v0.2.12/deploy/crds/zookeeper.pravega.io_zookeeperclusters_crd.yaml"
-} > "${ARTIFACTS_DIR}/crds/zookeeperclusters.yaml"
+./hack/zk-operator/update-crd.sh
+cp "config/dependencies/zookeeper_cluster_crd.yaml" "${ARTIFACTS_DIR}/crds/zookeeperclusters.yaml"
 
 # Package all Solr and Dependency CRDs
 {
diff --git a/hack/release/version/propagate_version.sh b/hack/release/version/propagate_version.sh
index 7697f63..32aaa67 100755
--- a/hack/release/version/propagate_version.sh
+++ b/hack/release/version/propagate_version.sh
@@ -114,3 +114,5 @@ fi
   sed -E "s|(kubectl.+/crds/)[^/<]+|\1${VERSION}|g" | \
   sed -E "s|(helm.+--version )[^ <]+|\1${VERSION#v}|g"
 } > docs/running-the-operator.md.tmp && mv docs/running-the-operator.md.tmp docs/running-the-operator.md
+
+make manifests
diff --git a/hack/release/wizard/scriptutil.py b/hack/release/wizard/scriptutil.py
index ac39d13..c453dab 100644
--- a/hack/release/wizard/scriptutil.py
+++ b/hack/release/wizard/scriptutil.py
@@ -130,9 +130,9 @@ def find_branch_type():
 
   if branchName == b'main':
     return BranchType.unstable
-  if re.match(r'release-(\d+)', branchName.decode('UTF-8')):
+  if re.match(r'^release-(\d+)$', branchName.decode('UTF-8')):
     return BranchType.stable
-  if re.match(r'release-(\d+)\.(\d+)', branchName.decode('UTF-8')):
+  if re.match(r'^release-(\d+)\.(\d+)$', branchName.decode('UTF-8')):
     return BranchType.release
   raise Exception('Cannot run %s on feature branch' % sys.argv[0].rsplit('/', 1)[-1])
 
diff --git a/hack/zk-operator/update-crd.sh b/hack/zk-operator/update-crd.sh
index cd3f194..cbe955a 100755
--- a/hack/zk-operator/update-crd.sh
+++ b/hack/zk-operator/update-crd.sh
@@ -27,5 +27,9 @@ ZK_OP_VERSION="$(cat versions.props | grep -E 'zookeeper-operator' | grep -o 'v[
 {
   cat hack/headers/zookeeper-operator-header.yaml.txt;
   printf "\n\n---\n"
-  curl -sL "https://raw.githubusercontent.com/pravega/zookeeper-operator/${ZK_OP_VERSION}/deploy/crds/zookeeper.pravega.io_zookeeperclusters_crd.yaml"
-} > config/dependencies/zookeeper_cluster_crd.yaml
\ No newline at end of file
+  curl -sL "https://raw.githubusercontent.com/pravega/zookeeper-operator/${ZK_OP_VERSION}/deploy/crds/zookeeper.pravega.io_zookeeperclusters_crd.yaml" \
+    | sed -e "/^  name: zookeeperclusters.zookeeper.pravega.io$/a \\
+  annotations:\\
+    operator.zookeeper.pravega.io\\/version: ${ZK_OP_VERSION}\\
+    argocd.argoproj.io\\/sync-options: Replace=true"
+} > config/dependencies/zookeeper_cluster_crd.yaml
diff --git a/helm/solr-operator/crds/crds.yaml b/helm/solr-operator/crds/crds.yaml
index c9ad81f..2868e65 100644
--- a/helm/solr-operator/crds/crds.yaml
+++ b/helm/solr-operator/crds/crds.yaml
@@ -19,6 +19,8 @@ kind: CustomResourceDefinition
 metadata:
   annotations:
     controller-gen.kubebuilder.io/version: v0.5.0
+    operator.solr.apache.org/version: v0.5.1-prerelease
+    argocd.argoproj.io/sync-options: Replace=true
   creationTimestamp: null
   name: solrbackups.solr.apache.org
 spec:
@@ -1272,6 +1274,8 @@ kind: CustomResourceDefinition
 metadata:
   annotations:
     controller-gen.kubebuilder.io/version: v0.5.0
+    operator.solr.apache.org/version: v0.5.1-prerelease
+    argocd.argoproj.io/sync-options: Replace=true
   creationTimestamp: null
   name: solrclouds.solr.apache.org
 spec:
@@ -8333,6 +8337,8 @@ kind: CustomResourceDefinition
 metadata:
   annotations:
     controller-gen.kubebuilder.io/version: v0.5.0
+    operator.solr.apache.org/version: v0.5.1-prerelease
+    argocd.argoproj.io/sync-options: Replace=true
   creationTimestamp: null
   name: solrprometheusexporters.solr.apache.org
 spec: