diff --git a/helm/crds/provisioning.totalsoft.ro_azurevirtualdesktops.yaml b/helm/crds/provisioning.totalsoft.ro_azurevirtualdesktops.yaml index ecea69d..0b99182 100644 --- a/helm/crds/provisioning.totalsoft.ro_azurevirtualdesktops.yaml +++ b/helm/crds/provisioning.totalsoft.ro_azurevirtualdesktops.yaml @@ -193,6 +193,22 @@ spec: type: string type: array type: object + vmApplications: + description: Virtual Machine Gallery Applications + items: + properties: + installOrderIndex: + description: 'Installation order index. Eg: 1, 2, 3' + type: integer + packageId: + description: 'Source gallery application id or application version + id eg: subscriptions/15b38e46-ef41-4f5b-bdba-7d9354568c2d/resourceGroups/test-vm/providers/Microsoft.Compute/galleries/lfgalery/applications/charisma-client/versions/4.33.0' + type: string + required: + - installOrderIndex + - packageId + type: object + type: array vmNamePrefix: description: Session Host VM name prefix. Will have platform and tenant suffix. @@ -219,6 +235,7 @@ spec: - platformRef - sourceImageId - subnetId + - vmApplications - vmNamePrefix - vmNumberOfInstances - vmSize diff --git a/internal/controllers/provisioning/provisioners/pulumi/azure_virtual_desktop.go b/internal/controllers/provisioning/provisioners/pulumi/azure_virtual_desktop.go index d1633a1..8d6eb0b 100644 --- a/internal/controllers/provisioning/provisioners/pulumi/azure_virtual_desktop.go +++ b/internal/controllers/provisioning/provisioners/pulumi/azure_virtual_desktop.go @@ -128,6 +128,14 @@ func NewAzureVirtualDesktopVM(ctx *pulumi.Context, name string, args *AzureVirtu return nil, err } + vmApplications := compute.VMGalleryApplicationArray{} + for _, vmApplication := range args.Spec.VmApplications { + vmApplications = append(vmApplications, compute.VMGalleryApplicationArgs{ + PackageReferenceId: pulumi.String(vmApplication.PackageId), + Order: pulumi.Int(vmApplication.InstallOrderIndex), + }) + } + vmArgs := compute.VirtualMachineArgs{ //VmName: pulumi.String(name), ResourceGroupName: args.ResourceGroupName, @@ -170,6 +178,9 @@ func NewAzureVirtualDesktopVM(ctx *pulumi.Context, name string, args *AzureVirtu }, }, }, + ApplicationProfile: compute.ApplicationProfileArgs{ + GalleryApplications: vmApplications, + }, } if args.Spec.EnableTrustedLaunch { diff --git a/pkg/apis/provisioning/v1alpha1/azureVirtualDesktopTypes.go b/pkg/apis/provisioning/v1alpha1/azureVirtualDesktopTypes.go index 8b835ec..44fcc8d 100644 --- a/pkg/apis/provisioning/v1alpha1/azureVirtualDesktopTypes.go +++ b/pkg/apis/provisioning/v1alpha1/azureVirtualDesktopTypes.go @@ -28,6 +28,9 @@ type AzureVirtualDesktopSpec struct { // The number of virtual machines to be added to the host pool VmNumberOfInstances int `json:"vmNumberOfInstances"` + // Virtual Machine Gallery Applications + VmApplications []VirtualMachineGalleryApplication `json:"vmApplications"` + // Possible values are Standard_LRS, StandardSSD_LRS or Premium_LRS. // +kubebuilder:validation:Enum=Standard_LRS;StandardSSD_LRS;Premium_LRS OSDiskType string `json:"osDiskType"` @@ -92,6 +95,16 @@ type AzureVirtualDesktopApplication struct { Path string `json:"path"` } +type VirtualMachineGalleryApplication struct { + + // Source gallery application id or application version id + // eg: subscriptions/15b38e46-ef41-4f5b-bdba-7d9354568c2d/resourceGroups/test-vm/providers/Microsoft.Compute/galleries/lfgalery/applications/charisma-client/versions/4.33.0 + PackageId string `json:"packageId"` + + // Installation order index. Eg: 1, 2, 3 + InstallOrderIndex int `json:"installOrderIndex"` +} + type InitScriptArgs struct { Name string `json:"name"` Value string `json:"value"` diff --git a/pkg/apis/provisioning/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/provisioning/v1alpha1/zz_generated.deepcopy.go index 38395d9..1259d5b 100644 --- a/pkg/apis/provisioning/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/provisioning/v1alpha1/zz_generated.deepcopy.go @@ -375,6 +375,11 @@ func (in *AzureVirtualDesktopList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AzureVirtualDesktopSpec) DeepCopyInto(out *AzureVirtualDesktopSpec) { *out = *in + if in.VmApplications != nil { + in, out := &in.VmApplications, &out.VmApplications + *out = make([]VirtualMachineGalleryApplication, len(*in)) + copy(*out, *in) + } if in.InitScriptArguments != nil { in, out := &in.InitScriptArguments, &out.InitScriptArguments *out = make([]InitScriptArgs, len(*in)) @@ -777,3 +782,19 @@ func (in *VaultSecretTemplate) DeepCopy() *VaultSecretTemplate { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualMachineGalleryApplication) DeepCopyInto(out *VirtualMachineGalleryApplication) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineGalleryApplication. +func (in *VirtualMachineGalleryApplication) DeepCopy() *VirtualMachineGalleryApplication { + if in == nil { + return nil + } + out := new(VirtualMachineGalleryApplication) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/generated/applyconfiguration/provisioning/v1alpha1/azurevirtualdesktopspec.go b/pkg/generated/applyconfiguration/provisioning/v1alpha1/azurevirtualdesktopspec.go index 3968cd3..b1c1ace 100644 --- a/pkg/generated/applyconfiguration/provisioning/v1alpha1/azurevirtualdesktopspec.go +++ b/pkg/generated/applyconfiguration/provisioning/v1alpha1/azurevirtualdesktopspec.go @@ -25,20 +25,21 @@ import ( // AzureVirtualDesktopSpecApplyConfiguration represents an declarative configuration of the AzureVirtualDesktopSpec type for use // with apply. type AzureVirtualDesktopSpecApplyConfiguration struct { - HostPoolName *string `json:"hostPoolName,omitempty"` - VmNamePrefix *string `json:"vmNamePrefix,omitempty"` - VmSize *string `json:"vmSize,omitempty"` - VmNumberOfInstances *int `json:"vmNumberOfInstances,omitempty"` - OSDiskType *string `json:"osDiskType,omitempty"` - SourceImageId *string `json:"sourceImageId,omitempty"` - SubnetId *string `json:"subnetId,omitempty"` - EnableTrustedLaunch *bool `json:"enableTrustedLaunch,omitempty"` - InitScript *string `json:"initScript,omitempty"` - InitScriptArguments []InitScriptArgsApplyConfiguration `json:"initScriptArgs,omitempty"` - WorkspaceFriendlyName *string `json:"workspaceFriendlyName,omitempty"` - Applications []AzureVirtualDesktopApplicationApplyConfiguration `json:"applications,omitempty"` - Users *AzureVirtualDesktopUsersSpecApplyConfiguration `json:"users,omitempty"` - Exports []AzureVirtualDesktopExportsSpecApplyConfiguration `json:"exports,omitempty"` + HostPoolName *string `json:"hostPoolName,omitempty"` + VmNamePrefix *string `json:"vmNamePrefix,omitempty"` + VmSize *string `json:"vmSize,omitempty"` + VmNumberOfInstances *int `json:"vmNumberOfInstances,omitempty"` + VmApplications []VirtualMachineGalleryApplicationApplyConfiguration `json:"vmApplications,omitempty"` + OSDiskType *string `json:"osDiskType,omitempty"` + SourceImageId *string `json:"sourceImageId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + EnableTrustedLaunch *bool `json:"enableTrustedLaunch,omitempty"` + InitScript *string `json:"initScript,omitempty"` + InitScriptArguments []InitScriptArgsApplyConfiguration `json:"initScriptArgs,omitempty"` + WorkspaceFriendlyName *string `json:"workspaceFriendlyName,omitempty"` + Applications []AzureVirtualDesktopApplicationApplyConfiguration `json:"applications,omitempty"` + Users *AzureVirtualDesktopUsersSpecApplyConfiguration `json:"users,omitempty"` + Exports []AzureVirtualDesktopExportsSpecApplyConfiguration `json:"exports,omitempty"` ProvisioningMetaApplyConfiguration `json:",inline"` } @@ -80,6 +81,19 @@ func (b *AzureVirtualDesktopSpecApplyConfiguration) WithVmNumberOfInstances(valu return b } +// WithVmApplications adds the given value to the VmApplications field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the VmApplications field. +func (b *AzureVirtualDesktopSpecApplyConfiguration) WithVmApplications(values ...*VirtualMachineGalleryApplicationApplyConfiguration) *AzureVirtualDesktopSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithVmApplications") + } + b.VmApplications = append(b.VmApplications, *values[i]) + } + return b +} + // WithOSDiskType sets the OSDiskType field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the OSDiskType field is set to the value of the last call. diff --git a/pkg/generated/applyconfiguration/provisioning/v1alpha1/virtualmachinegalleryapplication.go b/pkg/generated/applyconfiguration/provisioning/v1alpha1/virtualmachinegalleryapplication.go new file mode 100644 index 0000000..92f5a7e --- /dev/null +++ b/pkg/generated/applyconfiguration/provisioning/v1alpha1/virtualmachinegalleryapplication.go @@ -0,0 +1,48 @@ +/* +Copyright The Kubernetes 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. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// VirtualMachineGalleryApplicationApplyConfiguration represents an declarative configuration of the VirtualMachineGalleryApplication type for use +// with apply. +type VirtualMachineGalleryApplicationApplyConfiguration struct { + PackageId *string `json:"packageId,omitempty"` + InstallOrderIndex *int `json:"installOrderIndex,omitempty"` +} + +// VirtualMachineGalleryApplicationApplyConfiguration constructs an declarative configuration of the VirtualMachineGalleryApplication type for use with +// apply. +func VirtualMachineGalleryApplication() *VirtualMachineGalleryApplicationApplyConfiguration { + return &VirtualMachineGalleryApplicationApplyConfiguration{} +} + +// WithPackageId sets the PackageId field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the PackageId field is set to the value of the last call. +func (b *VirtualMachineGalleryApplicationApplyConfiguration) WithPackageId(value string) *VirtualMachineGalleryApplicationApplyConfiguration { + b.PackageId = &value + return b +} + +// WithInstallOrderIndex sets the InstallOrderIndex field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the InstallOrderIndex field is set to the value of the last call. +func (b *VirtualMachineGalleryApplicationApplyConfiguration) WithInstallOrderIndex(value int) *VirtualMachineGalleryApplicationApplyConfiguration { + b.InstallOrderIndex = &value + return b +} diff --git a/pkg/generated/applyconfiguration/utils.go b/pkg/generated/applyconfiguration/utils.go index 8f37690..f773bc2 100644 --- a/pkg/generated/applyconfiguration/utils.go +++ b/pkg/generated/applyconfiguration/utils.go @@ -115,6 +115,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &applyconfigurationprovisioningv1alpha1.ValueExportApplyConfiguration{} case provisioningv1alpha1.SchemeGroupVersion.WithKind("VaultSecretTemplate"): return &applyconfigurationprovisioningv1alpha1.VaultSecretTemplateApplyConfiguration{} + case provisioningv1alpha1.SchemeGroupVersion.WithKind("VirtualMachineGalleryApplication"): + return &applyconfigurationprovisioningv1alpha1.VirtualMachineGalleryApplicationApplyConfiguration{} } return nil