-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25900 from oWretch/f/pim-policies
`azurerm_role_management_policy` New resource & data source
- Loading branch information
Showing
47 changed files
with
4,440 additions
and
0 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
66 changes: 66 additions & 0 deletions
66
internal/services/authorization/parse/role_management_policy.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,66 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package parse | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" | ||
) | ||
|
||
type RoleManagementPolicyId struct { | ||
RoleDefinitionId string | ||
Scope string | ||
} | ||
|
||
var _ resourceids.Id = RoleManagementPolicyId{} | ||
|
||
func NewRoleManagementPolicyId(roleDefinitionId string, scope string) RoleManagementPolicyId { | ||
return RoleManagementPolicyId{ | ||
RoleDefinitionId: roleDefinitionId, | ||
Scope: scope, | ||
} | ||
} | ||
|
||
// RoleManagementPolicyID parses 'input' into a RoleManagementPolicyId | ||
func RoleManagementPolicyID(input string) (*RoleManagementPolicyId, error) { | ||
parts := strings.Split(input, "|") | ||
if len(parts) != 2 { | ||
return nil, fmt.Errorf("could not parse Role Management Policy ID, invalid format %q", input) | ||
} | ||
|
||
return &RoleManagementPolicyId{ | ||
RoleDefinitionId: parts[0], | ||
Scope: parts[1], | ||
}, nil | ||
} | ||
|
||
func (id RoleManagementPolicyId) ID() string { | ||
return fmt.Sprintf("%s|%s", id.RoleDefinitionId, id.Scope) | ||
} | ||
|
||
func (id RoleManagementPolicyId) String() string { | ||
components := []string{ | ||
fmt.Sprintf("Role Definition ID: %q", id.RoleDefinitionId), | ||
} | ||
if id.Scope != "" { | ||
components = append(components, fmt.Sprintf("Scope: %q", id.Scope)) | ||
} | ||
return fmt.Sprintf("Role Definition (%s)", strings.Join(components, "\n")) | ||
} | ||
|
||
func ValidateRoleManagementPolicyId(input interface{}, key string) (warnings []string, errors []error) { | ||
v, ok := input.(string) | ||
if !ok { | ||
errors = append(errors, fmt.Errorf("expected %q to be a string", key)) | ||
return | ||
} | ||
|
||
if _, err := RoleManagementPolicyID(v); err != nil { | ||
errors = append(errors, err) | ||
} | ||
|
||
return | ||
} |
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
Oops, something went wrong.