|
29 | 29 | cp deploy/crds/policy.open-cluster-management.io_policies.yaml ../policy-crd-v1beta1.yaml |
30 | 30 | ) |
31 | 31 |
|
32 | | -addLabelsExpression='.metadata.labels += {"addon.open-cluster-management.io/hosted-manifest-location": "hosting"}' |
| 32 | +addLocationLabel='.metadata.labels += {"addon.open-cluster-management.io/hosted-manifest-location": "hosting"}' |
| 33 | +addTemplateLabel='.metadata.labels += {"policy.open-cluster-management.io/policy-type": "template"}' |
| 34 | + |
| 35 | +# This annotation must *only* be added on the hub cluster. On others, we want the CRD removed. |
| 36 | +# This kind of condition is not valid YAML on its own, so it has to be hacked in. |
| 37 | +addTempAnnotation='.metadata.annotations += {"SEDTARGET": "SEDTARGET"}' |
| 38 | +replaceAnnotation='s/SEDTARGET: SEDTARGET/{{ if .Values.onMulticlusterHub }}"addon.open-cluster-management.io\/deletion-orphan": ""{{ end }}/g' |
33 | 39 |
|
34 | 40 | cat > pkg/addon/configpolicy/manifests/managedclusterchart/templates/policy.open-cluster-management.io_configurationpolicies_crd.yaml << EOF |
35 | 41 | # Copyright Contributors to the Open Cluster Management project |
36 | 42 |
|
37 | 43 | {{- if semverCompare "< 1.16.0" .Capabilities.KubeVersion.Version }} |
38 | | -$(yq e "$addLabelsExpression" .go/config-policy-crd-v1beta1.yaml) |
| 44 | +$(yq e "$addLocationLabel | $addTemplateLabel" .go/config-policy-crd-v1beta1.yaml) |
39 | 45 | {{ else }} |
40 | | -$(yq e "$addLabelsExpression" .go/config-policy-crd-v1.yaml) |
| 46 | +$(yq e "$addLocationLabel" .go/config-policy-crd-v1.yaml) |
41 | 47 | {{- end }} |
42 | 48 | EOF |
43 | 49 |
|
44 | 50 | cat > pkg/addon/policyframework/manifests/managedclusterchart/templates/policy.open-cluster-management.io_policies_crd.yaml << EOF |
45 | 51 | # Copyright Contributors to the Open Cluster Management project |
46 | 52 |
|
47 | 53 | {{- if semverCompare "< 1.16.0" .Capabilities.KubeVersion.Version }} |
48 | | -$(yq e "$addLabelsExpression" .go/policy-crd-v1beta1.yaml) |
| 54 | +$(yq e "$addTempAnnotation | $addLocationLabel" .go/policy-crd-v1beta1.yaml | sed -E "$replaceAnnotation") |
49 | 55 | {{ else }} |
50 | | -$(yq e "$addLabelsExpression" .go/policy-crd-v1.yaml) |
| 56 | +$(yq e "$addTempAnnotation | $addLocationLabel" .go/policy-crd-v1.yaml | sed -E "$replaceAnnotation") |
51 | 57 | {{- end }} |
52 | 58 | EOF |
53 | 59 |
|
|
0 commit comments