Skip to content

Commit

Permalink
Remove v1beta1 CRD
Browse files Browse the repository at this point in the history
Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
  • Loading branch information
dhaiducek committed Nov 1, 2024
1 parent c083e42 commit b53dc21
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 658 deletions.
33 changes: 2 additions & 31 deletions build/crd-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ for REPO in config-policy-controller governance-policy-propagator; do
git clone -b main --depth 1 https://github.com/open-cluster-management-io/${REPO}.git .go/${REPO}
done

generate_v1beta1() {
CRD_PATH=${1}
yq '.apiVersion += "beta1"' -i "${CRD_PATH}"
yq '.spec.version = "v1"' -i "${CRD_PATH}"
yq '.spec.additionalPrinterColumns = .spec.versions[].additionalPrinterColumns' -i "${CRD_PATH}"
yq '.spec.additionalPrinterColumns[] |= .JSONPath = .jsonPath' -i "${CRD_PATH}"
yq 'del(.spec.additionalPrinterColumns[].jsonPath)' -i "${CRD_PATH}"
yq '.spec.validation = .spec.versions[].schema' -i "${CRD_PATH}"
yq '.spec.subresources.status = {}' -i "${CRD_PATH}"
yq '.spec.versions = [{"name": "v1", "served": true, "storage": true}]' -i "${CRD_PATH}"
yq 'del(.. | select(has("default")).default)' -i "${CRD_PATH}"
yq 'del(.. | select(has("oneOf")).oneOf)' -i "${CRD_PATH}"
yq 'sort_keys(..)' -i "${CRD_PATH}"
}

format_descriptions() {
crd_path=${1}

Expand All @@ -52,9 +37,7 @@ format_descriptions() {
# ConfigurationPolicy CRD
format_descriptions deploy/crds/policy.open-cluster-management.io_configurationpolicies.yaml
cp deploy/crds/policy.open-cluster-management.io_configurationpolicies.yaml ../config-policy-crd-v1.yaml
cp deploy/crds/policy.open-cluster-management.io_configurationpolicies.yaml ../config-policy-crd-v1beta1.yaml
generate_v1beta1 ../config-policy-crd-v1beta1.yaml
# OperatorPolicy CRD (v1beta1 not required since it's not supported on earlier K8s)
# OperatorPolicy CRD
format_descriptions deploy/crds/policy.open-cluster-management.io_operatorpolicies.yaml
cp deploy/crds/policy.open-cluster-management.io_operatorpolicies.yaml ../operator-policy-crd-v1.yaml
)
Expand All @@ -64,16 +47,12 @@ format_descriptions() {
# Policy CRD
format_descriptions deploy/crds/policy.open-cluster-management.io_policies.yaml
cp deploy/crds/policy.open-cluster-management.io_policies.yaml ../policy-crd-v1.yaml
cp deploy/crds/policy.open-cluster-management.io_policies.yaml ../policy-crd-v1beta1.yaml
generate_v1beta1 ../policy-crd-v1beta1.yaml
)

crdPrefix='# Copyright Contributors to the Open Cluster Management project
{{- if semverCompare "< 1.16.0" (.Values.hostingClusterCapabilities.KubeVersion.Version | default .Capabilities.KubeVersion.Version) }}'
'

addLocationLabel='.metadata.labels += {"addon.open-cluster-management.io/hosted-manifest-location": "hosting"}'
addTemplateLabel='.metadata.labels += {"policy.open-cluster-management.io/policy-type": "template"}'

# This annotation must *only* be added on the hub cluster. On others, we want the CRD removed.
# This kind of condition is not valid YAML on its own, so it has to be hacked in.
Expand All @@ -82,24 +61,16 @@ replaceAnnotation='s/SEDTARGET: SEDTARGET/{{ if .Values.onMulticlusterHub }}"add

cat >pkg/addon/configpolicy/manifests/managedclusterchart/templates/policy.open-cluster-management.io_configurationpolicies_crd.yaml <<EOF
${crdPrefix}
$(yq e "$addLocationLabel | $addTemplateLabel" .go/config-policy-crd-v1beta1.yaml)
{{ else }}
$(yq e "$addLocationLabel" .go/config-policy-crd-v1.yaml)
{{- end }}
EOF

cat >pkg/addon/configpolicy/manifests/managedclusterchart/templates/policy.open-cluster-management.io_operatorpolicies_crd.yaml <<EOF
$(echo "${crdPrefix}" | sed 's/</>/')
$(yq e "$addLocationLabel" .go/operator-policy-crd-v1.yaml)
{{- end }}
EOF

cat >pkg/addon/policyframework/manifests/managedclusterchart/templates/policy.open-cluster-management.io_policies_crd.yaml <<EOF
${crdPrefix}
$(yq e "$addTempAnnotation | $addLocationLabel" .go/policy-crd-v1beta1.yaml | sed -E "$replaceAnnotation")
{{ else }}
$(yq e "$addTempAnnotation | $addLocationLabel" .go/policy-crd-v1.yaml | sed -E "$replaceAnnotation")
{{- end }}
EOF

# Clean up the repositories - the chmod is necessary because Go makes some read-only things.
Expand Down
Loading

0 comments on commit b53dc21

Please sign in to comment.