-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3/X] DXCDT-461: Remove permissions field from role resource (#714)
Co-authored-by: Will Vedder <willvedd@gmail.com>
- Loading branch information
Showing
17 changed files
with
2,947 additions
and
5,852 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package role | ||
|
||
import ( | ||
"github.com/auth0/go-auth0/management" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
|
||
"github.com/auth0/terraform-provider-auth0/internal/value" | ||
) | ||
|
||
func expandRole(data *schema.ResourceData) *management.Role { | ||
cfg := data.GetRawConfig() | ||
|
||
return &management.Role{ | ||
Name: value.String(cfg.GetAttr("name")), | ||
Description: value.String(cfg.GetAttr("description")), | ||
} | ||
} |
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,30 @@ | ||
package role | ||
|
||
import ( | ||
"github.com/auth0/go-auth0/management" | ||
"github.com/hashicorp/go-multierror" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func flattenRole(data *schema.ResourceData, role *management.Role, permissions []*management.Permission) error { | ||
result := multierror.Append( | ||
data.Set("name", role.GetName()), | ||
data.Set("description", role.GetDescription()), | ||
data.Set("permissions", flattenRolePermissions(permissions)), | ||
) | ||
|
||
return result.ErrorOrNil() | ||
} | ||
|
||
func flattenRolePermissions(permissions []*management.Permission) []interface{} { | ||
var result []interface{} | ||
for _, permission := range permissions { | ||
result = append(result, map[string]interface{}{ | ||
"name": permission.GetName(), | ||
"description": permission.GetDescription(), | ||
"resource_server_identifier": permission.GetResourceServerIdentifier(), | ||
"resource_server_name": permission.GetResourceServerName(), | ||
}) | ||
} | ||
return result | ||
} |
Oops, something went wrong.