-
Notifications
You must be signed in to change notification settings - Fork 205
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 (#4067)
* Update RoleAssignment test API version * Re-record tests using the newer API version. * Make it easier to run manual upgrade tests Split Taskfile targets more to make it easier to run manual upgrade tests where the flow is: 1. Install GA ASO. 2. Perform manual testing step. 3. Upgrade to vNext ASO. 4. Perform manual testing step. * Add support for RoleDefinition resource This fixes #2570. * Fix uniqueness bug with RoleAssignment owned by ARM ID Fix bug where RoleAssignment owned by ARM ID doesn't account for the ARM ID in the seed of the random UUID generate. This bugfix is BREAKING if the owner is using ARM ID and in the following cases: * User migrates RoleAssignment from one cluster to another. * User sets reconcile-policy: skip, deletes the RoleAssignment and then recreates it. In the above two cases, the new correct algorithm will consider the ARM ID of the owner and generate a different UUID than before. Other cases such as standard updates will not be impacted as Kubernetes sends the WHOLE object to the mutating webhook and for updates the object contains the (old) generated UUID. * Fix file format
- Loading branch information
Showing
38 changed files
with
7,802 additions
and
1,702 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
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
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.