fix: Address conflict in boundary_scope data source schema (#492)
* fix: Modify error message * refact: Rename keys for consistency * fix: Use scope_id in boundary_scope The examples for the boundary_scope data source suggest to use `parent_scope_id`, but the provider is actually expecting `scope_id`.
This commit is contained in:
1 parent
54fd626ae5
commit
63a1d9a5e9
6 files changed
+18
-18
No files matched your search
@@ -15,13 +15,13 @@ Please note that the Global scope will always have an id of "global", and does n
|
||||
```terraform
|
||||
# Retrieve the ID of a Boundary project
|
||||
data "boundary_scope" "org" {
|
||||
name = "SecOps"
|
||||
parent_scope_id = "global"
|
||||
name = "SecOps"
|
||||
scope_id = "global"
|
||||
}
|
||||
|
||||
data "boundary_scope" "project" {
|
||||
name = "2111"
|
||||
parent_scope_id = data.boundary_scope.id
|
||||
name = "2111"
|
||||
scope_id = data.boundary_scope.id
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Retrieve the ID of a Boundary project
|
||||
data "boundary_scope" "org" {
|
||||
name = "SecOps"
|
||||
parent_scope_id = "global"
|
||||
name = "SecOps"
|
||||
scope_id = "global"
|
||||
}
|
||||
|
||||
data "boundary_scope" "project" {
|
||||
name = "2111"
|
||||
parent_scope_id = data.boundary_scope.id
|
||||
name = "2111"
|
||||
scope_id = data.boundary_scope.id
|
||||
}
|
||||
@@ -47,8 +47,8 @@ const (
|
||||
// workerFilter is used for common "worker_filter" resource attribute
|
||||
WorkerFilterKey = "worker_filter"
|
||||
// common User arguments
|
||||
LoginNameKey = "login_name"
|
||||
PrimaryAccountID = "primary_account_id"
|
||||
ScopeKey = "scope"
|
||||
ParentScopeId = "parent_scope_id"
|
||||
LoginNameKey = "login_name"
|
||||
PrimaryAccountIdKey = "primary_account_id"
|
||||
ScopeKey = "scope"
|
||||
ParentScopeIdKey = "parent_scope_id"
|
||||
)
|
||||
@@ -65,7 +65,7 @@ func dataSourceScopeRead(ctx context.Context, d *schema.ResourceData, meta inter
|
||||
|
||||
scpls, err := scp.List(ctx, scopeId, opts...)
|
||||
if err != nil {
|
||||
return diag.Errorf("error calling read scope: %v", err)
|
||||
return diag.Errorf("error calling list scope: %v", err)
|
||||
}
|
||||
if scpls == nil {
|
||||
return diag.Errorf("no scopes found")
|
||||
|
||||
@@ -69,7 +69,7 @@ func dataSourceUser() *schema.Resource {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
ParentScopeId: {
|
||||
ParentScopeIdKey: {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
@@ -89,7 +89,7 @@ func dataSourceUser() *schema.Resource {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
PrimaryAccountID: {
|
||||
PrimaryAccountIdKey: {
|
||||
Description: "Primary account ID.",
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -151,7 +151,7 @@ func setFromUserItem(d *schema.ResourceData, user users.User) error {
|
||||
if err := d.Set(LoginNameKey, user.LoginName); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Set(PrimaryAccountID, user.PrimaryAccountId); err != nil {
|
||||
if err := d.Set(PrimaryAccountIdKey, user.PrimaryAccountId); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ func flattenScopeInfo(scope *scopes.ScopeInfo) []interface{} {
|
||||
m[DescriptionKey] = v
|
||||
}
|
||||
if v := scope.ParentScopeId; v != "" {
|
||||
m[ParentScopeId] = v
|
||||
m[ParentScopeIdKey] = v
|
||||
}
|
||||
if v := scope.Name; v != "" {
|
||||
m[NameKey] = v
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestAccUserDataSource_globalAdminUser(t *testing.T) {
|
||||
resource.TestCheckResourceAttr(dataSourceName, DescriptionKey, "Initial admin user within the \"global\" scope"),
|
||||
resource.TestCheckResourceAttr(dataSourceName, LoginNameKey, "testuser"),
|
||||
resource.TestMatchResourceAttr(dataSourceName, IDKey, regexache.MustCompile(`^u_.+`)),
|
||||
resource.TestMatchResourceAttr(dataSourceName, PrimaryAccountID, regexache.MustCompile(`^acctpw_.+`)),
|
||||
resource.TestMatchResourceAttr(dataSourceName, PrimaryAccountIdKey, regexache.MustCompile(`^acctpw_.+`)),
|
||||
resource.TestCheckResourceAttr(dataSourceName, "authorized_actions.#", "7"),
|
||||
resource.TestCheckResourceAttr(dataSourceName, "scope.0.name", "global"),
|
||||
resource.TestCheckResourceAttr(dataSourceName, "scope.0.id", "global"),
|
||||
|
||||
Reference in new issue
Block a user