Skip to content

Commit 6ad50d0

Browse files
authored
Merge pull request #811 from CecileRobertMichon/refactor-role-assignments
💎 refactor role assignment service
2 parents 92da24f + 5f99b7c commit 6ad50d0

File tree

13 files changed

+647
-110
lines changed

13 files changed

+647
-110
lines changed

cloud/scope/machine.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package scope
1919
import (
2020
"context"
2121
"encoding/base64"
22+
"k8s.io/apimachinery/pkg/util/uuid"
2223

2324
"github.com/go-logr/logr"
2425
"github.com/pkg/errors"
@@ -146,7 +147,7 @@ func (m *MachineScope) NICSpecs() []azure.NICSpec {
146147
return specs
147148
}
148149

149-
// DiskSpecs returns the public IP specs.
150+
// DiskSpecs returns the disk specs.
150151
func (m *MachineScope) DiskSpecs() []azure.DiskSpec {
151152
spec := azure.DiskSpec{
152153
Name: azure.GenerateOSDiskName(m.Name()),
@@ -155,6 +156,19 @@ func (m *MachineScope) DiskSpecs() []azure.DiskSpec {
155156
return []azure.DiskSpec{spec}
156157
}
157158

159+
// RoleAssignmentSpecs returns the role assignment specs.
160+
func (m *MachineScope) RoleAssignmentSpecs() []azure.RoleAssignmentSpec {
161+
if m.AzureMachine.Spec.Identity == infrav1.VMIdentitySystemAssigned {
162+
return []azure.RoleAssignmentSpec{
163+
{
164+
MachineName: m.Name(),
165+
UUID: string(uuid.NewUUID()),
166+
},
167+
}
168+
}
169+
return []azure.RoleAssignmentSpec{}
170+
}
171+
158172
// Subnet returns the machine's subnet based on its role
159173
func (m *MachineScope) Subnet() *infrav1.SubnetSpec {
160174
if m.IsControlPlane() {

cloud/services/roleassignments/mock_roleassignments/client_mock.go

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cloud/services/roleassignments/mock_roleassignments/doc.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ limitations under the License.
1515
*/
1616

1717
// Run go generate to regenerate this mock.
18-
//go:generate ../../../../hack/tools/bin/mockgen -destination roleassignments_mock.go -package mock_roleassignments -source ../client.go Client
18+
//go:generate ../../../../hack/tools/bin/mockgen -destination client_mock.go -package mock_roleassignments -source ../client.go Client
19+
//go:generate ../../../../hack/tools/bin/mockgen -destination roleassignments_mock.go -package mock_roleassignments -source ../service.go RoleAssignmentScope
20+
//go:generate /usr/bin/env bash -c "cat ../../../../hack/boilerplate/boilerplate.generatego.txt client_mock.go > _client_mock.go && mv _client_mock.go client_mock.go"
1921
//go:generate /usr/bin/env bash -c "cat ../../../../hack/boilerplate/boilerplate.generatego.txt roleassignments_mock.go > _roleassignments_mock.go && mv _roleassignments_mock.go roleassignments_mock.go"
2022
package mock_roleassignments //nolint

0 commit comments

Comments
 (0)