Skip to content

Commit 1f7dfcd

Browse files
committed
Loosen KMS validation to allow nil KMSConfig
1 parent d1c4dc4 commit 1f7dfcd

10 files changed

Lines changed: 26 additions & 34 deletions

config/v1/tests/apiservers.config.openshift.io/KMSEncryptionProvider.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,22 @@ tests:
5454
aws:
5555
keyARN: arn:aws:kms:us-east-1:101010101010:key/9a512e29-0d9c-4cf5-8174-fc1a5b22cd6a
5656
region: us-east-1
57-
expectedError: "kms config is required when encryption type is KMS, and forbidden otherwise"
58-
- name: Should fail to create with an empty KMS config
57+
expectedError: "kms config is forbidden when encryption type is not KMS"
58+
- name: Should be able to create with KMS type and nil kms config
5959
initial: |
6060
apiVersion: config.openshift.io/v1
6161
kind: APIServer
6262
spec:
6363
encryption:
6464
type: KMS
65-
kms: {}
66-
expectedError: "spec.encryption.kms.type: Required value"
65+
expected: |
66+
apiVersion: config.openshift.io/v1
67+
kind: APIServer
68+
spec:
69+
audit:
70+
profile: Default
71+
encryption:
72+
type: KMS
6773
- name: Should fail to create with kms type AWS but without aws config
6874
initial: |
6975
apiVersion: config.openshift.io/v1

config/v1/types_apiserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ type APIServerNamedServingCert struct {
175175
}
176176

177177
// APIServerEncryption is used to encrypt sensitive resources on the cluster.
178-
// +openshift:validation:FeatureGateAwareXValidation:featureGate=KMSEncryptionProvider,rule="has(self.type) && self.type == 'KMS' ? has(self.kms) : !has(self.kms)",message="kms config is required when encryption type is KMS, and forbidden otherwise"
178+
// +openshift:validation:FeatureGateAwareXValidation:featureGate=KMSEncryptionProvider,rule="self.type != 'KMS' ? !has(self.kms) : true",message="kms config is forbidden when encryption type is not KMS"
179179
// +union
180180
type APIServerEncryption struct {
181181
// type defines what encryption type should be used to encrypt resources at the datastore layer.

config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_apiservers-CustomNoUpgrade.crd.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,8 @@ spec:
245245
type: string
246246
type: object
247247
x-kubernetes-validations:
248-
- message: kms config is required when encryption type is KMS, and
249-
forbidden otherwise
250-
rule: 'has(self.type) && self.type == ''KMS'' ? has(self.kms) :
251-
!has(self.kms)'
248+
- message: kms config is forbidden when encryption type is not KMS
249+
rule: 'self.type != ''KMS'' ? !has(self.kms) : true'
252250
servingCerts:
253251
description: |-
254252
servingCert is the TLS cert info for serving secure traffic. If not specified, operator managed certificates

config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_apiservers-DevPreviewNoUpgrade.crd.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,8 @@ spec:
245245
type: string
246246
type: object
247247
x-kubernetes-validations:
248-
- message: kms config is required when encryption type is KMS, and
249-
forbidden otherwise
250-
rule: 'has(self.type) && self.type == ''KMS'' ? has(self.kms) :
251-
!has(self.kms)'
248+
- message: kms config is forbidden when encryption type is not KMS
249+
rule: 'self.type != ''KMS'' ? !has(self.kms) : true'
252250
servingCerts:
253251
description: |-
254252
servingCert is the TLS cert info for serving secure traffic. If not specified, operator managed certificates

config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_apiservers-TechPreviewNoUpgrade.crd.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,8 @@ spec:
245245
type: string
246246
type: object
247247
x-kubernetes-validations:
248-
- message: kms config is required when encryption type is KMS, and
249-
forbidden otherwise
250-
rule: 'has(self.type) && self.type == ''KMS'' ? has(self.kms) :
251-
!has(self.kms)'
248+
- message: kms config is forbidden when encryption type is not KMS
249+
rule: 'self.type != ''KMS'' ? !has(self.kms) : true'
252250
servingCerts:
253251
description: |-
254252
servingCert is the TLS cert info for serving secure traffic. If not specified, operator managed certificates

config/v1/zz_generated.featuregated-crd-manifests/apiservers.config.openshift.io/KMSEncryptionProvider.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,8 @@ spec:
245245
type: string
246246
type: object
247247
x-kubernetes-validations:
248-
- message: kms config is required when encryption type is KMS, and
249-
forbidden otherwise
250-
rule: 'has(self.type) && self.type == ''KMS'' ? has(self.kms) :
251-
!has(self.kms)'
248+
- message: kms config is forbidden when encryption type is not KMS
249+
rule: 'self.type != ''KMS'' ? !has(self.kms) : true'
252250
servingCerts:
253251
description: |-
254252
servingCert is the TLS cert info for serving secure traffic. If not specified, operator managed certificates

openapi/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9881,7 +9881,7 @@
98819881
"$ref": "#/definitions/com.github.openshift.api.config.v1.PKI"
98829882
},
98839883
"policyType": {
9884-
"description": "policyType is a required field specifies the type of the policy for verification. This field must correspond to how the policy was generated. Allowed values are \"PublicKey\", \"FulcioCAWithRekor\", and \"PKI\". When set to \"PublicKey\", the policy relies on a sigstore publicKey and may optionally use a Rekor verification. When set to \"FulcioCAWithRekor\", the policy is based on the Fulcio certification and incorporates a Rekor verification. When set to \"PKI\", the policy is based on the certificates from Bring Your Own Public Key Infrastructure (BYOPKI). This value is enabled by turning on the SigstoreImageVerificationPKI feature gate.",
9884+
"description": "policyType is a required field specifies the type of the policy for verification. This field must correspond to how the policy was generated. Allowed values are \"PublicKey\", \"FulcioCAWithRekor\", and \"PKI\". When set to \"PublicKey\", the policy relies on a sigstore publicKey and may optionally use a Rekor verification. When set to \"FulcioCAWithRekor\", the policy is based on the Fulcio certification and incorporates a Rekor verification. When set to \"PKI\", the policy is based on the certificates from Bring Your Own Public Key Infrastructure (BYOPKI).",
98859885
"type": "string",
98869886
"default": ""
98879887
},

