mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(provisioner): add support for workspace_owner_rbac_roles (#16407)
Part of https://github.com/coder/terraform-provider-coder/pull/330 Adds support for the coder_workspace_owner.rbac_roles attribute
This commit is contained in:
@@ -594,6 +594,19 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
|
||||
})
|
||||
}
|
||||
|
||||
roles, err := s.Database.GetAuthorizationUserRoles(ctx, owner.ID)
|
||||
if err != nil {
|
||||
return nil, failJob(fmt.Sprintf("get owner authorization roles: %s", err))
|
||||
}
|
||||
ownerRbacRoles := []*sdkproto.Role{}
|
||||
for _, role := range roles.Roles {
|
||||
if s.OrganizationID == uuid.Nil {
|
||||
ownerRbacRoles = append(ownerRbacRoles, &sdkproto.Role{Name: role, OrgId: ""})
|
||||
continue
|
||||
}
|
||||
ownerRbacRoles = append(ownerRbacRoles, &sdkproto.Role{Name: role, OrgId: s.OrganizationID.String()})
|
||||
}
|
||||
|
||||
protoJob.Type = &proto.AcquiredJob_WorkspaceBuild_{
|
||||
WorkspaceBuild: &proto.AcquiredJob_WorkspaceBuild{
|
||||
WorkspaceBuildId: workspaceBuild.ID.String(),
|
||||
@@ -621,6 +634,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
|
||||
WorkspaceOwnerSshPrivateKey: ownerSSHPrivateKey,
|
||||
WorkspaceBuildId: workspaceBuild.ID.String(),
|
||||
WorkspaceOwnerLoginType: string(owner.LoginType),
|
||||
WorkspaceOwnerRbacRoles: ownerRbacRoles,
|
||||
},
|
||||
LogLevel: input.LogLevel,
|
||||
},
|
||||
|
||||
@@ -377,6 +377,7 @@ func TestAcquireJob(t *testing.T) {
|
||||
WorkspaceOwnerSshPrivateKey: sshKey.PrivateKey,
|
||||
WorkspaceBuildId: build.ID.String(),
|
||||
WorkspaceOwnerLoginType: string(user.LoginType),
|
||||
WorkspaceOwnerRbacRoles: []*sdkproto.Role{{Name: "member", OrgId: pd.OrganizationID.String()}},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user