Skip to content

Commit

Permalink
Clarify storage class requirement for crypto.encryptionClassName API (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dilyar85 authored Oct 15, 2024
1 parent 8797c6d commit ddd2c56
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api/v1alpha3/virtualmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ type VirtualMachineCryptoSpec struct {
// If the underlying vSphere platform does not have a default key provider,
// then this field is required when specifying an encryption storage class
// and/or a VM Class with a vTPM.
//
// If this field is set, spec.storageClass must use an encryption-enabled
// storage class.
EncryptionClassName string `json:"encryptionClassName,omitempty"`

// +optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,9 @@ spec:
If the underlying vSphere platform does not have a default key provider,
then this field is required when specifying an encryption storage class
and/or a VM Class with a vTPM.
If this field is set, spec.storageClass must use an encryption-enabled
storage class.
type: string
useDefaultKeyProvider:
default: true
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/vmoperator.vmware.com_virtualmachines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3818,6 +3818,9 @@ spec:
If the underlying vSphere platform does not have a default key provider,
then this field is required when specifying an encryption storage class
and/or a VM Class with a vTPM.
If this field is set, spec.storageClass must use an encryption-enabled
storage class.
type: string
useDefaultKeyProvider:
default: true
Expand Down
5 changes: 4 additions & 1 deletion docs/ref/api/v1alpha3.md
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,10 @@ minus any virtual disks, will be encrypted.

If the underlying vSphere platform does not have a default key provider,
then this field is required when specifying an encryption storage class
and/or a VM Class with a vTPM. |
and/or a VM Class with a vTPM.

If this field is set, spec.storageClass must use an encryption-enabled
storage class. |
| `useDefaultKeyProvider` _boolean_ | UseDefaultKeyProvider describes the desired behavior for when an explicit
EncryptionClass is not provided.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ func (v validator) validateCrypto(
allErrs = append(allErrs, field.InternalError(encClassNamePath, err))

} else if !ok {
// Return an error on the "vm.Spec.Crypto.EncryptionClassName" path
// instead of "vm.Spec.StorageClass" because the storage class is
// invalid due to the user's choice of encryption class name.
allErrs = append(allErrs, field.Invalid(
encClassNamePath,
vm.Spec.Crypto.EncryptionClassName,
Expand Down

0 comments on commit ddd2c56

Please sign in to comment.