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

chore: stop generating crd v1beta1 #1325

Merged
merged 1 commit into from
Feb 21, 2022
Merged
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
13 changes: 4 additions & 9 deletions .github/bin/check-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,12 @@ checkCRDs() {
local checlusterbackup_CRD_V1="config/crd/bases/org.eclipse.che_checlusterbackups_crd.yaml"
local checlusterrestore_CRD_V1="config/crd/bases/org.eclipse.che_checlusterrestores_crd.yaml"

local checluster_CRD_V1BETA1="config/crd/bases/org_v1_che_crd-v1beta1.yaml"
local chebackupserverconfiguration_CRD_V1BETA1="config/crd/bases/org.eclipse.che_chebackupserverconfigurations_crd-v1beta1.yaml"
local checlusterbackup_CRD_V1BETA1="config/crd/bases/org.eclipse.che_checlusterbackups_crd-v1beta1.yaml"
local checlusterrestore_CRD_V1BETA1="config/crd/bases/org.eclipse.che_checlusterrestores_crd-v1beta1.yaml"

changedFiles=($(cd ${ROOT_PROJECT_DIR}; git diff --name-only))
# Check if there are any difference in the crds. If yes, then fail check.
if [[ " ${changedFiles[*]} " =~ $checluster_CRD_V1 ]] || [[ " ${changedFiles[*]} " =~ $checluster_CRD_V1BETA1 ]] || \
[[ " ${changedFiles[*]} " =~ $chebackupserverconfiguration_CRD_V1 ]] || [[ " ${changedFiles[*]} " =~ $chebackupserverconfiguration_CRD_V1BETA1 ]] || \
[[ " ${changedFiles[*]} " =~ $checlusterbackup_CRD_V1 ]] || [[ " ${changedFiles[*]} " =~ $checlusterbackup_CRD_V1BETA1 ]] || \
[[ " ${changedFiles[*]} " =~ $checlusterrestore_CRD_V1 ]] || [[ " ${changedFiles[*]} " =~ $checlusterrestore_CRD_V1BETA1 ]]
if [[ " ${changedFiles[*]} " =~ $checluster_CRD_V1 ]] || \
[[ " ${changedFiles[*]} " =~ $chebackupserverconfiguration_CRD_V1 ]] || \
[[ " ${changedFiles[*]} " =~ $checlusterbackup_CRD_V1 ]] || \
[[ " ${changedFiles[*]} " =~ $checlusterrestore_CRD_V1 ]]
then
echo "[ERROR] CRD file is not up to date: ${BASH_REMATCH}"
echo "[ERROR] Run 'make update-resources -s' to regenerate CRD files."
Expand Down
48 changes: 0 additions & 48 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
IMG ?= quay.io/eclipse/che-operator:next
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
CRD_BETA_OPTIONS ?= "crd:trivialVersions=true,crdVersions=v1beta1"

OPERATOR_YAML="config/manager/manager.yaml"

Expand All @@ -54,9 +53,6 @@ CRD_FOLDER="config/crd/bases"

ECLIPSE_CHE_CR=config/samples/org.eclipse.che_v1_checluster.yaml

# legacy crd v1beta1 file names
ECLIPSE_CHE_CRD_V1BETA1="$(CRD_FOLDER)/org_v1_che_crd-v1beta1.yaml"

# legacy crd file names
ECLIPSE_CHE_CRD_V1="$(CRD_FOLDER)/org_v1_che_crd.yaml"

Expand Down Expand Up @@ -126,58 +122,18 @@ download-operator-sdk:
chmod +x $${OP_SDK_PATH}
echo "[INFO] operator-sdk is ready."

removeRequiredAttribute: SHELL := /bin/bash
removeRequiredAttribute:
REQUIRED=false

while IFS= read -r line
do
if [[ $$REQUIRED == true ]]; then
if [[ $$line == *"- "* ]]; then
continue
else
REQUIRED=false
fi
fi

if [[ $$line == *"required:"* ]]; then
REQUIRED=true
continue
fi

echo "$$line" >> $$filePath.tmp
done < "$$filePath"

mv $${filePath}.tmp $${filePath}

manifests: controller-gen add-license-download ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
# Generate CRDs v1beta1
$(CONTROLLER_GEN) $(CRD_BETA_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
mv "$(ECLIPSE_CHE_CRD)" "$(ECLIPSE_CHE_CRD_V1BETA1)"

# Generate CRDs v1
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
mv "$(ECLIPSE_CHE_CRD)" "$(ECLIPSE_CHE_CRD_V1)"

# remove yaml delimitier, which makes OLM catalog source image broken.
sed -i.bak '/---/d' "$(ECLIPSE_CHE_CRD_V1BETA1)"
rm -rf "$(ECLIPSE_CHE_CRD_V1BETA1).bak"
sed -i.bak '/---/d' "$(ECLIPSE_CHE_CRD_V1)"
rm -rf "$(ECLIPSE_CHE_CRD_V1).bak"

# remove v1alphav2 version from crd files
yq -rYi "del(.spec.versions[1])" "$(ECLIPSE_CHE_CRD_V1BETA1)"
yq -rYi "del(.spec.versions[1])" "$(ECLIPSE_CHE_CRD_V1)"

# remove .spec.subresources.status from crd v1beta1 files
yq -rYi ".spec.subresources.status = {}" "$(ECLIPSE_CHE_CRD_V1BETA1)"

# remove .spec.validation.openAPIV3Schema.type field
yq -rYi "del(.spec.validation.openAPIV3Schema.type)" "$(ECLIPSE_CHE_CRD_V1BETA1)"

# remove "required" attributes from v1beta1 crd files
$(MAKE) removeRequiredAttribute "filePath=$(ECLIPSE_CHE_CRD_V1BETA1)"

$(MAKE) add-license $$(find ./config/crd -not -path "./vendor/*" -name "*.yaml")

generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand Down Expand Up @@ -311,10 +267,6 @@ init-cr:
kubectl apply -f ${ECLIPSE_CHE_CR} -n ${ECLIPSE_CHE_NAMESPACE}
fi

apply-cr-crd-beta:
kubectl apply -f ${ECLIPSE_CHE_CRD_V1BETA1}
kubectl apply -f ${ECLIPSE_CHE_CR} -n ${ECLIPSE_CHE_NAMESPACE}

create-env-file: prepare-templates
rm -rf "${ENV_FILE}"
touch "${ENV_FILE}"
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ $ make generate; make manifests
This command will update CRD files:
- `config/crd/bases/org_v1_che_crd.yaml`
- `config/crd/bases/org_v1_che_crd-v1beta1.yaml`
CRD beta yamls should be used for back compatibility with Openshift 3.
Expand Down
5 changes: 1 addition & 4 deletions api/v1/checluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ package v1
// Important: You must regenerate some generated code after modifying this file. At the root of the project:
// Run `make generate`. It will perform required changes:
// - update `api/v1/zz_generatedxxx` files;
// - update `config/crd/bases/org_v1_checluster_crd.yaml` and `config/crd/bases/org_v1_che_crd-v1beta1.yaml` files;
// - In the updated `config/crd/bases/org_v1_checluster_crd.yaml`: Delete all the `required:` openAPI rules in the CRD OpenApi schema;
// - Rename the new `config/crd/bases/org_v1_checluster_crd.yaml` to `config/crd/bases/org_v1_che_crd.yaml` to override it.
// IMPORTANT These 2 last steps are important to ensure backward compatibility with already existing `CheCluster` CRs that were created when no schema was provided.
// - update `config/crd/bases/org_v1_checluster_crd.yaml` file;

import (
chev1alpha1 "github.com/che-incubator/kubernetes-image-puller-operator/api/v1alpha1"
Expand Down
Loading