Skip to content

Commit 70009b9

Browse files
committed
removed changes besides template
1 parent 052c317 commit 70009b9

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ require (
2424
github.com/stretchr/testify v1.9.0
2525
github.com/yannh/kubeconform v0.6.7
2626
go.uber.org/mock v0.4.0
27+
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f
2728
golang.org/x/mod v0.20.0
2829
gopkg.in/yaml.v2 v2.4.0
2930
gopkg.in/yaml.v3 v3.0.1
@@ -141,7 +142,6 @@ require (
141142
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
142143
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
143144
golang.org/x/crypto v0.28.0 // indirect
144-
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
145145
golang.org/x/net v0.30.0 // indirect
146146
golang.org/x/oauth2 v0.19.0 // indirect
147147
golang.org/x/sync v0.8.0 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
507507
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
508508
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
509509
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
510+
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
511+
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
510512
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
511513
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
512514
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -542,6 +544,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
542544
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
543545
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
544546
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
547+
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
548+
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
545549
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
546550
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
547551
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=

pkg/providers/azure.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func InitiateAzureOIDCFlow(ctx context.Context, sc *SetUpCmd, s spinner.Spinner)
6060
return err
6161
}
6262

63-
if err := sc.assignSpRoles(ctx); err != nil {
63+
if err := sc.assignSpRole(ctx); err != nil {
6464
return err
6565
}
6666

@@ -164,28 +164,17 @@ func (sc *SetUpCmd) CreateServicePrincipal() error {
164164
return nil
165165
}
166166

167-
func (sc *SetUpCmd) assignSpRoles(ctx context.Context) error {
168-
var spRoles = []string{
169-
"b24988ac-6180-42a0-ab88-20f7382dd24c", // Contributor role ID
170-
"5af6afb3-c06c-4fa4-8848-71a8aee05683", // Azure Kubernetes Fleet Manager RBAC Writer role ID
171-
}
172-
for _, role := range spRoles {
173-
if err := sc.assignRole(ctx, role); err != nil {
174-
return err
175-
}
176-
}
177-
log.Debug("Roles assigned successfully!")
178-
return nil
179-
}
167+
func (sc *SetUpCmd) assignSpRole(ctx context.Context) error {
168+
log.Debug("Assigning contributor role to service principal...")
180169

181-
func (sc *SetUpCmd) assignRole(ctx context.Context, roleId string) error {
182170
roleAssignClient, err := createRoleAssignmentClient(sc.SubscriptionID)
183171
if err != nil {
184172
return fmt.Errorf("creating role assignment client: %w", err)
185173
}
186174

187175
scope := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s", sc.SubscriptionID, sc.ResourceGroupName)
188176
objectID := sc.spObjectId
177+
roleId := "b24988ac-6180-42a0-ab88-20f7382dd24c" // Contributor role ID
189178
raUid := uuid.New().String()
190179

191180
fullAssignmentId := fmt.Sprintf("/%s/providers/Microsoft.Authorization/roleAssignments/%s", scope, raUid)
@@ -205,6 +194,7 @@ func (sc *SetUpCmd) assignRole(ctx context.Context, roleId string) error {
205194
return fmt.Errorf("creating role assignment: %w", err)
206195
}
207196

197+
log.Debug("Role assigned successfully!")
208198
return nil
209199
}
210200

0 commit comments

Comments
 (0)