/
denyassignment.go
36 lines (28 loc) · 1.03 KB
/
denyassignment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cluster
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
import (
"context"
"github.com/Azure/ARO-RP/pkg/env"
"github.com/Azure/ARO-RP/pkg/util/arm"
"github.com/Azure/ARO-RP/pkg/util/stringutils"
)
func (m *manager) createOrUpdateDenyAssignment(ctx context.Context) error {
if m.env.FeatureIsSet(env.FeatureDisableDenyAssignments) {
return nil
}
// needed for AdminUpdate so it would not block other steps
if m.doc.OpenShiftCluster.Properties.ServicePrincipalProfile.SPObjectID == "" {
m.log.Print("skipping createOrUpdateDenyAssignment: SPObjectID is empty")
return nil
}
resourceGroup := stringutils.LastTokenByte(m.doc.OpenShiftCluster.Properties.ClusterProfile.ResourceGroupID, '/')
t := &arm.Template{
Schema: "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
ContentVersion: "1.0.0.0",
Resources: []*arm.Resource{
m.denyAssignment(),
},
}
return arm.DeployTemplate(ctx, m.log, m.deployments, resourceGroup, "storage", t, nil)
}