forked from Azure/azure-service-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for RoleDefinition resource
This fixes Azure#2570.
- Loading branch information
Showing
31 changed files
with
5,334 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
v2/api/authorization/customizations/role_definition_extension_types_gen.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// Code generated by azure-service-operator-codegen. DO NOT EDIT. | ||
github.com/Azure/azure-service-operator/v2/api/authorization/customizations | ||
└── RoleAssignmentExtension: Object (0 properties) | ||
├── RoleAssignmentExtension: Object (0 properties) | ||
└── RoleDefinitionExtension: Object (0 properties) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
v2/api/authorization/v1api20220401/role_definition_defaults.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Copyright (c) Microsoft Corporation. | ||
Licensed under the MIT license. | ||
*/ | ||
|
||
package v1api20220401 | ||
|
||
import ( | ||
"github.com/Azure/azure-service-operator/v2/internal/util/randextensions" | ||
"github.com/Azure/azure-service-operator/v2/pkg/genruntime" | ||
) | ||
|
||
var _ genruntime.Defaulter = &RoleDefinition{} | ||
|
||
func (definition *RoleDefinition) CustomDefault() { | ||
definition.defaultAzureName() | ||
} | ||
|
||
// defaultAzureName performs special AzureName defaulting for RoleDefinition by generating a stable GUID | ||
// based on the Role name. | ||
// We generate the UUID using UUIDv5 with a seed string based on the group+kind of the RoleDefinition and the | ||
// namespace+name it's deployed into. | ||
// We include the namespace and name to ensure no two RoleDefinitions in the same cluster can end up | ||
// with the same UUID. | ||
// We include the group and kind to ensure that different kinds of resources get different UUIDs. This isn't | ||
// entirely required by Azure, but it makes sense to avoid collisions between two resources of different types | ||
// even if they have the same namespace and name. | ||
// In the rare case users have multiple ASO instances with resources in the same namespace in each cluster | ||
// having the same name but not actually pointing to the same Azure resource (maybe in a different subscription?) | ||
// they can avoid name conflicts by explicitly specifying AzureName for their RoleDefinition. | ||
func (definition *RoleDefinition) defaultAzureName() { | ||
// If owner is not set we can't default AzureName, but the request will be rejected anyway for lack of owner. | ||
if definition.Spec.Owner == nil { | ||
return | ||
} | ||
|
||
if definition.AzureName() == "" { | ||
gk := definition.GroupVersionKind().GroupKind() | ||
definition.Spec.AzureName = randextensions.MakeUUIDName( | ||
definition.Name, | ||
randextensions.MakeUniqueOwnerScopedString( | ||
definition.Owner(), | ||
gk, | ||
definition.Namespace, | ||
definition.Name)) | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
v2/api/authorization/v1api20220401/role_definition_spec_arm_types_gen.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.