diff --git a/apis/compute/v1alpha3/referencers.go b/apis/compute/v1alpha3/referencers.go
index 0f8a62ce..61b252de 100644
--- a/apis/compute/v1alpha3/referencers.go
+++ b/apis/compute/v1alpha3/referencers.go
@@ -62,3 +62,42 @@ func (mg *AKSCluster) ResolveReferences(ctx context.Context, c client.Reader) er
return nil
}
+
+// ResolveReferences of this VirtualMachine.
+func (mg *VirtualMachine) ResolveReferences(ctx context.Context, c client.Reader) error {
+ r := reference.NewAPIResolver(c, mg)
+
+ // Resolve spec.resourceGroupName
+ rsp, err := r.Resolve(ctx, reference.ResolutionRequest{
+ CurrentValue: mg.Spec.ResourceGroupName,
+ Reference: mg.Spec.ResourceGroupNameRef,
+ Selector: mg.Spec.ResourceGroupNameSelector,
+ To: reference.To{Managed: &v1alpha3.ResourceGroup{}, List: &v1alpha3.ResourceGroupList{}},
+ Extract: reference.ExternalName(),
+ })
+ if err != nil {
+ return errors.Wrap(err, "spec.resourceGroupName")
+ }
+ mg.Spec.ResourceGroupName = rsp.ResolvedValue
+ mg.Spec.ResourceGroupNameRef = rsp.ResolvedReference
+
+ if mg.Spec.VirtualMachineParameters != nil && mg.Spec.VirtualMachineParameters.NetworkProfile != nil {
+ netProf := mg.Spec.VirtualMachineParameters.NetworkProfile
+ for _, networkInterface := range netProf.NetworkInterfaces {
+ // Resolve spec.properties.networkProfile.networkInterfaces[].networkInterfaceID
+ rsp, err := r.Resolve(ctx, reference.ResolutionRequest{
+ CurrentValue: networkInterface.NetworkInterfaceID,
+ Reference: networkInterface.NetworkInterfaceIDRef,
+ Selector: networkInterface.NetworkInterfaceIDSelector,
+ To: reference.To{Managed: &networkv1alpha3.NetworkInterface{}, List: &networkv1alpha3.NetworkInterfaceList{}},
+ Extract: networkv1alpha3.NetworkInterfaceID(),
+ })
+ if err != nil {
+ return errors.Wrap(err, "spec.properties.networkProfile.networkInterfaces[].networkInterfaceID")
+ }
+ networkInterface.NetworkInterfaceID = rsp.ResolvedValue
+ networkInterface.NetworkInterfaceIDRef = rsp.ResolvedReference
+ }
+ }
+ return nil
+}
diff --git a/apis/compute/v1alpha3/register.go b/apis/compute/v1alpha3/register.go
index 41431fbd..1bfe9720 100644
--- a/apis/compute/v1alpha3/register.go
+++ b/apis/compute/v1alpha3/register.go
@@ -45,6 +45,15 @@ var (
AKSClusterGroupVersionKind = SchemeGroupVersion.WithKind(AKSClusterKind)
)
+// VirtualMachine type metadata.
+var (
+ VirtualMachineKind = reflect.TypeOf(VirtualMachine{}).Name()
+ VirtualMachineGroupKind = schema.GroupKind{Group: Group, Kind: VirtualMachineKind}.String()
+ VirtualMachineKindAPIVersion = VirtualMachineKind + "." + SchemeGroupVersion.String()
+ VirtualMachineGroupVersionKind = SchemeGroupVersion.WithKind(VirtualMachineKind)
+)
+
func init() {
SchemeBuilder.Register(&AKSCluster{}, &AKSClusterList{})
+ SchemeBuilder.Register(&VirtualMachine{}, &VirtualMachineList{})
}
diff --git a/apis/compute/v1alpha3/types.go b/apis/compute/v1alpha3/types.go
index 283c1d1b..5276b11b 100644
--- a/apis/compute/v1alpha3/types.go
+++ b/apis/compute/v1alpha3/types.go
@@ -131,3 +131,184 @@ type AKSClusterList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []AKSCluster `json:"items"`
}
+
+// ImageReferenceParameters specifies information about the image to use. You can specify information about platform
+// images, marketplace images, or virtual machine images. This element is required when you want to use a
+// platform image, marketplace image, or virtual machine image, but is not used in other creation
+// operations. NOTE: Image reference publisher and offer can only be set when you create the scale set.
+type ImageReferenceParameters struct {
+ // Publisher - The image publisher.
+ Publisher string `json:"publisher"`
+ // Offer - Specifies the offer of the platform image or marketplace image used to create the virtual machine.
+ Offer string `json:"offer"`
+ // Sku - The image SKU.
+ Sku string `json:"sku"`
+ // Version - Specifies the version of the platform image or marketplace image used to create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image available at deploy time. Even if you use 'latest', the VM image will not automatically update after deploy time even if a new version becomes available.
+ Version string `json:"version"`
+}
+
+// OSDiskParameters specifies information about the operating system disk used by the virtual machine.
For
+// more information about disks, see [About disks and VHDs for Azure virtual
+// machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-about-disks-vhds?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json).
+type OSDiskParameters struct {
+ // Name - The disk name.
+ Name string `json:"name"`
+ // Vhd - The virtual hard disk.
+ Vhd *VirtualHardDiskParameters `json:"vhd"`
+}
+
+// VirtualHardDiskParameters describes the uri of a disk.
+type VirtualHardDiskParameters struct {
+ // URI - Specifies the virtual hard disk's uri.
+ URI string `json:"uri,omitempty"`
+}
+
+// StorageProfileParameters specifies the storage settings for the virtual machine disks.
+type StorageProfileParameters struct {
+ // ImageReference - Specifies information about the image to use. You can specify information about platform images, marketplace images, or virtual machine images. This element is required when you want to use a platform image, marketplace image, or virtual machine image, but is not used in other creation operations.
+ ImageReference *ImageReferenceParameters `json:"imageReference"`
+ // OsDisk - Specifies information about the operating system disk used by the virtual machine.
For more information about disks, see [About disks and VHDs for Azure virtual machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-about-disks-vhds?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json).
+ OsDisk *OSDiskParameters `json:"osDisk,omitempty"`
+}
+
+// OSProfileParameters specifies the operating system settings for the virtual machine. Some of the settings cannot
+// be changed once VM is provisioned.
+type OSProfileParameters struct {
+ // ComputerName - Specifies the host OS name of the virtual machine.
This name cannot be updated after the VM is created.
**Max-length (Windows):** 15 characters
**Max-length (Linux):** 64 characters.
For naming conventions and restrictions see [Azure infrastructure services implementation guidelines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-infrastructure-subscription-accounts-guidelines?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json#1-naming-conventions).
+ ComputerName string `json:"computerName"`
+ // AdminUsername - Specifies the name of the administrator account.
This property cannot be updated after the VM is created.
**Windows-only restriction:** Cannot end in "."
**Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5".
**Minimum-length (Linux):** 1 character
**Max-length (Linux):** 64 characters
**Max-length (Windows):** 20 characters
For root access to the Linux VM, see [Using root privileges on Linux virtual machines in Azure](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-use-root-privileges?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)
For a list of built-in system users on Linux that should not be used in this field, see [Selecting User Names for Linux on Azure](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-usernames?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)
+ AdminUsername string `json:"adminUsername"`
+ // AdminPassword - Specifies the password of the administrator account.
**Minimum-length (Windows):** 8 characters
**Minimum-length (Linux):** 6 characters
**Max-length (Windows):** 123 characters
**Max-length (Linux):** 72 characters
**Complexity requirements:** 3 out of 4 conditions below need to be fulfilled
Has lower characters
Has upper characters
Has a digit
Has a special character (Regex match [\W_])
**Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", "pass@word1", "Password!", "Password1", "Password22", "iloveyou!"
For resetting the password, see [How to reset the Remote Desktop service or its login password in a Windows VM](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-reset-rdp?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json)
For resetting root password, see [Manage users, SSH, and check or repair disks on Azure Linux VMs using the VMAccess Extension](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-using-vmaccess-extension?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json#reset-root-password)
+ AdminPassword string `json:"adminPassword"`
+
+ // LinuxConfiguration - Specifies the Linux operating system settings on the virtual machine.
For a list of supported Linux distributions, see [Linux on Azure-Endorsed Distributions](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-endorsed-distros?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)
For running non-endorsed distributions, see [Information for Non-Endorsed Distributions](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-create-upload-generic?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
+ LinuxConfiguration *LinuxConfigurationParameters `json:"linuxConfiguration"`
+}
+
+// LinuxConfigurationParameters specifies the Linux operating system settings on the virtual machine.
For a
+// list of supported Linux distributions, see [Linux on Azure-Endorsed
+// Distributions](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-endorsed-distros?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)
+//
For running non-endorsed distributions, see [Information for Non-Endorsed
+// Distributions](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-create-upload-generic?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
+type LinuxConfigurationParameters struct {
+ // SSH - Specifies the ssh key configuration for a Linux OS.
+ SSH *SSHConfigurationParameters `json:"ssh"`
+}
+
+// SSHConfigurationParameters SSH configuration for Linux based VMs running on Azure
+type SSHConfigurationParameters struct {
+ // PublicKeys - The list of SSH public keys used to authenticate with linux based VMs.
+ PublicKeys []*SSHPublicKey `json:"publicKeys"`
+}
+
+// SSHPublicKey contains information about SSH certificate public key and the path on the Linux VM where
+// the public key is placed.
+type SSHPublicKey struct {
+ // Path - Specifies the full path on the created VM where ssh public key is stored. If the file already exists, the specified key is appended to the file. Example: /home/user/.ssh/authorized_keys
+ Path string `json:"path"`
+ // KeyData - SSH public key certificate used to authenticate with the VM through ssh. The key needs to be at least 2048-bit and in ssh-rsa format.
For creating ssh keys, see [Create SSH keys on Linux and Mac for Linux VMs in Azure](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-mac-create-ssh-keys?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
+ KeyData string `json:"keyData"`
+}
+
+// HardwareProfileParameters specifies the hardware settings for the virtual machine.
+type HardwareProfileParameters struct {
+ // VMSize - Specifies the size of the virtual machine. For more information about virtual machine sizes, see [Sizes for virtual machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-sizes?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json).
The available VM sizes depend on region and availability set. For a list of available sizes use these APIs:
[List all available virtual machine sizes in an availability set](https://docs.microsoft.com/rest/api/compute/availabilitysets/listavailablesizes)
[List all available virtual machine sizes in a region](https://docs.microsoft.com/rest/api/compute/virtualmachinesizes/list)
[List all available virtual machine sizes for resizing](https://docs.microsoft.com/rest/api/compute/virtualmachines/listavailablesizes). Possible values include: 'VirtualMachineSizeTypesBasicA0', 'VirtualMachineSizeTypesBasicA1', 'VirtualMachineSizeTypesBasicA2', 'VirtualMachineSizeTypesBasicA3', 'VirtualMachineSizeTypesBasicA4', 'VirtualMachineSizeTypesStandardA0', 'VirtualMachineSizeTypesStandardA1', 'VirtualMachineSizeTypesStandardA2', 'VirtualMachineSizeTypesStandardA3', 'VirtualMachineSizeTypesStandardA4', 'VirtualMachineSizeTypesStandardA5', 'VirtualMachineSizeTypesStandardA6', 'VirtualMachineSizeTypesStandardA7', 'VirtualMachineSizeTypesStandardA8', 'VirtualMachineSizeTypesStandardA9', 'VirtualMachineSizeTypesStandardA10', 'VirtualMachineSizeTypesStandardA11', 'VirtualMachineSizeTypesStandardA1V2', 'VirtualMachineSizeTypesStandardA2V2', 'VirtualMachineSizeTypesStandardA4V2', 'VirtualMachineSizeTypesStandardA8V2', 'VirtualMachineSizeTypesStandardA2mV2', 'VirtualMachineSizeTypesStandardA4mV2', 'VirtualMachineSizeTypesStandardA8mV2', 'VirtualMachineSizeTypesStandardB1s', 'VirtualMachineSizeTypesStandardB1ms', 'VirtualMachineSizeTypesStandardB2s', 'VirtualMachineSizeTypesStandardB2ms', 'VirtualMachineSizeTypesStandardB4ms', 'VirtualMachineSizeTypesStandardB8ms', 'VirtualMachineSizeTypesStandardD1', 'VirtualMachineSizeTypesStandardD2', 'VirtualMachineSizeTypesStandardD3', 'VirtualMachineSizeTypesStandardD4', 'VirtualMachineSizeTypesStandardD11', 'VirtualMachineSizeTypesStandardD12', 'VirtualMachineSizeTypesStandardD13', 'VirtualMachineSizeTypesStandardD14', 'VirtualMachineSizeTypesStandardD1V2', 'VirtualMachineSizeTypesStandardD2V2', 'VirtualMachineSizeTypesStandardD3V2', 'VirtualMachineSizeTypesStandardD4V2', 'VirtualMachineSizeTypesStandardD5V2', 'VirtualMachineSizeTypesStandardD2V3', 'VirtualMachineSizeTypesStandardD4V3', 'VirtualMachineSizeTypesStandardD8V3', 'VirtualMachineSizeTypesStandardD16V3', 'VirtualMachineSizeTypesStandardD32V3', 'VirtualMachineSizeTypesStandardD64V3', 'VirtualMachineSizeTypesStandardD2sV3', 'VirtualMachineSizeTypesStandardD4sV3', 'VirtualMachineSizeTypesStandardD8sV3', 'VirtualMachineSizeTypesStandardD16sV3', 'VirtualMachineSizeTypesStandardD32sV3', 'VirtualMachineSizeTypesStandardD64sV3', 'VirtualMachineSizeTypesStandardD11V2', 'VirtualMachineSizeTypesStandardD12V2', 'VirtualMachineSizeTypesStandardD13V2', 'VirtualMachineSizeTypesStandardD14V2', 'VirtualMachineSizeTypesStandardD15V2', 'VirtualMachineSizeTypesStandardDS1', 'VirtualMachineSizeTypesStandardDS2', 'VirtualMachineSizeTypesStandardDS3', 'VirtualMachineSizeTypesStandardDS4', 'VirtualMachineSizeTypesStandardDS11', 'VirtualMachineSizeTypesStandardDS12', 'VirtualMachineSizeTypesStandardDS13', 'VirtualMachineSizeTypesStandardDS14', 'VirtualMachineSizeTypesStandardDS1V2', 'VirtualMachineSizeTypesStandardDS2V2', 'VirtualMachineSizeTypesStandardDS3V2', 'VirtualMachineSizeTypesStandardDS4V2', 'VirtualMachineSizeTypesStandardDS5V2', 'VirtualMachineSizeTypesStandardDS11V2', 'VirtualMachineSizeTypesStandardDS12V2', 'VirtualMachineSizeTypesStandardDS13V2', 'VirtualMachineSizeTypesStandardDS14V2', 'VirtualMachineSizeTypesStandardDS15V2', 'VirtualMachineSizeTypesStandardDS134V2', 'VirtualMachineSizeTypesStandardDS132V2', 'VirtualMachineSizeTypesStandardDS148V2', 'VirtualMachineSizeTypesStandardDS144V2', 'VirtualMachineSizeTypesStandardE2V3', 'VirtualMachineSizeTypesStandardE4V3', 'VirtualMachineSizeTypesStandardE8V3', 'VirtualMachineSizeTypesStandardE16V3', 'VirtualMachineSizeTypesStandardE32V3', 'VirtualMachineSizeTypesStandardE64V3', 'VirtualMachineSizeTypesStandardE2sV3', 'VirtualMachineSizeTypesStandardE4sV3', 'VirtualMachineSizeTypesStandardE8sV3', 'VirtualMachineSizeTypesStandardE16sV3', 'VirtualMachineSizeTypesStandardE32sV3', 'VirtualMachineSizeTypesStandardE64sV3', 'VirtualMachineSizeTypesStandardE3216V3', 'VirtualMachineSizeTypesStandardE328sV3', 'VirtualMachineSizeTypesStandardE6432sV3', 'VirtualMachineSizeTypesStandardE6416sV3', 'VirtualMachineSizeTypesStandardF1', 'VirtualMachineSizeTypesStandardF2', 'VirtualMachineSizeTypesStandardF4', 'VirtualMachineSizeTypesStandardF8', 'VirtualMachineSizeTypesStandardF16', 'VirtualMachineSizeTypesStandardF1s', 'VirtualMachineSizeTypesStandardF2s', 'VirtualMachineSizeTypesStandardF4s', 'VirtualMachineSizeTypesStandardF8s', 'VirtualMachineSizeTypesStandardF16s', 'VirtualMachineSizeTypesStandardF2sV2', 'VirtualMachineSizeTypesStandardF4sV2', 'VirtualMachineSizeTypesStandardF8sV2', 'VirtualMachineSizeTypesStandardF16sV2', 'VirtualMachineSizeTypesStandardF32sV2', 'VirtualMachineSizeTypesStandardF64sV2', 'VirtualMachineSizeTypesStandardF72sV2', 'VirtualMachineSizeTypesStandardG1', 'VirtualMachineSizeTypesStandardG2', 'VirtualMachineSizeTypesStandardG3', 'VirtualMachineSizeTypesStandardG4', 'VirtualMachineSizeTypesStandardG5', 'VirtualMachineSizeTypesStandardGS1', 'VirtualMachineSizeTypesStandardGS2', 'VirtualMachineSizeTypesStandardGS3', 'VirtualMachineSizeTypesStandardGS4', 'VirtualMachineSizeTypesStandardGS5', 'VirtualMachineSizeTypesStandardGS48', 'VirtualMachineSizeTypesStandardGS44', 'VirtualMachineSizeTypesStandardGS516', 'VirtualMachineSizeTypesStandardGS58', 'VirtualMachineSizeTypesStandardH8', 'VirtualMachineSizeTypesStandardH16', 'VirtualMachineSizeTypesStandardH8m', 'VirtualMachineSizeTypesStandardH16m', 'VirtualMachineSizeTypesStandardH16r', 'VirtualMachineSizeTypesStandardH16mr', 'VirtualMachineSizeTypesStandardL4s', 'VirtualMachineSizeTypesStandardL8s', 'VirtualMachineSizeTypesStandardL16s', 'VirtualMachineSizeTypesStandardL32s', 'VirtualMachineSizeTypesStandardM64s', 'VirtualMachineSizeTypesStandardM64ms', 'VirtualMachineSizeTypesStandardM128s', 'VirtualMachineSizeTypesStandardM128ms', 'VirtualMachineSizeTypesStandardM6432ms', 'VirtualMachineSizeTypesStandardM6416ms', 'VirtualMachineSizeTypesStandardM12864ms', 'VirtualMachineSizeTypesStandardM12832ms', 'VirtualMachineSizeTypesStandardNC6', 'VirtualMachineSizeTypesStandardNC12', 'VirtualMachineSizeTypesStandardNC24', 'VirtualMachineSizeTypesStandardNC24r', 'VirtualMachineSizeTypesStandardNC6sV2', 'VirtualMachineSizeTypesStandardNC12sV2', 'VirtualMachineSizeTypesStandardNC24sV2', 'VirtualMachineSizeTypesStandardNC24rsV2', 'VirtualMachineSizeTypesStandardNC6sV3', 'VirtualMachineSizeTypesStandardNC12sV3', 'VirtualMachineSizeTypesStandardNC24sV3', 'VirtualMachineSizeTypesStandardNC24rsV3', 'VirtualMachineSizeTypesStandardND6s', 'VirtualMachineSizeTypesStandardND12s', 'VirtualMachineSizeTypesStandardND24s', 'VirtualMachineSizeTypesStandardND24rs', 'VirtualMachineSizeTypesStandardNV6', 'VirtualMachineSizeTypesStandardNV12', 'VirtualMachineSizeTypesStandardNV24'
+ VMSize string `json:"vmSize"`
+}
+
+// NetworkProfileParameters specifies the network interfaces of the virtual machine.
+type NetworkProfileParameters struct {
+ // NetworkInterfaces - Specifies the list of resource Ids for the network interfaces associated with the virtual machine.
+ NetworkInterfaces []*NetworkInterfaceReferenceParameters `json:"networkInterfaces"`
+}
+
+// NetworkInterfaceReferenceParameters describes a network interface reference.
+type NetworkInterfaceReferenceParameters struct {
+ // NetworkInterfaceIDRef is the id of network interface that the cluster will be created in
+ NetworkInterfaceID string `json:"networkInterfaceIDName"`
+
+ // NetworkInterfaceIDRefRef - A reference to a NetworkInterface to retrieve its id
+ NetworkInterfaceIDRef *xpv1.Reference `json:"networkInterfaceIDRef"`
+
+ // NetworkInterfaceIDSelector - Select a reference to a NetworkInterface to retrieve its id
+ NetworkInterfaceIDSelector *xpv1.Selector `json:"networkInterfaceIDSelector"`
+
+ // Primary - Specifies the primary network interface in case the virtual machine has more than 1 network interface.
+ Primary bool `json:"primary,omitempty"`
+}
+
+// VirtualMachineParameters describes a Virtual Machine.
+type VirtualMachineParameters struct {
+ // Location - Resource location
+ Location string `json:"location"`
+ // HardwareProfile - Specifies the hardware settings for the virtual machine.
+ HardwareProfile *HardwareProfileParameters `json:"hardwareProfile"`
+ // StorageProfile - Specifies the storage settings for the virtual machine disks.
+ StorageProfile *StorageProfileParameters `json:"storageProfile"`
+ // OsProfile - Specifies the operating system settings used while creating the virtual machine. Some of the settings cannot be changed once VM is provisioned.
+ OsProfile *OSProfileParameters `json:"osProfile"`
+ // NetworkProfile - Specifies the network interfaces of the virtual machine.
+ NetworkProfile *NetworkProfileParameters `json:"networkProfile"`
+}
+
+// An VirtualMachineSpec defines the desired state of a VirtualMachine.
+type VirtualMachineSpec struct {
+ xpv1.ResourceSpec `json:",inline"`
+
+ // ResourceGroupName is the name of the resource group that the cluster will
+ // be created in
+ ResourceGroupName string `json:"resourceGroupName,omitempty"`
+
+ // ResourceGroupNameRef - A reference to a ResourceGroup to retrieve its
+ // name
+ ResourceGroupNameRef *xpv1.Reference `json:"resourceGroupNameRef,omitempty"`
+
+ // ResourceGroupNameSelector - Select a reference to a ResourceGroup to
+ // retrieve its name
+ ResourceGroupNameSelector *xpv1.Selector `json:"resourceGroupNameSelector,omitempty"`
+
+ VirtualMachineParameters *VirtualMachineParameters `json:"properties"`
+}
+
+// An PrimaryInterfaceStatus represents the observed state of primary interface of VirtualMachine.
+type PrimaryInterfaceStatus struct {
+ Subnet string `json:"subnet"`
+ PublicIPAddress string `json:"publicIPAddress"`
+}
+
+// An VirtualMachineStatus represents the observed state of an VirtualMachine.
+type VirtualMachineStatus struct {
+ xpv1.ResourceStatus `json:",inline"`
+
+ // State is the current state of the cluster.
+ State string `json:"state,omitempty"`
+}
+
+// +kubebuilder:object:root=true
+
+// An VirtualMachine is a managed resource that represents an VirtualMachine
+// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
+// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status"
+// +kubebuilder:printcolumn:name="LOCATION",type="string",JSONPath=".spec.properties.location"
+// +kubebuilder:printcolumn:name="SIZE",type="string",JSONPath=".spec.properties.hardwareProfile.vmSize"
+// +kubebuilder:printcolumn:name="OS_OFFER",type="string",JSONPath=".spec.properties.storageProfile.imageReference.offer"
+// +kubebuilder:printcolumn:name="OS_SKU",type="string",JSONPath=".spec.properties.storageProfile.imageReference.sku"
+// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
+// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,azure}
+// +kubebuilder:subresource:status
+type VirtualMachine struct {
+ metav1.TypeMeta `json:",inline"`
+ metav1.ObjectMeta `json:"metadata,omitempty"`
+
+ Spec VirtualMachineSpec `json:"spec"`
+ Status VirtualMachineStatus `json:"status,omitempty"`
+}
+
+// +kubebuilder:object:root=true
+
+// VirtualMachineList contains a list of VirtualMachine.
+type VirtualMachineList struct {
+ metav1.TypeMeta `json:",inline"`
+ metav1.ListMeta `json:"metadata,omitempty"`
+ Items []VirtualMachine `json:"items"`
+}
diff --git a/apis/compute/v1alpha3/zz_generated.deepcopy.go b/apis/compute/v1alpha3/zz_generated.deepcopy.go
index 50b9a2aa..3246ef64 100644
--- a/apis/compute/v1alpha3/zz_generated.deepcopy.go
+++ b/apis/compute/v1alpha3/zz_generated.deepcopy.go
@@ -156,3 +156,381 @@ func (in *AKSClusterStatus) DeepCopy() *AKSClusterStatus {
in.DeepCopyInto(out)
return out
}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *HardwareProfileParameters) DeepCopyInto(out *HardwareProfileParameters) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HardwareProfileParameters.
+func (in *HardwareProfileParameters) DeepCopy() *HardwareProfileParameters {
+ if in == nil {
+ return nil
+ }
+ out := new(HardwareProfileParameters)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ImageReferenceParameters) DeepCopyInto(out *ImageReferenceParameters) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageReferenceParameters.
+func (in *ImageReferenceParameters) DeepCopy() *ImageReferenceParameters {
+ if in == nil {
+ return nil
+ }
+ out := new(ImageReferenceParameters)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *LinuxConfigurationParameters) DeepCopyInto(out *LinuxConfigurationParameters) {
+ *out = *in
+ if in.SSH != nil {
+ in, out := &in.SSH, &out.SSH
+ *out = new(SSHConfigurationParameters)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LinuxConfigurationParameters.
+func (in *LinuxConfigurationParameters) DeepCopy() *LinuxConfigurationParameters {
+ if in == nil {
+ return nil
+ }
+ out := new(LinuxConfigurationParameters)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *NetworkInterfaceReferenceParameters) DeepCopyInto(out *NetworkInterfaceReferenceParameters) {
+ *out = *in
+ if in.NetworkInterfaceIDRef != nil {
+ in, out := &in.NetworkInterfaceIDRef, &out.NetworkInterfaceIDRef
+ *out = new(v1.Reference)
+ **out = **in
+ }
+ if in.NetworkInterfaceIDSelector != nil {
+ in, out := &in.NetworkInterfaceIDSelector, &out.NetworkInterfaceIDSelector
+ *out = new(v1.Selector)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkInterfaceReferenceParameters.
+func (in *NetworkInterfaceReferenceParameters) DeepCopy() *NetworkInterfaceReferenceParameters {
+ if in == nil {
+ return nil
+ }
+ out := new(NetworkInterfaceReferenceParameters)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *NetworkProfileParameters) DeepCopyInto(out *NetworkProfileParameters) {
+ *out = *in
+ if in.NetworkInterfaces != nil {
+ in, out := &in.NetworkInterfaces, &out.NetworkInterfaces
+ *out = make([]*NetworkInterfaceReferenceParameters, len(*in))
+ for i := range *in {
+ if (*in)[i] != nil {
+ in, out := &(*in)[i], &(*out)[i]
+ *out = new(NetworkInterfaceReferenceParameters)
+ (*in).DeepCopyInto(*out)
+ }
+ }
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkProfileParameters.
+func (in *NetworkProfileParameters) DeepCopy() *NetworkProfileParameters {
+ if in == nil {
+ return nil
+ }
+ out := new(NetworkProfileParameters)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *OSDiskParameters) DeepCopyInto(out *OSDiskParameters) {
+ *out = *in
+ if in.Vhd != nil {
+ in, out := &in.Vhd, &out.Vhd
+ *out = new(VirtualHardDiskParameters)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OSDiskParameters.
+func (in *OSDiskParameters) DeepCopy() *OSDiskParameters {
+ if in == nil {
+ return nil
+ }
+ out := new(OSDiskParameters)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *OSProfileParameters) DeepCopyInto(out *OSProfileParameters) {
+ *out = *in
+ if in.LinuxConfiguration != nil {
+ in, out := &in.LinuxConfiguration, &out.LinuxConfiguration
+ *out = new(LinuxConfigurationParameters)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OSProfileParameters.
+func (in *OSProfileParameters) DeepCopy() *OSProfileParameters {
+ if in == nil {
+ return nil
+ }
+ out := new(OSProfileParameters)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *PrimaryInterfaceStatus) DeepCopyInto(out *PrimaryInterfaceStatus) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrimaryInterfaceStatus.
+func (in *PrimaryInterfaceStatus) DeepCopy() *PrimaryInterfaceStatus {
+ if in == nil {
+ return nil
+ }
+ out := new(PrimaryInterfaceStatus)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *SSHConfigurationParameters) DeepCopyInto(out *SSHConfigurationParameters) {
+ *out = *in
+ if in.PublicKeys != nil {
+ in, out := &in.PublicKeys, &out.PublicKeys
+ *out = make([]*SSHPublicKey, len(*in))
+ for i := range *in {
+ if (*in)[i] != nil {
+ in, out := &(*in)[i], &(*out)[i]
+ *out = new(SSHPublicKey)
+ **out = **in
+ }
+ }
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SSHConfigurationParameters.
+func (in *SSHConfigurationParameters) DeepCopy() *SSHConfigurationParameters {
+ if in == nil {
+ return nil
+ }
+ out := new(SSHConfigurationParameters)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *SSHPublicKey) DeepCopyInto(out *SSHPublicKey) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SSHPublicKey.
+func (in *SSHPublicKey) DeepCopy() *SSHPublicKey {
+ if in == nil {
+ return nil
+ }
+ out := new(SSHPublicKey)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *StorageProfileParameters) DeepCopyInto(out *StorageProfileParameters) {
+ *out = *in
+ if in.ImageReference != nil {
+ in, out := &in.ImageReference, &out.ImageReference
+ *out = new(ImageReferenceParameters)
+ **out = **in
+ }
+ if in.OsDisk != nil {
+ in, out := &in.OsDisk, &out.OsDisk
+ *out = new(OSDiskParameters)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageProfileParameters.
+func (in *StorageProfileParameters) DeepCopy() *StorageProfileParameters {
+ if in == nil {
+ return nil
+ }
+ out := new(StorageProfileParameters)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *VirtualHardDiskParameters) DeepCopyInto(out *VirtualHardDiskParameters) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualHardDiskParameters.
+func (in *VirtualHardDiskParameters) DeepCopy() *VirtualHardDiskParameters {
+ if in == nil {
+ return nil
+ }
+ out := new(VirtualHardDiskParameters)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *VirtualMachine) DeepCopyInto(out *VirtualMachine) {
+ *out = *in
+ out.TypeMeta = in.TypeMeta
+ in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
+ in.Spec.DeepCopyInto(&out.Spec)
+ in.Status.DeepCopyInto(&out.Status)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachine.
+func (in *VirtualMachine) DeepCopy() *VirtualMachine {
+ if in == nil {
+ return nil
+ }
+ out := new(VirtualMachine)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
+func (in *VirtualMachine) DeepCopyObject() runtime.Object {
+ if c := in.DeepCopy(); c != nil {
+ return c
+ }
+ return nil
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *VirtualMachineList) DeepCopyInto(out *VirtualMachineList) {
+ *out = *in
+ out.TypeMeta = in.TypeMeta
+ in.ListMeta.DeepCopyInto(&out.ListMeta)
+ if in.Items != nil {
+ in, out := &in.Items, &out.Items
+ *out = make([]VirtualMachine, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineList.
+func (in *VirtualMachineList) DeepCopy() *VirtualMachineList {
+ if in == nil {
+ return nil
+ }
+ out := new(VirtualMachineList)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
+func (in *VirtualMachineList) DeepCopyObject() runtime.Object {
+ if c := in.DeepCopy(); c != nil {
+ return c
+ }
+ return nil
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *VirtualMachineParameters) DeepCopyInto(out *VirtualMachineParameters) {
+ *out = *in
+ if in.HardwareProfile != nil {
+ in, out := &in.HardwareProfile, &out.HardwareProfile
+ *out = new(HardwareProfileParameters)
+ **out = **in
+ }
+ if in.StorageProfile != nil {
+ in, out := &in.StorageProfile, &out.StorageProfile
+ *out = new(StorageProfileParameters)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.OsProfile != nil {
+ in, out := &in.OsProfile, &out.OsProfile
+ *out = new(OSProfileParameters)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.NetworkProfile != nil {
+ in, out := &in.NetworkProfile, &out.NetworkProfile
+ *out = new(NetworkProfileParameters)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineParameters.
+func (in *VirtualMachineParameters) DeepCopy() *VirtualMachineParameters {
+ if in == nil {
+ return nil
+ }
+ out := new(VirtualMachineParameters)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *VirtualMachineSpec) DeepCopyInto(out *VirtualMachineSpec) {
+ *out = *in
+ in.ResourceSpec.DeepCopyInto(&out.ResourceSpec)
+ if in.ResourceGroupNameRef != nil {
+ in, out := &in.ResourceGroupNameRef, &out.ResourceGroupNameRef
+ *out = new(v1.Reference)
+ **out = **in
+ }
+ if in.ResourceGroupNameSelector != nil {
+ in, out := &in.ResourceGroupNameSelector, &out.ResourceGroupNameSelector
+ *out = new(v1.Selector)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.VirtualMachineParameters != nil {
+ in, out := &in.VirtualMachineParameters, &out.VirtualMachineParameters
+ *out = new(VirtualMachineParameters)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineSpec.
+func (in *VirtualMachineSpec) DeepCopy() *VirtualMachineSpec {
+ if in == nil {
+ return nil
+ }
+ out := new(VirtualMachineSpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *VirtualMachineStatus) DeepCopyInto(out *VirtualMachineStatus) {
+ *out = *in
+ in.ResourceStatus.DeepCopyInto(&out.ResourceStatus)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineStatus.
+func (in *VirtualMachineStatus) DeepCopy() *VirtualMachineStatus {
+ if in == nil {
+ return nil
+ }
+ out := new(VirtualMachineStatus)
+ in.DeepCopyInto(out)
+ return out
+}
diff --git a/apis/compute/v1alpha3/zz_generated.managed.go b/apis/compute/v1alpha3/zz_generated.managed.go
index c1d87c60..57cc3372 100644
--- a/apis/compute/v1alpha3/zz_generated.managed.go
+++ b/apis/compute/v1alpha3/zz_generated.managed.go
@@ -75,3 +75,59 @@ func (mg *AKSCluster) SetProviderReference(r *xpv1.Reference) {
func (mg *AKSCluster) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) {
mg.Spec.WriteConnectionSecretToReference = r
}
+
+// GetCondition of this VirtualMachine.
+func (mg *VirtualMachine) GetCondition(ct xpv1.ConditionType) xpv1.Condition {
+ return mg.Status.GetCondition(ct)
+}
+
+// GetDeletionPolicy of this VirtualMachine.
+func (mg *VirtualMachine) GetDeletionPolicy() xpv1.DeletionPolicy {
+ return mg.Spec.DeletionPolicy
+}
+
+// GetProviderConfigReference of this VirtualMachine.
+func (mg *VirtualMachine) GetProviderConfigReference() *xpv1.Reference {
+ return mg.Spec.ProviderConfigReference
+}
+
+/*
+GetProviderReference of this VirtualMachine.
+Deprecated: Use GetProviderConfigReference.
+*/
+func (mg *VirtualMachine) GetProviderReference() *xpv1.Reference {
+ return mg.Spec.ProviderReference
+}
+
+// GetWriteConnectionSecretToReference of this VirtualMachine.
+func (mg *VirtualMachine) GetWriteConnectionSecretToReference() *xpv1.SecretReference {
+ return mg.Spec.WriteConnectionSecretToReference
+}
+
+// SetConditions of this VirtualMachine.
+func (mg *VirtualMachine) SetConditions(c ...xpv1.Condition) {
+ mg.Status.SetConditions(c...)
+}
+
+// SetDeletionPolicy of this VirtualMachine.
+func (mg *VirtualMachine) SetDeletionPolicy(r xpv1.DeletionPolicy) {
+ mg.Spec.DeletionPolicy = r
+}
+
+// SetProviderConfigReference of this VirtualMachine.
+func (mg *VirtualMachine) SetProviderConfigReference(r *xpv1.Reference) {
+ mg.Spec.ProviderConfigReference = r
+}
+
+/*
+SetProviderReference of this VirtualMachine.
+Deprecated: Use SetProviderConfigReference.
+*/
+func (mg *VirtualMachine) SetProviderReference(r *xpv1.Reference) {
+ mg.Spec.ProviderReference = r
+}
+
+// SetWriteConnectionSecretToReference of this VirtualMachine.
+func (mg *VirtualMachine) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) {
+ mg.Spec.WriteConnectionSecretToReference = r
+}
diff --git a/apis/compute/v1alpha3/zz_generated.managedlist.go b/apis/compute/v1alpha3/zz_generated.managedlist.go
index d9641758..ea337835 100644
--- a/apis/compute/v1alpha3/zz_generated.managedlist.go
+++ b/apis/compute/v1alpha3/zz_generated.managedlist.go
@@ -28,3 +28,12 @@ func (l *AKSClusterList) GetItems() []resource.Managed {
}
return items
}
+
+// GetItems of this VirtualMachineList.
+func (l *VirtualMachineList) GetItems() []resource.Managed {
+ items := make([]resource.Managed, len(l.Items))
+ for i := range l.Items {
+ items[i] = &l.Items[i]
+ }
+ return items
+}
diff --git a/apis/network/v1alpha3/referencers.go b/apis/network/v1alpha3/referencers.go
index 0907b29d..c7589517 100644
--- a/apis/network/v1alpha3/referencers.go
+++ b/apis/network/v1alpha3/referencers.go
@@ -40,6 +40,18 @@ func SubnetID() reference.ExtractValueFn {
}
}
+// NetworkInterfaceID extracts status.ID from the supplied managed resource, which must be
+// a NetworkInterface.
+func NetworkInterfaceID() reference.ExtractValueFn {
+ return func(mg resource.Managed) string {
+ s, ok := mg.(*NetworkInterface)
+ if !ok {
+ return ""
+ }
+ return s.Status.ID
+ }
+}
+
// PublicIPAddressID extracts status.ID from the supplied managed resource, which must be
// a PublicIPAddress.
func PublicIPAddressID() reference.ExtractValueFn {
diff --git a/examples/compute/virtualmachine.yaml b/examples/compute/virtualmachine.yaml
new file mode 100644
index 00000000..946f8d8c
--- /dev/null
+++ b/examples/compute/virtualmachine.yaml
@@ -0,0 +1,32 @@
+apiVersion: compute.azure.crossplane.io/v1alpha3
+kind: VirtualMachine
+metadata:
+ name: example-vm
+spec:
+ resourceGroupNameRef:
+ name: example-rg
+ providerConfigRef:
+ name: example
+ properties:
+ location: West US 2
+ hardwareProfile:
+ vmSize: Standard_B1s
+ storageProfile:
+ imageReference:
+ publisher: Canonical
+ offer: UbuntuServer
+ sku: 16.04-LTS
+ version: latest
+ osProfile:
+ computerName: example-vm
+ adminUsername: exampleuser
+ adminPassword: exAmpl2-user
+ linuxConfiguration:
+ ssh:
+ publicKeys:
+ - path: /home/exampleuser/.ssh/authorized_keys
+ keyData: SSH_KEY
+ networkProfile:
+ networkInterfaces:
+ - networkInterfaceIDRef:
+ name: example-network-interface
diff --git a/package/crds/compute.azure.crossplane.io_virtualmachines.yaml b/package/crds/compute.azure.crossplane.io_virtualmachines.yaml
new file mode 100644
index 00000000..bbbc8d73
--- /dev/null
+++ b/package/crds/compute.azure.crossplane.io_virtualmachines.yaml
@@ -0,0 +1,326 @@
+apiVersion: apiextensions.k8s.io/v1
+kind: CustomResourceDefinition
+metadata:
+ annotations:
+ controller-gen.kubebuilder.io/version: v0.4.0
+ creationTimestamp: null
+ name: virtualmachines.compute.azure.crossplane.io
+spec:
+ group: compute.azure.crossplane.io
+ names:
+ categories:
+ - crossplane
+ - managed
+ - azure
+ kind: VirtualMachine
+ listKind: VirtualMachineList
+ plural: virtualmachines
+ singular: virtualmachine
+ scope: Cluster
+ versions:
+ - additionalPrinterColumns:
+ - jsonPath: .status.conditions[?(@.type=='Ready')].status
+ name: READY
+ type: string
+ - jsonPath: .status.conditions[?(@.type=='Synced')].status
+ name: SYNCED
+ type: string
+ - jsonPath: .spec.properties.location
+ name: LOCATION
+ type: string
+ - jsonPath: .spec.properties.hardwareProfile.vmSize
+ name: SIZE
+ type: string
+ - jsonPath: .spec.properties.storageProfile.imageReference.offer
+ name: OS_OFFER
+ type: string
+ - jsonPath: .spec.properties.storageProfile.imageReference.sku
+ name: OS_SKU
+ type: string
+ - jsonPath: .metadata.creationTimestamp
+ name: AGE
+ type: date
+ name: v1alpha3
+ schema:
+ openAPIV3Schema:
+ description: An VirtualMachine is a managed resource that represents an VirtualMachine
+ properties:
+ apiVersion:
+ description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
+ type: string
+ kind:
+ description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
+ type: string
+ metadata:
+ type: object
+ spec:
+ description: An VirtualMachineSpec defines the desired state of a VirtualMachine.
+ properties:
+ deletionPolicy:
+ description: DeletionPolicy specifies what will happen to the underlying external when this managed resource is deleted - either "Delete" or "Orphan" the external resource. The "Delete" policy is the default when no policy is specified.
+ enum:
+ - Orphan
+ - Delete
+ type: string
+ properties:
+ description: VirtualMachineParameters describes a Virtual Machine.
+ properties:
+ hardwareProfile:
+ description: HardwareProfile - Specifies the hardware settings for the virtual machine.
+ properties:
+ vmSize:
+ description: 'VMSize - Specifies the size of the virtual machine. For more information about virtual machine sizes, see [Sizes for virtual machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-sizes?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json).
The available VM sizes depend on region and availability set. For a list of available sizes use these APIs:
[List all available virtual machine sizes in an availability set](https://docs.microsoft.com/rest/api/compute/availabilitysets/listavailablesizes)
[List all available virtual machine sizes in a region](https://docs.microsoft.com/rest/api/compute/virtualmachinesizes/list)
[List all available virtual machine sizes for resizing](https://docs.microsoft.com/rest/api/compute/virtualmachines/listavailablesizes). Possible values include: ''VirtualMachineSizeTypesBasicA0'', ''VirtualMachineSizeTypesBasicA1'', ''VirtualMachineSizeTypesBasicA2'', ''VirtualMachineSizeTypesBasicA3'', ''VirtualMachineSizeTypesBasicA4'', ''VirtualMachineSizeTypesStandardA0'', ''VirtualMachineSizeTypesStandardA1'', ''VirtualMachineSizeTypesStandardA2'', ''VirtualMachineSizeTypesStandardA3'', ''VirtualMachineSizeTypesStandardA4'', ''VirtualMachineSizeTypesStandardA5'', ''VirtualMachineSizeTypesStandardA6'', ''VirtualMachineSizeTypesStandardA7'', ''VirtualMachineSizeTypesStandardA8'', ''VirtualMachineSizeTypesStandardA9'', ''VirtualMachineSizeTypesStandardA10'', ''VirtualMachineSizeTypesStandardA11'', ''VirtualMachineSizeTypesStandardA1V2'', ''VirtualMachineSizeTypesStandardA2V2'', ''VirtualMachineSizeTypesStandardA4V2'', ''VirtualMachineSizeTypesStandardA8V2'', ''VirtualMachineSizeTypesStandardA2mV2'', ''VirtualMachineSizeTypesStandardA4mV2'', ''VirtualMachineSizeTypesStandardA8mV2'', ''VirtualMachineSizeTypesStandardB1s'', ''VirtualMachineSizeTypesStandardB1ms'', ''VirtualMachineSizeTypesStandardB2s'', ''VirtualMachineSizeTypesStandardB2ms'', ''VirtualMachineSizeTypesStandardB4ms'', ''VirtualMachineSizeTypesStandardB8ms'', ''VirtualMachineSizeTypesStandardD1'', ''VirtualMachineSizeTypesStandardD2'', ''VirtualMachineSizeTypesStandardD3'', ''VirtualMachineSizeTypesStandardD4'', ''VirtualMachineSizeTypesStandardD11'', ''VirtualMachineSizeTypesStandardD12'', ''VirtualMachineSizeTypesStandardD13'', ''VirtualMachineSizeTypesStandardD14'', ''VirtualMachineSizeTypesStandardD1V2'', ''VirtualMachineSizeTypesStandardD2V2'', ''VirtualMachineSizeTypesStandardD3V2'', ''VirtualMachineSizeTypesStandardD4V2'', ''VirtualMachineSizeTypesStandardD5V2'', ''VirtualMachineSizeTypesStandardD2V3'', ''VirtualMachineSizeTypesStandardD4V3'', ''VirtualMachineSizeTypesStandardD8V3'', ''VirtualMachineSizeTypesStandardD16V3'', ''VirtualMachineSizeTypesStandardD32V3'', ''VirtualMachineSizeTypesStandardD64V3'', ''VirtualMachineSizeTypesStandardD2sV3'', ''VirtualMachineSizeTypesStandardD4sV3'', ''VirtualMachineSizeTypesStandardD8sV3'', ''VirtualMachineSizeTypesStandardD16sV3'', ''VirtualMachineSizeTypesStandardD32sV3'', ''VirtualMachineSizeTypesStandardD64sV3'', ''VirtualMachineSizeTypesStandardD11V2'', ''VirtualMachineSizeTypesStandardD12V2'', ''VirtualMachineSizeTypesStandardD13V2'', ''VirtualMachineSizeTypesStandardD14V2'', ''VirtualMachineSizeTypesStandardD15V2'', ''VirtualMachineSizeTypesStandardDS1'', ''VirtualMachineSizeTypesStandardDS2'', ''VirtualMachineSizeTypesStandardDS3'', ''VirtualMachineSizeTypesStandardDS4'', ''VirtualMachineSizeTypesStandardDS11'', ''VirtualMachineSizeTypesStandardDS12'', ''VirtualMachineSizeTypesStandardDS13'', ''VirtualMachineSizeTypesStandardDS14'', ''VirtualMachineSizeTypesStandardDS1V2'', ''VirtualMachineSizeTypesStandardDS2V2'', ''VirtualMachineSizeTypesStandardDS3V2'', ''VirtualMachineSizeTypesStandardDS4V2'', ''VirtualMachineSizeTypesStandardDS5V2'', ''VirtualMachineSizeTypesStandardDS11V2'', ''VirtualMachineSizeTypesStandardDS12V2'', ''VirtualMachineSizeTypesStandardDS13V2'', ''VirtualMachineSizeTypesStandardDS14V2'', ''VirtualMachineSizeTypesStandardDS15V2'', ''VirtualMachineSizeTypesStandardDS134V2'', ''VirtualMachineSizeTypesStandardDS132V2'', ''VirtualMachineSizeTypesStandardDS148V2'', ''VirtualMachineSizeTypesStandardDS144V2'', ''VirtualMachineSizeTypesStandardE2V3'', ''VirtualMachineSizeTypesStandardE4V3'', ''VirtualMachineSizeTypesStandardE8V3'', ''VirtualMachineSizeTypesStandardE16V3'', ''VirtualMachineSizeTypesStandardE32V3'', ''VirtualMachineSizeTypesStandardE64V3'', ''VirtualMachineSizeTypesStandardE2sV3'', ''VirtualMachineSizeTypesStandardE4sV3'', ''VirtualMachineSizeTypesStandardE8sV3'', ''VirtualMachineSizeTypesStandardE16sV3'', ''VirtualMachineSizeTypesStandardE32sV3'', ''VirtualMachineSizeTypesStandardE64sV3'', ''VirtualMachineSizeTypesStandardE3216V3'', ''VirtualMachineSizeTypesStandardE328sV3'', ''VirtualMachineSizeTypesStandardE6432sV3'', ''VirtualMachineSizeTypesStandardE6416sV3'', ''VirtualMachineSizeTypesStandardF1'', ''VirtualMachineSizeTypesStandardF2'', ''VirtualMachineSizeTypesStandardF4'', ''VirtualMachineSizeTypesStandardF8'', ''VirtualMachineSizeTypesStandardF16'', ''VirtualMachineSizeTypesStandardF1s'', ''VirtualMachineSizeTypesStandardF2s'', ''VirtualMachineSizeTypesStandardF4s'', ''VirtualMachineSizeTypesStandardF8s'', ''VirtualMachineSizeTypesStandardF16s'', ''VirtualMachineSizeTypesStandardF2sV2'', ''VirtualMachineSizeTypesStandardF4sV2'', ''VirtualMachineSizeTypesStandardF8sV2'', ''VirtualMachineSizeTypesStandardF16sV2'', ''VirtualMachineSizeTypesStandardF32sV2'', ''VirtualMachineSizeTypesStandardF64sV2'', ''VirtualMachineSizeTypesStandardF72sV2'', ''VirtualMachineSizeTypesStandardG1'', ''VirtualMachineSizeTypesStandardG2'', ''VirtualMachineSizeTypesStandardG3'', ''VirtualMachineSizeTypesStandardG4'', ''VirtualMachineSizeTypesStandardG5'', ''VirtualMachineSizeTypesStandardGS1'', ''VirtualMachineSizeTypesStandardGS2'', ''VirtualMachineSizeTypesStandardGS3'', ''VirtualMachineSizeTypesStandardGS4'', ''VirtualMachineSizeTypesStandardGS5'', ''VirtualMachineSizeTypesStandardGS48'', ''VirtualMachineSizeTypesStandardGS44'', ''VirtualMachineSizeTypesStandardGS516'', ''VirtualMachineSizeTypesStandardGS58'', ''VirtualMachineSizeTypesStandardH8'', ''VirtualMachineSizeTypesStandardH16'', ''VirtualMachineSizeTypesStandardH8m'', ''VirtualMachineSizeTypesStandardH16m'', ''VirtualMachineSizeTypesStandardH16r'', ''VirtualMachineSizeTypesStandardH16mr'', ''VirtualMachineSizeTypesStandardL4s'', ''VirtualMachineSizeTypesStandardL8s'', ''VirtualMachineSizeTypesStandardL16s'', ''VirtualMachineSizeTypesStandardL32s'', ''VirtualMachineSizeTypesStandardM64s'', ''VirtualMachineSizeTypesStandardM64ms'', ''VirtualMachineSizeTypesStandardM128s'', ''VirtualMachineSizeTypesStandardM128ms'', ''VirtualMachineSizeTypesStandardM6432ms'', ''VirtualMachineSizeTypesStandardM6416ms'', ''VirtualMachineSizeTypesStandardM12864ms'', ''VirtualMachineSizeTypesStandardM12832ms'', ''VirtualMachineSizeTypesStandardNC6'', ''VirtualMachineSizeTypesStandardNC12'', ''VirtualMachineSizeTypesStandardNC24'', ''VirtualMachineSizeTypesStandardNC24r'', ''VirtualMachineSizeTypesStandardNC6sV2'', ''VirtualMachineSizeTypesStandardNC12sV2'', ''VirtualMachineSizeTypesStandardNC24sV2'', ''VirtualMachineSizeTypesStandardNC24rsV2'', ''VirtualMachineSizeTypesStandardNC6sV3'', ''VirtualMachineSizeTypesStandardNC12sV3'', ''VirtualMachineSizeTypesStandardNC24sV3'', ''VirtualMachineSizeTypesStandardNC24rsV3'', ''VirtualMachineSizeTypesStandardND6s'', ''VirtualMachineSizeTypesStandardND12s'', ''VirtualMachineSizeTypesStandardND24s'', ''VirtualMachineSizeTypesStandardND24rs'', ''VirtualMachineSizeTypesStandardNV6'', ''VirtualMachineSizeTypesStandardNV12'', ''VirtualMachineSizeTypesStandardNV24'''
+ type: string
+ required:
+ - vmSize
+ type: object
+ location:
+ description: Location - Resource location
+ type: string
+ networkProfile:
+ description: NetworkProfile - Specifies the network interfaces of the virtual machine.
+ properties:
+ networkInterfaces:
+ description: NetworkInterfaces - Specifies the list of resource Ids for the network interfaces associated with the virtual machine.
+ items:
+ description: NetworkInterfaceReferenceParameters describes a network interface reference.
+ properties:
+ networkInterfaceIDName:
+ description: NetworkInterfaceIDRef is the id of network interface that the cluster will be created in
+ type: string
+ networkInterfaceIDRef:
+ description: NetworkInterfaceIDRefRef - A reference to a NetworkInterface to retrieve its id
+ properties:
+ name:
+ description: Name of the referenced object.
+ type: string
+ required:
+ - name
+ type: object
+ networkInterfaceIDSelector:
+ description: NetworkInterfaceIDSelector - Select a reference to a NetworkInterface to retrieve its id
+ properties:
+ matchControllerRef:
+ description: MatchControllerRef ensures an object with the same controller reference as the selecting object is selected.
+ type: boolean
+ matchLabels:
+ additionalProperties:
+ type: string
+ description: MatchLabels ensures an object with matching labels is selected.
+ type: object
+ type: object
+ primary:
+ description: Primary - Specifies the primary network interface in case the virtual machine has more than 1 network interface.
+ type: boolean
+ required:
+ - networkInterfaceIDName
+ - networkInterfaceIDRef
+ - networkInterfaceIDSelector
+ type: object
+ type: array
+ required:
+ - networkInterfaces
+ type: object
+ osProfile:
+ description: OsProfile - Specifies the operating system settings used while creating the virtual machine. Some of the settings cannot be changed once VM is provisioned.
+ properties:
+ adminPassword:
+ description: AdminPassword - Specifies the password of the administrator account.
**Minimum-length (Windows):** 8 characters
**Minimum-length (Linux):** 6 characters
**Max-length (Windows):** 123 characters
**Max-length (Linux):** 72 characters
**Complexity requirements:** 3 out of 4 conditions below need to be fulfilled
Has lower characters
Has upper characters
Has a digit
Has a special character (Regex match [\W_])
**Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", "pass@word1", "Password!", "Password1", "Password22", "iloveyou!"
For resetting the password, see [How to reset the Remote Desktop service or its login password in a Windows VM](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-reset-rdp?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json)
For resetting root password, see [Manage users, SSH, and check or repair disks on Azure Linux VMs using the VMAccess Extension](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-using-vmaccess-extension?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json#reset-root-password)
+ type: string
+ adminUsername:
+ description: AdminUsername - Specifies the name of the administrator account.
This property cannot be updated after the VM is created.
**Windows-only restriction:** Cannot end in "."
**Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5".
**Minimum-length (Linux):** 1 character
**Max-length (Linux):** 64 characters
**Max-length (Windows):** 20 characters
For root access to the Linux VM, see [Using root privileges on Linux virtual machines in Azure](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-use-root-privileges?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)
For a list of built-in system users on Linux that should not be used in this field, see [Selecting User Names for Linux on Azure](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-usernames?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)
+ type: string
+ computerName:
+ description: ComputerName - Specifies the host OS name of the virtual machine.
This name cannot be updated after the VM is created.
**Max-length (Windows):** 15 characters
**Max-length (Linux):** 64 characters.
For naming conventions and restrictions see [Azure infrastructure services implementation guidelines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-infrastructure-subscription-accounts-guidelines?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json#1-naming-conventions).
+ type: string
+ linuxConfiguration:
+ description: LinuxConfiguration - Specifies the Linux operating system settings on the virtual machine.
For a list of supported Linux distributions, see [Linux on Azure-Endorsed Distributions](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-endorsed-distros?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)
For running non-endorsed distributions, see [Information for Non-Endorsed Distributions](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-create-upload-generic?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
+ properties:
+ ssh:
+ description: SSH - Specifies the ssh key configuration for a Linux OS.
+ properties:
+ publicKeys:
+ description: PublicKeys - The list of SSH public keys used to authenticate with linux based VMs.
+ items:
+ description: SSHPublicKey contains information about SSH certificate public key and the path on the Linux VM where the public key is placed.
+ properties:
+ keyData:
+ description: KeyData - SSH public key certificate used to authenticate with the VM through ssh. The key needs to be at least 2048-bit and in ssh-rsa format.
For creating ssh keys, see [Create SSH keys on Linux and Mac for Linux VMs in Azure](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-mac-create-ssh-keys?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
+ type: string
+ path:
+ description: 'Path - Specifies the full path on the created VM where ssh public key is stored. If the file already exists, the specified key is appended to the file. Example: /home/user/.ssh/authorized_keys'
+ type: string
+ required:
+ - keyData
+ - path
+ type: object
+ type: array
+ required:
+ - publicKeys
+ type: object
+ required:
+ - ssh
+ type: object
+ required:
+ - adminPassword
+ - adminUsername
+ - computerName
+ - linuxConfiguration
+ type: object
+ storageProfile:
+ description: StorageProfile - Specifies the storage settings for the virtual machine disks.
+ properties:
+ imageReference:
+ description: ImageReference - Specifies information about the image to use. You can specify information about platform images, marketplace images, or virtual machine images. This element is required when you want to use a platform image, marketplace image, or virtual machine image, but is not used in other creation operations.
+ properties:
+ offer:
+ description: Offer - Specifies the offer of the platform image or marketplace image used to create the virtual machine.
+ type: string
+ publisher:
+ description: Publisher - The image publisher.
+ type: string
+ sku:
+ description: Sku - The image SKU.
+ type: string
+ version:
+ description: Version - Specifies the version of the platform image or marketplace image used to create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image available at deploy time. Even if you use 'latest', the VM image will not automatically update after deploy time even if a new version becomes available.
+ type: string
+ required:
+ - offer
+ - publisher
+ - sku
+ - version
+ type: object
+ osDisk:
+ description: OsDisk - Specifies information about the operating system disk used by the virtual machine.
For more information about disks, see [About disks and VHDs for Azure virtual machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-about-disks-vhds?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json).
+ properties:
+ name:
+ description: Name - The disk name.
+ type: string
+ vhd:
+ description: Vhd - The virtual hard disk.
+ properties:
+ uri:
+ description: URI - Specifies the virtual hard disk's uri.
+ type: string
+ type: object
+ required:
+ - name
+ - vhd
+ type: object
+ required:
+ - imageReference
+ type: object
+ required:
+ - hardwareProfile
+ - location
+ - networkProfile
+ - osProfile
+ - storageProfile
+ type: object
+ providerConfigRef:
+ description: ProviderConfigReference specifies how the provider that will be used to create, observe, update, and delete this managed resource should be configured.
+ properties:
+ name:
+ description: Name of the referenced object.
+ type: string
+ required:
+ - name
+ type: object
+ providerRef:
+ description: 'ProviderReference specifies the provider that will be used to create, observe, update, and delete this managed resource. Deprecated: Please use ProviderConfigReference, i.e. `providerConfigRef`'
+ properties:
+ name:
+ description: Name of the referenced object.
+ type: string
+ required:
+ - name
+ type: object
+ resourceGroupName:
+ description: ResourceGroupName is the name of the resource group that the cluster will be created in
+ type: string
+ resourceGroupNameRef:
+ description: ResourceGroupNameRef - A reference to a ResourceGroup to retrieve its name
+ properties:
+ name:
+ description: Name of the referenced object.
+ type: string
+ required:
+ - name
+ type: object
+ resourceGroupNameSelector:
+ description: ResourceGroupNameSelector - Select a reference to a ResourceGroup to retrieve its name
+ properties:
+ matchControllerRef:
+ description: MatchControllerRef ensures an object with the same controller reference as the selecting object is selected.
+ type: boolean
+ matchLabels:
+ additionalProperties:
+ type: string
+ description: MatchLabels ensures an object with matching labels is selected.
+ type: object
+ type: object
+ writeConnectionSecretToRef:
+ description: WriteConnectionSecretToReference specifies the namespace and name of a Secret to which any connection details for this managed resource should be written. Connection details frequently include the endpoint, username, and password required to connect to the managed resource.
+ properties:
+ name:
+ description: Name of the secret.
+ type: string
+ namespace:
+ description: Namespace of the secret.
+ type: string
+ required:
+ - name
+ - namespace
+ type: object
+ required:
+ - properties
+ type: object
+ status:
+ description: An VirtualMachineStatus represents the observed state of an VirtualMachine.
+ properties:
+ conditions:
+ description: Conditions of the resource.
+ items:
+ description: A Condition that may apply to a resource.
+ properties:
+ lastTransitionTime:
+ description: LastTransitionTime is the last time this condition transitioned from one status to another.
+ format: date-time
+ type: string
+ message:
+ description: A Message containing details about this condition's last transition from one status to another, if any.
+ type: string
+ reason:
+ description: A Reason for this condition's last transition from one status to another.
+ type: string
+ status:
+ description: Status of this condition; is it currently True, False, or Unknown?
+ type: string
+ type:
+ description: Type of this condition. At most one of each condition type may apply to a resource at any point in time.
+ type: string
+ required:
+ - lastTransitionTime
+ - reason
+ - status
+ - type
+ type: object
+ type: array
+ state:
+ description: State is the current state of the cluster.
+ type: string
+ type: object
+ required:
+ - spec
+ type: object
+ served: true
+ storage: true
+ subresources:
+ status: {}
+status:
+ acceptedNames:
+ kind: ""
+ plural: ""
+ conditions: []
+ storedVersions: []
diff --git a/pkg/clients/compute/fake/fake.go b/pkg/clients/compute/fake/fake.go
index 5f23a694..752291c5 100644
--- a/pkg/clients/compute/fake/fake.go
+++ b/pkg/clients/compute/fake/fake.go
@@ -19,6 +19,8 @@ package fake
import (
"context"
+ "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
+ "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute/computeapi"
"github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2018-03-31/containerservice"
"github.com/crossplane/provider-azure/apis/compute/v1alpha3"
@@ -51,3 +53,28 @@ func (c AKSClient) DeleteManagedCluster(ctx context.Context, ac *v1alpha3.AKSClu
func (c AKSClient) GetKubeConfig(ctx context.Context, ac *v1alpha3.AKSCluster) ([]byte, error) {
return c.MockGetKubeConfig(ctx, ac)
}
+
+var _ computeapi.VirtualMachinesClientAPI = &VirtualMachineClient{}
+
+// VirtualMachineClient is a fake VirtualMachine client.
+type VirtualMachineClient struct {
+ computeapi.VirtualMachinesClientAPI
+ MockCreateOrUpdate func(ctx context.Context, resourceGroupName string, vmName string, parameters compute.VirtualMachine) (result compute.VirtualMachinesCreateOrUpdateFuture, err error)
+ MockDelete func(ctx context.Context, resourceGroupName string, vmName string) (result compute.VirtualMachinesDeleteFuture, err error)
+ MockGet func(ctx context.Context, resourceGroupName string, vmName string, expand compute.InstanceViewTypes) (result compute.VirtualMachine, err error)
+}
+
+// CreateOrUpdate calls MockCreateOrUpdate.
+func (c *VirtualMachineClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, vmName string, parameters compute.VirtualMachine) (result compute.VirtualMachinesCreateOrUpdateFuture, err error) {
+ return c.MockCreateOrUpdate(ctx, resourceGroupName, vmName, parameters)
+}
+
+// Delete calls MockDelete.
+func (c *VirtualMachineClient) Delete(ctx context.Context, resourceGroupName string, vmName string) (result compute.VirtualMachinesDeleteFuture, err error) {
+ return c.MockDelete(ctx, resourceGroupName, vmName)
+}
+
+// Get calls MockGet.
+func (c *VirtualMachineClient) Get(ctx context.Context, resourceGroupName string, vmName string, expand compute.InstanceViewTypes) (result compute.VirtualMachine, err error) {
+ return c.MockGet(ctx, resourceGroupName, vmName, expand)
+}
diff --git a/pkg/clients/compute/vm.go b/pkg/clients/compute/vm.go
new file mode 100644
index 00000000..5447869f
--- /dev/null
+++ b/pkg/clients/compute/vm.go
@@ -0,0 +1,128 @@
+/*
+Copyright 2021 The Crossplane Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the c.Specific language governing permissions and
+limitations under the License.
+*/
+
+package compute
+
+import (
+ "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
+ "github.com/Azure/go-autorest/autorest/to"
+
+ "github.com/crossplane/provider-azure/apis/compute/v1alpha3"
+ azure "github.com/crossplane/provider-azure/pkg/clients"
+)
+
+// NewStorageProfileParameters converts to Azure StorageProfile
+func NewStorageProfileParameters(profile *v1alpha3.StorageProfileParameters) *compute.StorageProfile {
+ return &compute.StorageProfile{
+ ImageReference: NewImageParameters(profile.ImageReference),
+ OsDisk: NewOSDiskParameters(profile.OsDisk),
+ }
+}
+
+// NewImageParameters converts to Azure ImageReference
+func NewImageParameters(img *v1alpha3.ImageReferenceParameters) *compute.ImageReference {
+ return &compute.ImageReference{
+ Publisher: azure.ToStringPtr(img.Publisher),
+ Offer: azure.ToStringPtr(img.Offer),
+ Sku: azure.ToStringPtr(img.Sku),
+ Version: azure.ToStringPtr(img.Version),
+ }
+}
+
+// NewOSDiskParameters converts to Azure OSDisk
+func NewOSDiskParameters(img *v1alpha3.OSDiskParameters) *compute.OSDisk {
+ if img == nil {
+ return nil
+ }
+ return &compute.OSDisk{
+ Name: azure.ToStringPtr(img.Name),
+ Vhd: &compute.VirtualHardDisk{URI: azure.ToStringPtr(img.Vhd.URI)},
+ CreateOption: compute.DiskCreateOptionTypesFromImage,
+ }
+}
+
+// NewOSProfileParameters converts to Azure OSProfile
+func NewOSProfileParameters(os *v1alpha3.OSProfileParameters) *compute.OSProfile {
+ return &compute.OSProfile{
+ ComputerName: to.StringPtr(os.ComputerName),
+ AdminUsername: to.StringPtr(os.AdminUsername),
+ AdminPassword: to.StringPtr(os.AdminPassword),
+ LinuxConfiguration: &compute.LinuxConfiguration{
+ SSH: &compute.SSHConfiguration{
+ PublicKeys: NewSSHPublicKeys(os.LinuxConfiguration.SSH.PublicKeys),
+ },
+ },
+ }
+}
+
+// NewSSHPublicKeys converts to Azure SSHPublicKey
+func NewSSHPublicKeys(keys []*v1alpha3.SSHPublicKey) *[]compute.SSHPublicKey {
+ v := make([]compute.SSHPublicKey, len(keys))
+ for i, key := range keys {
+ v[i] = compute.SSHPublicKey{
+ Path: azure.ToStringPtr(key.Path),
+ KeyData: azure.ToStringPtr(key.Path),
+ }
+ }
+ return &v
+}
+
+// NewHardwareProfileParameters converts to Azure HardwareProfile
+func NewHardwareProfileParameters(hwprof *v1alpha3.HardwareProfileParameters) *compute.HardwareProfile {
+ return &compute.HardwareProfile{
+ VMSize: compute.VirtualMachineSizeTypes(hwprof.VMSize),
+ }
+}
+
+// NewNetworkProfileParameters converts to Azure NetworkProfile
+func NewNetworkProfileParameters(netprof *v1alpha3.NetworkProfileParameters) *compute.NetworkProfile {
+ return &compute.NetworkProfile{
+ NetworkInterfaces: NewNetworkInterfaces(netprof.NetworkInterfaces),
+ }
+}
+
+// NewNetworkInterfaces converts to Azure NetworkInterfaceReference
+func NewNetworkInterfaces(ifaces []*v1alpha3.NetworkInterfaceReferenceParameters) *[]compute.NetworkInterfaceReference {
+ ifs := make([]compute.NetworkInterfaceReference, len(ifaces))
+ for i, iface := range ifaces {
+ ifs[i] = compute.NetworkInterfaceReference{
+ ID: azure.ToStringPtr(iface.NetworkInterfaceID),
+ NetworkInterfaceReferenceProperties: &compute.NetworkInterfaceReferenceProperties{
+ Primary: azure.ToBoolPtr(iface.Primary),
+ },
+ }
+ }
+ return &ifs
+}
+
+// NewVirtualMachine converts to Azure VirtualMachine
+func NewVirtualMachine(vmparams *v1alpha3.VirtualMachineParameters) compute.VirtualMachine {
+ return compute.VirtualMachine{
+ Location: to.StringPtr(vmparams.Location),
+ VirtualMachineProperties: &compute.VirtualMachineProperties{
+ HardwareProfile: NewHardwareProfileParameters(vmparams.HardwareProfile),
+ StorageProfile: NewStorageProfileParameters(vmparams.StorageProfile),
+ OsProfile: NewOSProfileParameters(vmparams.OsProfile),
+ NetworkProfile: NewNetworkProfileParameters(vmparams.NetworkProfile),
+ },
+ }
+}
+
+// UpdateVirtualMachineStatus updates the status related to the external
+// Azure network interface in the VirtualMachine
+func UpdateVirtualMachineStatus(v *v1alpha3.VirtualMachine, az *compute.VirtualMachine) {
+ v.Status.State = azure.ToString(az.ProvisioningState)
+}
diff --git a/pkg/controller/azure.go b/pkg/controller/azure.go
index 876eb7a8..50beb107 100644
--- a/pkg/controller/azure.go
+++ b/pkg/controller/azure.go
@@ -24,6 +24,7 @@ import (
"github.com/crossplane/provider-azure/pkg/controller/cache"
"github.com/crossplane/provider-azure/pkg/controller/compute"
+ "github.com/crossplane/provider-azure/pkg/controller/compute/vm"
"github.com/crossplane/provider-azure/pkg/controller/config"
"github.com/crossplane/provider-azure/pkg/controller/database/cosmosdb"
"github.com/crossplane/provider-azure/pkg/controller/database/mysqlserver"
@@ -46,6 +47,7 @@ func Setup(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimiter) error {
for _, setup := range []func(ctrl.Manager, logging.Logger, workqueue.RateLimiter) error{
config.Setup,
cache.SetupRedis,
+ vm.SetupVirtualMachine,
compute.SetupAKSCluster,
mysqlserver.Setup,
mysqlserverfirewallrule.Setup,
diff --git a/pkg/controller/compute/vm/managed.go b/pkg/controller/compute/vm/managed.go
new file mode 100644
index 00000000..8d97de28
--- /dev/null
+++ b/pkg/controller/compute/vm/managed.go
@@ -0,0 +1,149 @@
+/*
+Copyright 2021 The Crossplane Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package vm
+
+import (
+ "context"
+
+ computemngr "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
+ "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute/computeapi"
+ "github.com/pkg/errors"
+ "k8s.io/client-go/util/workqueue"
+ ctrl "sigs.k8s.io/controller-runtime"
+ "sigs.k8s.io/controller-runtime/pkg/client"
+ "sigs.k8s.io/controller-runtime/pkg/controller"
+
+ xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
+ "github.com/crossplane/crossplane-runtime/pkg/event"
+ "github.com/crossplane/crossplane-runtime/pkg/logging"
+ "github.com/crossplane/crossplane-runtime/pkg/meta"
+ "github.com/crossplane/crossplane-runtime/pkg/ratelimiter"
+ "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
+ "github.com/crossplane/crossplane-runtime/pkg/resource"
+
+ "github.com/crossplane/provider-azure/apis/compute/v1alpha3"
+ azure "github.com/crossplane/provider-azure/pkg/clients"
+ "github.com/crossplane/provider-azure/pkg/clients/compute"
+)
+
+// Error strings.
+const (
+ errNotVirtualMachine = "managed resource is not a VirtualMachine"
+ errCreateVirtualMachine = "cannot create VirtualMachine"
+ errGetVirtualMachine = "cannot get VirtualMachine"
+ errDeleteVirtualMachine = "cannot delete VirtualMachine"
+)
+
+// SetupVirtualMachine adds a controller that reconciles VirtualMachine.
+func SetupVirtualMachine(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimiter) error {
+ name := managed.ControllerName(v1alpha3.VirtualMachineKind)
+
+ return ctrl.NewControllerManagedBy(mgr).
+ Named(name).
+ WithOptions(controller.Options{
+ RateLimiter: ratelimiter.NewDefaultManagedRateLimiter(rl),
+ }).
+ For(&v1alpha3.VirtualMachine{}).
+ Complete(managed.NewReconciler(mgr,
+ resource.ManagedKind(v1alpha3.VirtualMachineGroupVersionKind),
+ managed.WithConnectionPublishers(),
+ managed.WithExternalConnecter(&connecter{client: mgr.GetClient()}),
+ managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())),
+ managed.WithLogger(l.WithValues("controller", name)),
+ managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name)))))
+}
+
+type connecter struct {
+ client client.Client
+}
+
+func (c *connecter) Connect(ctx context.Context, mg resource.Managed) (managed.ExternalClient, error) {
+ creds, auth, err := azure.GetAuthInfo(ctx, c.client, mg)
+ if err != nil {
+ return nil, err
+ }
+ cl := computemngr.NewVirtualMachinesClient(creds[azure.CredentialsKeySubscriptionID])
+ cl.Authorizer = auth
+ return &external{client: cl}, nil
+}
+
+type external struct {
+ client computeapi.VirtualMachinesClientAPI
+}
+
+func (e *external) Observe(ctx context.Context, mg resource.Managed) (managed.ExternalObservation, error) {
+ cr, ok := mg.(*v1alpha3.VirtualMachine)
+ if !ok {
+ return managed.ExternalObservation{}, errors.New(errNotVirtualMachine)
+ }
+
+ c, err := e.client.Get(ctx, cr.Spec.ResourceGroupName, meta.GetExternalName(cr), computemngr.InstanceView)
+ if azure.IsNotFound(err) {
+ return managed.ExternalObservation{ResourceExists: false}, nil
+ }
+ if err != nil {
+ return managed.ExternalObservation{}, errors.Wrap(err, errGetVirtualMachine)
+ }
+
+ compute.UpdateVirtualMachineStatus(cr, &c)
+
+ if cr.Status.State == "Succeeded" {
+ cr.SetConditions(xpv1.Available())
+ }
+
+ // VirtualMachine are always up to date because we can't yet update them.
+ o := managed.ExternalObservation{
+ ResourceExists: true,
+ ResourceUpToDate: true,
+ }
+ return o, nil
+}
+
+func (e *external) Create(ctx context.Context, mg resource.Managed) (managed.ExternalCreation, error) {
+ cr, ok := mg.(*v1alpha3.VirtualMachine)
+ if !ok {
+ return managed.ExternalCreation{}, errors.New(errNotVirtualMachine)
+ }
+ cr.SetConditions(xpv1.Creating())
+ if _, err := e.client.CreateOrUpdate(ctx, cr.Spec.ResourceGroupName, meta.GetExternalName(cr), compute.NewVirtualMachine(cr.Spec.VirtualMachineParameters)); err != nil {
+ return managed.ExternalCreation{}, errors.Wrap(err, errCreateVirtualMachine)
+ }
+ return managed.ExternalCreation{}, nil
+}
+
+func (e *external) Update(ctx context.Context, mg resource.Managed) (managed.ExternalUpdate, error) {
+ if _, ok := mg.(*v1alpha3.VirtualMachine); !ok {
+ return managed.ExternalUpdate{}, errors.New(errNotVirtualMachine)
+ }
+ return managed.ExternalUpdate{}, nil
+}
+
+func (e *external) Delete(ctx context.Context, mg resource.Managed) error {
+ cr, ok := mg.(*v1alpha3.VirtualMachine)
+ if !ok {
+ return errors.New(errNotVirtualMachine)
+ }
+ cr.SetConditions(xpv1.Deleting())
+ _, err := e.client.Delete(ctx, cr.Spec.ResourceGroupName, meta.GetExternalName(cr))
+ if azure.IsNotFound(err) {
+ return nil
+ }
+ if err != nil {
+ return errors.Wrap(err, errDeleteVirtualMachine)
+ }
+ return nil
+}
diff --git a/pkg/controller/compute/vm/managed_test.go b/pkg/controller/compute/vm/managed_test.go
new file mode 100644
index 00000000..16ac01e5
--- /dev/null
+++ b/pkg/controller/compute/vm/managed_test.go
@@ -0,0 +1,332 @@
+/*
+Copyright 2021 The Crossplane Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package vm
+
+import (
+ "context"
+ "net/http"
+ "testing"
+
+ "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
+ "github.com/Azure/go-autorest/autorest"
+
+ "github.com/google/go-cmp/cmp"
+ "github.com/pkg/errors"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/types"
+
+ xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
+ "github.com/crossplane/crossplane-runtime/pkg/meta"
+ "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
+ "github.com/crossplane/crossplane-runtime/pkg/resource"
+ "github.com/crossplane/crossplane-runtime/pkg/test"
+
+ "github.com/crossplane/provider-azure/apis/compute/v1alpha3"
+ azure "github.com/crossplane/provider-azure/pkg/clients"
+ "github.com/crossplane/provider-azure/pkg/clients/compute/fake"
+)
+
+const (
+ name = "coolVirtualMachine"
+ uid = types.UID("definitely-a-uuid")
+ resourceGroupName = "coolRG"
+)
+
+var (
+ ctx = context.Background()
+ errorBoom = errors.New("boom")
+)
+
+type testCase struct {
+ name string
+ e managed.ExternalClient
+ r resource.Managed
+ want resource.Managed
+ wantErr error
+}
+
+type virtualMachineModifier func(address *v1alpha3.VirtualMachine)
+
+func withConditions(c ...xpv1.Condition) virtualMachineModifier {
+ return func(r *v1alpha3.VirtualMachine) { r.Status.ConditionedStatus.Conditions = c }
+}
+
+func withState(s string) virtualMachineModifier {
+ return func(r *v1alpha3.VirtualMachine) { r.Status.State = s }
+}
+
+func virtualMachine(sm ...virtualMachineModifier) *v1alpha3.VirtualMachine {
+ r := &v1alpha3.VirtualMachine{
+ ObjectMeta: metav1.ObjectMeta{
+ Name: name,
+ UID: uid,
+ Finalizers: []string{},
+ },
+ Spec: v1alpha3.VirtualMachineSpec{
+ ResourceGroupName: resourceGroupName,
+ VirtualMachineParameters: &v1alpha3.VirtualMachineParameters{
+ Location: "West US 2",
+ HardwareProfile: &v1alpha3.HardwareProfileParameters{
+ VMSize: "Standard_B1s",
+ },
+ StorageProfile: &v1alpha3.StorageProfileParameters{
+ ImageReference: &v1alpha3.ImageReferenceParameters{
+ Publisher: "Canonical",
+ Offer: "UbuntuServer",
+ Sku: "16.04-LTS",
+ Version: "latest",
+ },
+ },
+ OsProfile: &v1alpha3.OSProfileParameters{
+ ComputerName: "example-vm",
+ AdminUsername: "testuser",
+ AdminPassword: "t2st-uSer",
+ LinuxConfiguration: &v1alpha3.LinuxConfigurationParameters{
+ SSH: &v1alpha3.SSHConfigurationParameters{
+ PublicKeys: make([]*v1alpha3.SSHPublicKey, 0),
+ },
+ },
+ },
+ NetworkProfile: &v1alpha3.NetworkProfileParameters{
+ NetworkInterfaces: make([]*v1alpha3.NetworkInterfaceReferenceParameters, 0),
+ },
+ },
+ },
+ Status: v1alpha3.VirtualMachineStatus{},
+ }
+ meta.SetExternalName(r, name)
+ for _, m := range sm {
+ m(r)
+ }
+ return r
+}
+
+// Test that our Reconciler implementation satisfies the Reconciler interface.
+var _ managed.ExternalClient = &external{}
+var _ managed.ExternalConnecter = &connecter{}
+
+func TestCreate(t *testing.T) {
+ cases := []testCase{
+ {
+ name: "NotVirtualMachine",
+ e: &external{client: &fake.VirtualMachineClient{}},
+ r: &v1alpha3.AKSCluster{},
+ want: &v1alpha3.AKSCluster{},
+ wantErr: errors.New(errNotVirtualMachine),
+ },
+ {
+ name: "SuccessfulCreate",
+ e: &external{client: &fake.VirtualMachineClient{
+ MockCreateOrUpdate: func(ctx context.Context, resourceGroupName string, VMName string, parameters compute.VirtualMachine) (result compute.VirtualMachinesCreateOrUpdateFuture, err error) {
+ return compute.VirtualMachinesCreateOrUpdateFuture{}, nil
+ },
+ }},
+ r: virtualMachine(),
+ want: virtualMachine(
+ withConditions(xpv1.Creating()),
+ ),
+ },
+ {
+ name: "FailedCreate",
+ e: &external{client: &fake.VirtualMachineClient{
+ MockCreateOrUpdate: func(ctx context.Context, resourceGroupName string, VMName string, parameters compute.VirtualMachine) (result compute.VirtualMachinesCreateOrUpdateFuture, err error) {
+ return compute.VirtualMachinesCreateOrUpdateFuture{}, errorBoom
+ },
+ }},
+ r: virtualMachine(),
+ want: virtualMachine(
+ withConditions(xpv1.Creating()),
+ ),
+ wantErr: errors.Wrap(errorBoom, errCreateVirtualMachine),
+ },
+ }
+
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ _, err := tc.e.Create(ctx, tc.r)
+
+ if diff := cmp.Diff(tc.wantErr, err, test.EquateErrors()); diff != "" {
+ t.Errorf("tc.e.Create(...): want error != got error:\n%s", diff)
+ }
+
+ if diff := cmp.Diff(tc.want, tc.r, test.EquateConditions()); diff != "" {
+ t.Errorf("r: -want, +got:\n%s", diff)
+ }
+ })
+ }
+}
+
+func TestObserve(t *testing.T) {
+ cases := []testCase{
+ {
+ name: "NotVirtualMachine",
+ e: &external{client: &fake.VirtualMachineClient{}},
+ r: &v1alpha3.AKSCluster{},
+ want: &v1alpha3.AKSCluster{},
+ wantErr: errors.New(errNotVirtualMachine),
+ },
+ {
+ name: "SuccessfulObserveNotExist",
+ e: &external{client: &fake.VirtualMachineClient{
+ MockGet: func(ctx context.Context, resourceGroupName string, VMName string, expand compute.InstanceViewTypes) (result compute.VirtualMachine, err error) {
+ return compute.VirtualMachine{VirtualMachineProperties: &compute.VirtualMachineProperties{}}, autorest.DetailedError{StatusCode: http.StatusNotFound}
+ },
+ }},
+ r: virtualMachine(),
+ want: virtualMachine(),
+ },
+ {
+ name: "SuccessfulObserveExists",
+ e: &external{client: &fake.VirtualMachineClient{
+ MockGet: func(ctx context.Context, resourceGroupName string, VMName string, expand compute.InstanceViewTypes) (result compute.VirtualMachine, err error) {
+ return compute.VirtualMachine{VirtualMachineProperties: &compute.VirtualMachineProperties{
+ ProvisioningState: azure.ToStringPtr(string(compute.ProvisioningStateSucceeded)),
+ }}, nil
+ },
+ }},
+ r: virtualMachine(),
+ want: virtualMachine(
+ withConditions(xpv1.Available()),
+ withState(string(compute.ProvisioningStateSucceeded)),
+ ),
+ },
+ {
+ name: "FailedObserve",
+ e: &external{client: &fake.VirtualMachineClient{
+ MockGet: func(ctx context.Context, resourceGroupName string, VMName string, expand compute.InstanceViewTypes) (result compute.VirtualMachine, err error) {
+ return compute.VirtualMachine{}, errorBoom
+ },
+ }},
+ r: virtualMachine(),
+ want: virtualMachine(),
+ wantErr: errors.Wrap(errorBoom, errGetVirtualMachine),
+ },
+ }
+
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ _, err := tc.e.Observe(ctx, tc.r)
+
+ if diff := cmp.Diff(tc.wantErr, err, test.EquateErrors()); diff != "" {
+ t.Errorf("tc.e.Observe(...): want error != got error:\n%s", diff)
+ }
+
+ if diff := cmp.Diff(tc.want, tc.r, test.EquateConditions()); diff != "" {
+ t.Errorf("r: -want, +got:\n%s", diff)
+ }
+ })
+ }
+}
+
+func TestUpdate(t *testing.T) {
+ cases := []testCase{
+ {
+ name: "NotVirtualMachine",
+ e: &external{client: &fake.VirtualMachineClient{}},
+ r: &v1alpha3.AKSCluster{},
+ want: &v1alpha3.AKSCluster{},
+ wantErr: errors.New(errNotVirtualMachine),
+ },
+ {
+ name: "SuccessfulDoesNotNeedUpdate",
+ e: &external{client: &fake.VirtualMachineClient{
+ MockGet: func(ctx context.Context, resourceGroupName string, VMName string, expand compute.InstanceViewTypes) (result compute.VirtualMachine, err error) {
+ return compute.VirtualMachine{VirtualMachineProperties: &compute.VirtualMachineProperties{}}, autorest.DetailedError{StatusCode: http.StatusNotFound}
+ },
+ }},
+ r: virtualMachine(),
+ want: virtualMachine(),
+ },
+ }
+
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ _, err := tc.e.Update(ctx, tc.r)
+
+ if diff := cmp.Diff(tc.wantErr, err, test.EquateErrors()); diff != "" {
+ t.Errorf("tc.e.Update(...): want error != got error:\n%s", diff)
+ }
+
+ if diff := cmp.Diff(tc.want, tc.r, test.EquateConditions()); diff != "" {
+ t.Errorf("r: -want, +got:\n%s", diff)
+ }
+ })
+ }
+}
+
+func TestDelete(t *testing.T) {
+ cases := []testCase{
+ {
+ name: "NotVirtualMachine",
+ e: &external{client: &fake.VirtualMachineClient{}},
+ r: &v1alpha3.AKSCluster{},
+ want: &v1alpha3.AKSCluster{},
+ wantErr: errors.New(errNotVirtualMachine),
+ },
+ {
+ name: "Successful",
+ e: &external{client: &fake.VirtualMachineClient{
+ MockDelete: func(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachinesDeleteFuture, err error) {
+ return compute.VirtualMachinesDeleteFuture{}, nil
+ },
+ }},
+ r: virtualMachine(),
+ want: virtualMachine(
+ withConditions(xpv1.Deleting()),
+ ),
+ },
+ {
+ name: "SuccessfulNotFound",
+ e: &external{client: &fake.VirtualMachineClient{
+ MockDelete: func(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachinesDeleteFuture, err error) {
+ return compute.VirtualMachinesDeleteFuture{}, autorest.DetailedError{StatusCode: http.StatusNotFound}
+ },
+ }},
+ r: virtualMachine(),
+ want: virtualMachine(
+ withConditions(xpv1.Deleting()),
+ ),
+ },
+ {
+ name: "Failed",
+ e: &external{client: &fake.VirtualMachineClient{
+ MockDelete: func(ctx context.Context, resourceGroupName string, VMName string) (result compute.VirtualMachinesDeleteFuture, err error) {
+ return compute.VirtualMachinesDeleteFuture{}, errorBoom
+ },
+ }},
+ r: virtualMachine(),
+ want: virtualMachine(
+ withConditions(xpv1.Deleting()),
+ ),
+ wantErr: errors.Wrap(errorBoom, errDeleteVirtualMachine),
+ },
+ }
+
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ err := tc.e.Delete(ctx, tc.r)
+
+ if diff := cmp.Diff(tc.wantErr, err, test.EquateErrors()); diff != "" {
+ t.Errorf("tc.e.Delete(...): want error != got error:\n%s", diff)
+ }
+
+ if diff := cmp.Diff(tc.want, tc.r, test.EquateConditions()); diff != "" {
+ t.Errorf("r: -want, +got:\n%s", diff)
+ }
+ })
+ }
+}