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 2021/07/07 17:18:55 UTC

[solr-operator] branch main updated: Fix issues with linting. Better solution for testing changes. (#280)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 75756eb  Fix issues with linting. Better solution for testing changes. (#280)
75756eb is described below

commit 75756eb7a422871e470f721c5d3ca253da5c4955
Author: Houston Putman <ho...@apache.org>
AuthorDate: Wed Jul 7 13:18:49 2021 -0400

    Fix issues with linting. Better solution for testing changes. (#280)
---
 Makefile                                    | 22 +++++++++------------
 api/v1beta1/solrbackup_types.go             | 20 +++++++++----------
 api/v1beta1/solrcloud_types.go              | 30 ++++++++++++++---------------
 api/v1beta1/solrprometheusexporter_types.go | 18 ++++++++---------
 hack/config/add_crds_roles_headers.sh       |  4 ++--
 hack/config/copy_crds_roles_helm.sh         | 16 ++++++++-------
 6 files changed, 54 insertions(+), 56 deletions(-)

diff --git a/Makefile b/Makefile
index acd5f35..d306a8b 100644
--- a/Makefile
+++ b/Makefile
@@ -98,14 +98,13 @@ deploy: manifests install
 
 # Generate code
 generate:
-	controller-gen object:headerFile=./hack/headers/header.go.txt paths="./..."
+	controller-gen object:headerFile=./hack/headers/header.go.txt paths=$(or $(TMP_API_DIRECTORY),"./...")
 
 # Generate manifests e.g. CRD, RBAC etc.
 manifests:
-	rm -r config/crd/bases
-	controller-gen $(CRD_OPTIONS) rbac:roleName=solr-operator-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
-	./hack/config/copy_crds_roles_helm.sh
-	./hack/config/add_crds_roles_headers.sh
+	controller-gen $(CRD_OPTIONS) rbac:roleName=solr-operator-role webhook paths="./..." 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) 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
 
 # Run go fmt against code
 fmt:
@@ -139,11 +138,9 @@ check-licenses:
 check-manifests:
 	rm -rf generated-check
 	mkdir -p generated-check
-	mv config generated-check/existing-config; cp -r generated-check/existing-config config
-	mv helm generated-check/existing-helm; cp -r generated-check/existing-helm helm
-	make manifests
-	mv config generated-check/config; mv generated-check/existing-config config
-	mv helm generated-check/helm; mv generated-check/existing-helm helm
+	cp -r helm generated-check/helm
+	cp -r config generated-check/config
+	TMP_CONFIG_OUTPUT_DIRECTORY=generated-check/config TMP_HELM_OUTPUT_DIRECTORY=generated-check/helm make manifests
 	@echo "Check to make sure the manifests are up to date"
 	diff --recursive config generated-check/config
 	diff --recursive helm generated-check/helm
@@ -151,9 +148,8 @@ check-manifests:
 check-generated:
 	rm -rf generated-check
 	mkdir -p generated-check
-	cp -r api generated-check/existing-api
-	make generate
-	mv api generated-check/api; mv generated-check/existing-api api
+	cp -r api generated-check/api
+	TMP_API_DIRECTORY="./generated-check/api/..." make generate
 	@echo "Check to make sure the generated code is up to date"
 	diff --recursive api generated-check/api
 
diff --git a/api/v1beta1/solrbackup_types.go b/api/v1beta1/solrbackup_types.go
index e2aad5b..66ecde0 100644
--- a/api/v1beta1/solrbackup_types.go
+++ b/api/v1beta1/solrbackup_types.go
@@ -281,17 +281,17 @@ func (sb *SolrBackup) PersistenceJobName() string {
 	return fmt.Sprintf("%s-solr-backup-persistence", sb.GetName())
 }
 
-// +kubebuilder:object:root=true
-// +kubebuilder:resource:scope=Namespaced
+//+kubebuilder:object:root=true
+//+kubebuilder:resource:scope=Namespaced
+//+kubebuilder:storageversion
+//+kubebuilder:categories=all
+//+kubebuilder:subresource:status
+//+kubebuilder:printcolumn:name="Cloud",type="string",JSONPath=".spec.solrCloud",description="Solr Cloud"
+//+kubebuilder:printcolumn:name="Finished",type="boolean",JSONPath=".status.finished",description="Whether the backup has finished"
+//+kubebuilder:printcolumn:name="Successful",type="boolean",JSONPath=".status.successful",description="Whether the backup was successful"
+//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
 
 // SolrBackup is the Schema for the solrbackups API
-// +kubebuilder:categories=all
-// +kubebuilder:subresource:status
-// +kubebuilder:storageversion
-// +kubebuilder:printcolumn:name="Cloud",type="string",JSONPath=".spec.solrCloud",description="Solr Cloud"
-// +kubebuilder:printcolumn:name="Finished",type="boolean",JSONPath=".status.finished",description="Whether the backup has finished"
-// +kubebuilder:printcolumn:name="Successful",type="boolean",JSONPath=".status.successful",description="Whether the backup was successful"
-// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
 type SolrBackup struct {
 	metav1.TypeMeta   `json:",inline"`
 	metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -305,7 +305,7 @@ func (sb *SolrBackup) WithDefaults() bool {
 	return sb.Spec.withDefaults(sb.Name)
 }
 
-// +kubebuilder:object:root=true
+//+kubebuilder:object:root=true
 
 // SolrBackupList contains a list of SolrBackup
 type SolrBackupList struct {
diff --git a/api/v1beta1/solrcloud_types.go b/api/v1beta1/solrcloud_types.go
index 34555d6..e60839c 100644
--- a/api/v1beta1/solrcloud_types.go
+++ b/api/v1beta1/solrcloud_types.go
@@ -745,22 +745,22 @@ type SolrNodeStatus struct {
 	SpecUpToDate bool `json:"specUpToDate"`
 }
 
-// +kubebuilder:object:root=true
-// +kubebuilder:resource:scope=Namespaced
+//+kubebuilder:object:root=true
+//+kubebuilder:resource:scope=Namespaced
+//+kubebuilder:resource:shortName=solr
+//+kubebuilder:categories=all
+//+kubebuilder:subresource:status
+//+kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.readyReplicas,selectorpath=.status.podSelector
+//+kubebuilder:storageversion
+//+kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.version",description="Solr Version of the cloud"
+//+kubebuilder:printcolumn:name="TargetVersion",type="string",JSONPath=".status.targetVersion",description="Target Solr Version of the cloud"
+//+kubebuilder:printcolumn:name="DesiredNodes",type="integer",JSONPath=".spec.replicas",description="Number of solr nodes configured to run in the cloud"
+//+kubebuilder:printcolumn:name="Nodes",type="integer",JSONPath=".status.replicas",description="Number of solr nodes running"
+//+kubebuilder:printcolumn:name="ReadyNodes",type="integer",JSONPath=".status.readyReplicas",description="Number of solr nodes connected to the cloud"
+//+kubebuilder:printcolumn:name="UpToDateNodes",type="integer",JSONPath=".status.upToDateNodes",description="Number of solr nodes running the latest SolrCloud pod spec"
+//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
 
 // SolrCloud is the Schema for the solrclouds API
-// +kubebuilder:resource:shortName=solr
-// +kubebuilder:categories=all
-// +kubebuilder:subresource:status
-// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.readyReplicas,selectorpath=.status.podSelector
-// +kubebuilder:storageversion
-// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.version",description="Solr Version of the cloud"
-// +kubebuilder:printcolumn:name="TargetVersion",type="string",JSONPath=".status.targetVersion",description="Target Solr Version of the cloud"
-// +kubebuilder:printcolumn:name="DesiredNodes",type="integer",JSONPath=".spec.replicas",description="Number of solr nodes configured to run in the cloud"
-// +kubebuilder:printcolumn:name="Nodes",type="integer",JSONPath=".status.replicas",description="Number of solr nodes running"
-// +kubebuilder:printcolumn:name="ReadyNodes",type="integer",JSONPath=".status.readyReplicas",description="Number of solr nodes connected to the cloud"
-// +kubebuilder:printcolumn:name="UpToDateNodes",type="integer",JSONPath=".status.upToDateNodes",description="Number of solr nodes running the latest SolrCloud pod spec"
-// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
 type SolrCloud struct {
 	metav1.TypeMeta   `json:",inline"`
 	metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -1029,7 +1029,7 @@ func (sc *SolrCloud) SharedLabelsWith(labels map[string]string) map[string]strin
 	return newLabels
 }
 
-// +kubebuilder:object:root=true
+//+kubebuilder:object:root=true
 
 // SolrCloudList contains a list of SolrCloud
 type SolrCloudList struct {
diff --git a/api/v1beta1/solrprometheusexporter_types.go b/api/v1beta1/solrprometheusexporter_types.go
index 9f99396..6decc90 100644
--- a/api/v1beta1/solrprometheusexporter_types.go
+++ b/api/v1beta1/solrprometheusexporter_types.go
@@ -174,16 +174,16 @@ type SolrPrometheusExporterStatus struct {
 	Ready bool `json:"ready"`
 }
 
-// +kubebuilder:object:root=true
-// +kubebuilder:resource:scope=Namespaced
+//+kubebuilder:object:root=true
+//+kubebuilder:resource:scope=Namespaced
+//+kubebuilder:resource:shortName=solrmetrics
+//+kubebuilder:subresource:status
+//+kubebuilder:storageversion
+//+kubebuilder:printcolumn:name="Ready",type="boolean",JSONPath=".status.ready",description="Whether the prometheus exporter is ready"
+//+kubebuilder:printcolumn:name="Scrape Interval",type="integer",JSONPath=".spec.scrapeInterval",description="Scrape interval for metrics (in ms)"
+//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
 
 // SolrPrometheusExporter is the Schema for the solrprometheusexporters API
-// +kubebuilder:resource:shortName=solrmetrics
-// +kubebuilder:subresource:status
-// +kubebuilder:storageversion
-// +kubebuilder:printcolumn:name="Ready",type="boolean",JSONPath=".status.ready",description="Whether the prometheus exporter is ready"
-// +kubebuilder:printcolumn:name="Scrape Interval",type="integer",JSONPath=".spec.scrapeInterval",description="Scrape interval for metrics (in ms)"
-// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
 type SolrPrometheusExporter struct {
 	metav1.TypeMeta   `json:",inline"`
 	metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -237,7 +237,7 @@ func (sc *SolrPrometheusExporter) MetricsIngressUrl(ingressBaseUrl string) strin
 	return fmt.Sprintf("%s.%s", sc.MetricsIngressPrefix(), ingressBaseUrl)
 }
 
-// +kubebuilder:object:root=true
+//+kubebuilder:object:root=true
 
 // SolrPrometheusExporterList contains a list of SolrPrometheusExporter
 type SolrPrometheusExporterList struct {
diff --git a/hack/config/add_crds_roles_headers.sh b/hack/config/add_crds_roles_headers.sh
index 1c3b110..13f31e9 100755
--- a/hack/config/add_crds_roles_headers.sh
+++ b/hack/config/add_crds_roles_headers.sh
@@ -21,9 +21,9 @@ set -o pipefail
 # error on unset variables
 set -u
 
-echo "Copying CRDs and Role to helm repo"
+echo "Add headers to CRDs and Role files"
 
-files=(config/crd/bases/* config/rbac/role.yaml)
+files=("${CONFIG_DIRECTORY:-config}"/crd/bases/* "${CONFIG_DIRECTORY:-config}"/rbac/role.yaml)
 
 # Copy and package CRDs
 for file in "${files[@]}"; do
diff --git a/hack/config/copy_crds_roles_helm.sh b/hack/config/copy_crds_roles_helm.sh
index c3eac01..02d26f1 100755
--- a/hack/config/copy_crds_roles_helm.sh
+++ b/hack/config/copy_crds_roles_helm.sh
@@ -23,24 +23,26 @@ set -u
 
 echo "Copying CRDs and Role to helm repo"
 
+CONFIG_DIRECTORY="${CONFIG_DIRECTORY:-config}"
+HELM_DIRECTORY="${HELM_DIRECTORY:-helm}"
+
 # Copy and package CRDs
 {
   cat hack/headers/header.yaml.txt
   printf "\n"
-  cat config/crd/bases/solr.apache.org_solrbackups.yaml
-  cat config/crd/bases/solr.apache.org_solrclouds.yaml
-  cat config/crd/bases/solr.apache.org_solrprometheusexporters.yaml
-
-} > helm/solr-operator/crds/crds.yaml
+  cat "${CONFIG_DIRECTORY}/crd/bases/solr.apache.org_solrbackups.yaml"
+  cat "${CONFIG_DIRECTORY}/crd/bases/solr.apache.org_solrclouds.yaml"
+  cat "${CONFIG_DIRECTORY}/crd/bases/solr.apache.org_solrprometheusexporters.yaml"
+} > "${HELM_DIRECTORY}/solr-operator/crds/crds.yaml"
 
 # Copy Kube Role for Solr Operator permissions to Helm
 # Template the Solr Operator role as needed for Helm values
 {
   cat hack/headers/header.yaml.txt
   printf '\n\n{{- if .Values.rbac.create }}\n{{- range $namespace := (split "," (include "solr-operator.watchNamespaces" $)) }}\n'
-  cat config/rbac/role.yaml \
+  cat "${CONFIG_DIRECTORY}/rbac/role.yaml" \
     | awk '/^rules:$/{print "  namespace: {{ $namespace }}"}1' \
     | sed -E 's/^kind: ClusterRole$/kind: {{ include "solr-operator\.roleType" \$ }}/' \
     | sed -E 's/name: solr-operator-role$/name: {{ include "solr-operator\.fullname" \$ }}-role/'
   printf '\n{{- end }}\n{{- end }}\n'
-} > helm/solr-operator/templates/role.yaml
+} > "${HELM_DIRECTORY}/solr-operator/templates/role.yaml"