Skip to content

Commit

Permalink
Merge pull request #219 from bryanv/bryanv/v1a2-mr
Browse files Browse the repository at this point in the history
✨ v1a2 provider & api changes
  • Loading branch information
bryanv authored Sep 29, 2023
2 parents 7fbd536 + 865f407 commit a70112e
Show file tree
Hide file tree
Showing 127 changed files with 19,949 additions and 205 deletions.
6 changes: 6 additions & 0 deletions api/v1alpha1/condition_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ func Convert_v1alpha1_Condition_To_v1_Condition(in *Condition, out *metav1.Condi
out.Reason = in.Reason
out.Message = in.Message

// The metav1.Condition requires the reason to be non-empty, when it was not in our prior v1a1 Condition.
// We don't have any great options as to what we can fill this in as.
if out.Reason == "" {
out.Reason = string(out.Status)
}

// TODO: out.ObservedGeneration =

return nil
Expand Down
28 changes: 23 additions & 5 deletions api/v1alpha1/virtualmachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func convert_v1alpha1_VmMetadata_To_v1alpha2_BootstrapSpec(
out.CloudInit = &v1alpha2.VirtualMachineBootstrapCloudInitSpec{
RawCloudConfig: corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{Name: objectName},
Key: "guestinfo.userdata",
Key: "guestinfo.userdata", // TODO: Is this good enough? v1a1 would include everything with the "guestinfo" prefix
},
}
case VirtualMachineMetadataOvfEnvTransport:
Expand Down Expand Up @@ -449,6 +449,12 @@ func convert_v1alpha2_NetworkStatus_To_v1alpha1_Network(
func Convert_v1alpha1_VirtualMachineSpec_To_v1alpha2_VirtualMachineSpec(
in *VirtualMachineSpec, out *v1alpha2.VirtualMachineSpec, s apiconversion.Scope) error {

// The generated auto convert will convert the power modes as-is strings which breaks things, so keep
// this first.
if err := autoConvert_v1alpha1_VirtualMachineSpec_To_v1alpha2_VirtualMachineSpec(in, out, s); err != nil {
return err
}

out.PowerState = convert_v1alpha1_VirtualMachinePowerState_To_v1alpha2_VirtualMachinePowerState(in.PowerState)
out.PowerOffMode = convert_v1alpha1_VirtualMachinePowerOpMode_To_v1alpha2_VirtualMachinePowerOpMode(in.PowerOffMode)
out.SuspendMode = convert_v1alpha1_VirtualMachinePowerOpMode_To_v1alpha2_VirtualMachinePowerOpMode(in.SuspendMode)
Expand All @@ -469,12 +475,16 @@ func Convert_v1alpha1_VirtualMachineSpec_To_v1alpha2_VirtualMachineSpec(
// Deprecated:
// in.Ports

return autoConvert_v1alpha1_VirtualMachineSpec_To_v1alpha2_VirtualMachineSpec(in, out, s)
return nil
}

func Convert_v1alpha2_VirtualMachineSpec_To_v1alpha1_VirtualMachineSpec(
in *v1alpha2.VirtualMachineSpec, out *VirtualMachineSpec, s apiconversion.Scope) error {

if err := autoConvert_v1alpha2_VirtualMachineSpec_To_v1alpha1_VirtualMachineSpec(in, out, s); err != nil {
return err
}

out.PowerState = convert_v1alpha2_VirtualMachinePowerState_To_v1alpha1_VirtualMachinePowerState(in.PowerState)
out.PowerOffMode = convert_v1alpha2_VirtualMachinePowerOpMode_To_v1alpha1_VirtualMachinePowerOpMode(in.PowerOffMode)
out.SuspendMode = convert_v1alpha2_VirtualMachinePowerOpMode_To_v1alpha1_VirtualMachinePowerOpMode(in.SuspendMode)
Expand All @@ -496,7 +506,7 @@ func Convert_v1alpha2_VirtualMachineSpec_To_v1alpha1_VirtualMachineSpec(
// Deprecated:
// out.Ports

return autoConvert_v1alpha2_VirtualMachineSpec_To_v1alpha1_VirtualMachineSpec(in, out, s)
return nil
}

func Convert_v1alpha1_VirtualMachineVolumeStatus_To_v1alpha2_VirtualMachineVolumeStatus(
Expand All @@ -518,18 +528,26 @@ func Convert_v1alpha2_VirtualMachineVolumeStatus_To_v1alpha1_VirtualMachineVolum
func Convert_v1alpha1_VirtualMachineStatus_To_v1alpha2_VirtualMachineStatus(
in *VirtualMachineStatus, out *v1alpha2.VirtualMachineStatus, s apiconversion.Scope) error {

if err := autoConvert_v1alpha1_VirtualMachineStatus_To_v1alpha2_VirtualMachineStatus(in, out, s); err != nil {
return err
}

out.PowerState = convert_v1alpha1_VirtualMachinePowerState_To_v1alpha2_VirtualMachinePowerState(in.PowerState)
out.Network = convert_v1alpha1_Network_To_v1alpha2_NetworkStatus(in.VmIp, in.NetworkInterfaces)
out.LastRestartTime = in.LastRestartTime

// WARNING: in.Phase requires manual conversion: does not exist in peer-type

return autoConvert_v1alpha1_VirtualMachineStatus_To_v1alpha2_VirtualMachineStatus(in, out, s)
return nil
}

func Convert_v1alpha2_VirtualMachineStatus_To_v1alpha1_VirtualMachineStatus(
in *v1alpha2.VirtualMachineStatus, out *VirtualMachineStatus, s apiconversion.Scope) error {

if err := autoConvert_v1alpha2_VirtualMachineStatus_To_v1alpha1_VirtualMachineStatus(in, out, s); err != nil {
return err
}

out.PowerState = convert_v1alpha2_VirtualMachinePowerState_To_v1alpha1_VirtualMachinePowerState(in.PowerState)
out.Phase = convert_v1alpha2_Conditions_To_v1alpha1_Phase(in.Conditions)
out.VmIp, out.NetworkInterfaces = convert_v1alpha2_NetworkStatus_To_v1alpha1_Network(in.Network)
Expand All @@ -538,7 +556,7 @@ func Convert_v1alpha2_VirtualMachineStatus_To_v1alpha1_VirtualMachineStatus(
// WARNING: in.Image requires manual conversion: does not exist in peer-type
// WARNING: in.Class requires manual conversion: does not exist in peer-type

return autoConvert_v1alpha2_VirtualMachineStatus_To_v1alpha1_VirtualMachineStatus(in, out, s)
return nil
}

// ConvertTo converts this VirtualMachine to the Hub version.
Expand Down
72 changes: 36 additions & 36 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,19 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /default-validate-vmoperator-vmware-com-v1alpha1-virtualmachineclass
path: /default-validate-vmoperator-vmware-com-v1alpha2-virtualmachine
failurePolicy: Fail
name: default.validating.virtualmachineclass.v1alpha1.vmoperator.vmware.com
name: default.validating.virtualmachine.v1alpha2.vmoperator.vmware.com
rules:
- apiGroups:
- vmoperator.vmware.com
apiVersions:
- v1alpha1
- v1alpha2
operations:
- CREATE
- UPDATE
resources:
- virtualmachineclasses
- virtualmachines
sideEffects: None
- admissionReviewVersions:
- v1
Expand All @@ -124,9 +124,9 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /default-validate-vmoperator-vmware-com-v1alpha1-virtualmachinepublishrequest
path: /default-validate-vmoperator-vmware-com-v1alpha1-virtualmachineclass
failurePolicy: Fail
name: default.validating.virtualmachinepublishrequest.v1alpha1.vmoperator.vmware.com
name: default.validating.virtualmachineclass.v1alpha1.vmoperator.vmware.com
rules:
- apiGroups:
- vmoperator.vmware.com
Expand All @@ -136,7 +136,7 @@ webhooks:
- CREATE
- UPDATE
resources:
- virtualmachinepublishrequests
- virtualmachineclasses
sideEffects: None
- admissionReviewVersions:
- v1
Expand All @@ -145,19 +145,19 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /default-validate-vmoperator-vmware-com-v1alpha1-virtualmachineservice
path: /default-validate-vmoperator-vmware-com-v1alpha2-virtualmachineclass
failurePolicy: Fail
name: default.validating.virtualmachineservice.v1alpha1.vmoperator.vmware.com
name: default.validating.virtualmachineclass.v1alpha2.vmoperator.vmware.com
rules:
- apiGroups:
- vmoperator.vmware.com
apiVersions:
- v1alpha1
- v1alpha2
operations:
- CREATE
- UPDATE
resources:
- virtualmachineservices
- virtualmachineclasses
sideEffects: None
- admissionReviewVersions:
- v1
Expand All @@ -166,9 +166,9 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /default-validate-vmoperator-vmware-com-v1alpha1-virtualmachinesetresourcepolicy
path: /default-validate-vmoperator-vmware-com-v1alpha1-virtualmachinepublishrequest
failurePolicy: Fail
name: default.validating.virtualmachinesetresourcepolicy.v1alpha1.vmoperator.vmware.com
name: default.validating.virtualmachinepublishrequest.v1alpha1.vmoperator.vmware.com
rules:
- apiGroups:
- vmoperator.vmware.com
Expand All @@ -178,7 +178,7 @@ webhooks:
- CREATE
- UPDATE
resources:
- virtualmachinesetresourcepolicies
- virtualmachinepublishrequests
sideEffects: None
- admissionReviewVersions:
- v1
Expand All @@ -187,19 +187,19 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /default-validate-vmoperator-vmware-com-v1alpha1-webconsolerequest
path: /default-validate-vmoperator-vmware-com-v1alpha2-virtualmachinepublishrequest
failurePolicy: Fail
name: default.validating.webconsolerequest.v1alpha1.vmoperator.vmware.com
name: default.validating.virtualmachinepublishrequest.v1alpha2.vmoperator.vmware.com
rules:
- apiGroups:
- vmoperator.vmware.com
apiVersions:
- v1alpha1
- v1alpha2
operations:
- CREATE
- UPDATE
resources:
- webconsolerequests
- virtualmachinepublishrequests
sideEffects: None
- admissionReviewVersions:
- v1
Expand All @@ -208,19 +208,19 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /default-validate-vmoperator-vmware-com-v1alpha2-virtualmachine
path: /default-validate-vmoperator-vmware-com-v1alpha1-virtualmachineservice
failurePolicy: Fail
name: default.validating.virtualmachine.v1alpha2.vmoperator.vmware.com
name: default.validating.virtualmachineservice.v1alpha1.vmoperator.vmware.com
rules:
- apiGroups:
- vmoperator.vmware.com
apiVersions:
- v1alpha2
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- virtualmachines
- virtualmachineservices
sideEffects: None
- admissionReviewVersions:
- v1
Expand All @@ -229,9 +229,9 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /default-validate-vmoperator-vmware-com-v1alpha2-virtualmachineclass
path: /default-validate-vmoperator-vmware-com-v1alpha2-virtualmachineservice
failurePolicy: Fail
name: default.validating.virtualmachineclass.v1alpha2.vmoperator.vmware.com
name: default.validating.virtualmachineservice.v1alpha2.vmoperator.vmware.com
rules:
- apiGroups:
- vmoperator.vmware.com
Expand All @@ -241,7 +241,7 @@ webhooks:
- CREATE
- UPDATE
resources:
- virtualmachineclasses
- virtualmachineservices
sideEffects: None
- admissionReviewVersions:
- v1
Expand All @@ -250,19 +250,19 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /default-validate-vmoperator-vmware-com-v1alpha2-virtualmachinepublishrequest
path: /default-validate-vmoperator-vmware-com-v1alpha1-virtualmachinesetresourcepolicy
failurePolicy: Fail
name: default.validating.virtualmachinepublishrequest.v1alpha2.vmoperator.vmware.com
name: default.validating.virtualmachinesetresourcepolicy.v1alpha1.vmoperator.vmware.com
rules:
- apiGroups:
- vmoperator.vmware.com
apiVersions:
- v1alpha2
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- virtualmachinepublishrequests
- virtualmachinesetresourcepolicies
sideEffects: None
- admissionReviewVersions:
- v1
Expand All @@ -271,9 +271,9 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /default-validate-vmoperator-vmware-com-v1alpha2-virtualmachineservice
path: /default-validate-vmoperator-vmware-com-v1alpha2-virtualmachinesetresourcepolicy
failurePolicy: Fail
name: default.validating.virtualmachineservice.v1alpha2.vmoperator.vmware.com
name: default.validating.virtualmachinesetresourcepolicy.v1alpha2.vmoperator.vmware.com
rules:
- apiGroups:
- vmoperator.vmware.com
Expand All @@ -283,7 +283,7 @@ webhooks:
- CREATE
- UPDATE
resources:
- virtualmachineservices
- virtualmachinesetresourcepolicies
sideEffects: None
- admissionReviewVersions:
- v1
Expand All @@ -292,17 +292,17 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /default-validate-vmoperator-vmware-com-v1alpha2-virtualmachinesetresourcepolicy
path: /default-validate-vmoperator-vmware-com-v1alpha1-webconsolerequest
failurePolicy: Fail
name: default.validating.virtualmachinesetresourcepolicy.v1alpha2.vmoperator.vmware.com
name: default.validating.webconsolerequest.v1alpha1.vmoperator.vmware.com
rules:
- apiGroups:
- vmoperator.vmware.com
apiVersions:
- v1alpha2
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- virtualmachinesetresourcepolicies
- webconsolerequests
sideEffects: None
Loading

0 comments on commit a70112e

Please sign in to comment.