payload-manifests/crds/0000_10_config-operator_01_apiservers-CustomNoUpgrade.crd.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,8 @@ spec:
245245
type: string
246246
type: object
247247
x-kubernetes-validations:
248-
- message: kms config is required when encryption type is KMS, and
249-
forbidden otherwise
250-
rule: 'has(self.type) && self.type == ''KMS'' ? has(self.kms) :
251-
!has(self.kms)'
248+
- message: kms config is forbidden when encryption type is not KMS
249+
rule: 'self.type != ''KMS'' ? !has(self.kms) : true'
252250
servingCerts:
253251
description: |-
254252
servingCert is the TLS cert info for serving secure traffic. If not specified, operator managed certificates

payload-manifests/crds/0000_10_config-operator_01_apiservers-DevPreviewNoUpgrade.crd.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,8 @@ spec:
245245
type: string
246246
type: object
247247
x-kubernetes-validations:
248-
- message: kms config is required when encryption type is KMS, and
249-
forbidden otherwise
250-
rule: 'has(self.type) && self.type == ''KMS'' ? has(self.kms) :
251-
!has(self.kms)'
248+
- message: kms config is forbidden when encryption type is not KMS
249+
rule: 'self.type != ''KMS'' ? !has(self.kms) : true'
252250
servingCerts:
253251
description: |-
254252
servingCert is the TLS cert info for serving secure traffic. If not specified, operator managed certificates

payload-manifests/crds/0000_10_config-operator_01_apiservers-TechPreviewNoUpgrade.crd.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,8 @@ spec:
245245
type: string
246246
type: object
247247
x-kubernetes-validations:
248-
- message: kms config is required when encryption type is KMS, and
249-
forbidden otherwise
250-
rule: 'has(self.type) && self.type == ''KMS'' ? has(self.kms) :
251-
!has(self.kms)'
248+
- message: kms config is forbidden when encryption type is not KMS
249+
rule: 'self.type != ''KMS'' ? !has(self.kms) : true'
252250
servingCerts:
253251
description: |-
254252
servingCert is the TLS cert info for serving secure traffic. If not specified, operator managed certificates

0 commit comments

Comments
 (0)