Skip to content

Commit

Permalink
AVD configurable groups (#79)
Browse files Browse the repository at this point in the history
* AVD configurable groups

* Refactoring

* fix

* fix

* whitespace

* fix
  • Loading branch information
fraliv13 authored Nov 27, 2023
1 parent 18bd910 commit bf0cfe2
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 0 deletions.
11 changes: 11 additions & 0 deletions helm/crds/provisioning.totalsoft.ro_azurevirtualdesktops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ spec:
- domain
type: object
type: array
groups:
properties:
admins:
items:
type: string
type: array
applicationUsers:
items:
type: string
type: array
type: object
hostPoolName:
description: Virtual Desktop name prefix. Will have platform and tenant
suffix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,22 @@ func azureVirtualDesktopDeployFunc(target provisioning.ProvisioningTarget, resou
return err
}
}
for _, childAppsUserGroupName := range avd.Spec.Groups.ApplicationUsers {
childAppsUserGroup, err := azuread.LookupGroup(ctx, &azuread.LookupGroupArgs{
DisplayName: pulumi.StringRef(childAppsUserGroupName),
}, nil)
if err != nil {
return err
}

_, err = azuread.NewGroupMember(ctx, fmt.Sprintf("%s-app-user-group-%s", childAppsUserGroupName, avd.Spec.HostPoolName), &azuread.GroupMemberArgs{
GroupObjectId: appsUserGroup.ID(),
MemberObjectId: pulumi.String(childAppsUserGroup.Id),
}, pulumi.Parent(appsUserGroup))
if err != nil {
return err
}
}

adminUserGroup, err := azuread.NewGroup(ctx, fmt.Sprintf("%s-admin", hostPoolName), &azuread.GroupArgs{
DisplayName: pulumi.String(fmt.Sprintf("%s-%s-admin", globalQalifier, hostPoolName)),
Expand Down Expand Up @@ -461,6 +477,24 @@ func azureVirtualDesktopDeployFunc(target provisioning.ProvisioningTarget, resou
}
}

for _, childAdminUserGroupName := range avd.Spec.Groups.Admins {
childAdminUserGroup, err := azuread.LookupGroup(ctx, &azuread.LookupGroupArgs{
DisplayName: pulumi.StringRef(childAdminUserGroupName),
}, nil)

if err != nil {
return err
}

_, err = azuread.NewGroupMember(ctx, fmt.Sprintf("%s-admin-group-%s", childAdminUserGroupName, avd.Spec.HostPoolName), &azuread.GroupMemberArgs{
GroupObjectId: adminUserGroup.ID(),
MemberObjectId: pulumi.String(childAdminUserGroup.Id),
}, pulumi.Parent(adminUserGroup))
if err != nil {
return err
}
}

avdComponent.HostPool, err = desktopvirtualization.NewHostPool(ctx, hostPoolName, &desktopvirtualization.HostPoolArgs{
//HostPoolName: pulumi.String(hostPoolName),
HostPoolType: pulumi.String(desktopvirtualization.HostPoolTypePooled),
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/provisioning/v1alpha1/azureVirtualDesktopTypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ type AzureVirtualDesktopSpec struct {
// +optional
Users AzureVirtualDesktopUsersSpec `json:"users"`

// +optional
Groups AzureVirtualDesktopGroupsSpec `json:"groups"`

// +optional
Exports []AzureVirtualDesktopExportsSpec `json:"exports,omitempty"`

Expand Down Expand Up @@ -89,6 +92,13 @@ type AzureVirtualDesktopUsersSpec struct {
ApplicationUsers []string `json:"applicationUsers,omitempty"`
}

type AzureVirtualDesktopGroupsSpec struct {
// +optional
Admins []string `json:"admins,omitempty"`
// +optional
ApplicationUsers []string `json:"applicationUsers,omitempty"`
}

type AzureVirtualDesktopApplication struct {
Name string `json:"name"`
FriendlyName string `json:"friendlyName"`
Expand Down
27 changes: 27 additions & 0 deletions pkg/apis/provisioning/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/generated/applyconfiguration/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bf0cfe2

Please sign in to comment.