Skip to content

Commit

Permalink
AVD - Templated init script arguments (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
fraliv13 authored Nov 27, 2023
1 parent bf0cfe2 commit 42825ea
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"totalsoft.ro/platform-controllers/internal/controllers/provisioning"
"totalsoft.ro/platform-controllers/internal/template"
platformv1 "totalsoft.ro/platform-controllers/pkg/apis/platform/v1alpha1"
provisioningv1 "totalsoft.ro/platform-controllers/pkg/apis/provisioning/v1alpha1"
)
Expand Down Expand Up @@ -73,6 +74,8 @@ type AzureVirtualDesktopVMArgs struct {

DiskDeleteOptions compute.DeleteOptions

Target provisioning.ProvisioningTarget

Spec provisioningv1.AzureVirtualDesktopSpec
}

Expand Down Expand Up @@ -277,11 +280,19 @@ func NewAzureVirtualDesktopVM(ctx *pulumi.Context, name string, args *AzureVirtu
return nil, err
}

tc := provisioning.GetTemplateContext(args.Target)

params := compute.RunCommandInputParameterArray{}
for _, arg := range args.Spec.InitScriptArguments {

parsedValue, err := template.ParseTemplate(arg.Value, tc)
if err != nil {
return nil, err
}

params = append(params, compute.RunCommandInputParameterArgs{
Name: pulumi.String(arg.Name),
Value: pulumi.String(arg.Value),
Value: pulumi.String(parsedValue),
})
}

Expand Down Expand Up @@ -695,7 +706,8 @@ func azureVirtualDesktopDeployFunc(target provisioning.ProvisioningTarget, resou
ProfileUser: storageAccount.Name,
ProfileSecret: storageAccountKeys.Keys().Index(pulumi.Int(0)).Value(),

Spec: avd.Spec,
Target: target,
Spec: avd.Spec,
}, pulumi.Parent(avdComponent))

if err != nil {
Expand Down

0 comments on commit 42825ea

Please sign in to comment.