Skip to content

Commit

Permalink
Add add_vpcs and add_placement_groups user grants
Browse files Browse the repository at this point in the history
linodego added support for the `add_vpcs` and `add_placement_group` user
grants in v1.44.0 (linode/linodego#622). This
patch adds support for these fields in the `linode_user` resource.
  • Loading branch information
stvnjacobs committed Jan 16, 2025
1 parent 8c5ed5a commit 98f08dc
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/data-sources/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ The Linode User resource exports the following attributes:

* `add_nodebalancers` - If true, this User may add NodeBalancers.

* `add_placement_groups` - If true, this User may add Placement Groups.

* `add_stackscritps` - If true, this User may add StackScripts.

* `add_volumes` - If true, this User may add Volumes.

* `add_vpcs` - If true, this User may add Virtual Private Clouds (VPCs).

* `cancel_account` - If true, this User may cancel the entire Account.

* `longview_subscription` - If true, this User may manage the Account’s Longview subscription.
Expand Down
4 changes: 4 additions & 0 deletions docs/data-sources/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ Each Linode user will be stored in the `users` attribute and will export the fol

* `add_nodebalancers` - If true, this User may add NodeBalancers.

* `add_placement_groups` - If true, this User may add Placement Groups.

* `add_stackscritps` - If true, this User may add StackScripts.

* `add_volumes` - If true, this User may add Volumes.

* `add_vpcs` - If true, this User may add Virtual Private Clouds (VPCs).

* `cancel_account` - If true, this User may cancel the entire Account.

* `longview_subscription` - If true, this User may manage the Account’s Longview subscription.
Expand Down
4 changes: 4 additions & 0 deletions docs/resources/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ In addition to all the arguments above, the following attributes are exported.

* `add_nodebalancers` - (optional) If true, this User may add NodeBalancers.

* `add_placement_groups` - (optional) If true, this User may add Placement Groups.

* `add_stackscripts` - (optional) If true, this User may add StackScripts.

* `add_vpcs` - (optional) If true, this User may add Virtual Private Clouds (VPCs).

* `cancel_account` - (optional) If true, this User may cancel the entire Account.

* `longview_subscription` - (optional) If true, this User may manage the Account’s Longview subscription.
Expand Down
2 changes: 2 additions & 0 deletions linode/user/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ func flattenGrantsGlobal(global *linodego.GlobalUserGrants) map[string]interface
result["add_linodes"] = global.AddLinodes
result["add_longview"] = global.AddLongview
result["add_nodebalancers"] = global.AddNodeBalancers
result["add_placement_groups"] = global.AddPlacementGroups
result["add_stackscripts"] = global.AddStackScripts
result["add_volumes"] = global.AddVolumes
result["add_vpcs"] = global.AddVPCs
result["cancel_account"] = global.CancelAccount
result["longview_subscription"] = global.LongviewSubscription

Expand Down
2 changes: 2 additions & 0 deletions linode/user/framework_datasource_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ var linodeUserGrantsGlobalObjectType = types.ObjectType{
"add_linodes": types.BoolType,
"add_longview": types.BoolType,
"add_nodebalancers": types.BoolType,
"add_placement_groups": types.BoolType,
"add_stackscripts": types.BoolType,
"add_volumes": types.BoolType,
"add_vpcs": types.BoolType,
"cancel_account": types.BoolType,
"longview_subscription": types.BoolType,
},
Expand Down
2 changes: 2 additions & 0 deletions linode/user/framework_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ func flattenGlobalGrants(ctx context.Context, grants linodego.GlobalUserGrants)
result["add_linodes"] = types.BoolValue(grants.AddLinodes)
result["add_longview"] = types.BoolValue(grants.AddLongview)
result["add_nodebalancers"] = types.BoolValue(grants.AddNodeBalancers)
result["add_placement_groups"] = types.BoolValue(grants.AddPlacementGroups)
result["add_stackscripts"] = types.BoolValue(grants.AddStackScripts)
result["add_volumes"] = types.BoolValue(grants.AddVolumes)
result["add_vpcs"] = types.BoolValue(grants.AddVPCs)
result["cancel_account"] = types.BoolValue(grants.CancelAccount)
result["longview_subscription"] = types.BoolValue(grants.LongviewSubscription)

Expand Down
4 changes: 4 additions & 0 deletions linode/user/framework_models_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ func TestParseUserGrants(t *testing.T) {
AddLinodes: true,
AddLongview: true,
AddNodeBalancers: true,
AddPlacementGroups: true,
AddStackScripts: true,
AddVolumes: true,
AddVPCs: true,
CancelAccount: false,
LongviewSubscription: true,
},
Expand Down Expand Up @@ -147,8 +149,10 @@ func TestParseUserGrants(t *testing.T) {
assert.Contains(t, dataModel.GlobalGrants.String(), "\"add_linodes\":true")
assert.Contains(t, dataModel.GlobalGrants.String(), "\"add_longview\":true")
assert.Contains(t, dataModel.GlobalGrants.String(), "\"add_nodebalancers\":true")
assert.Contains(t, dataModel.GlobalGrants.String(), "\"add_placement_groups\":true")
assert.Contains(t, dataModel.GlobalGrants.String(), "\"add_stackscripts\":true")
assert.Contains(t, dataModel.GlobalGrants.String(), "\"add_volumes\":true")
assert.Contains(t, dataModel.GlobalGrants.String(), "\"add_vpcs\":true")
assert.Contains(t, dataModel.GlobalGrants.String(), "\"cancel_account\":false")
assert.Contains(t, dataModel.GlobalGrants.String(), "\"longview_subscription\":true")
}
2 changes: 2 additions & 0 deletions linode/user/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,10 @@ func expandGrantsGlobal(global map[string]interface{}) linodego.GlobalUserGrants
result.AddLinodes = global["add_linodes"].(bool)
result.AddLongview = global["add_longview"].(bool)
result.AddNodeBalancers = global["add_nodebalancers"].(bool)
result.AddPlacementGroups = global["add_placement_groups"].(bool)
result.AddStackScripts = global["add_stackscripts"].(bool)
result.AddVolumes = global["add_volumes"].(bool)
result.AddVPCs = global["add_vpcs"].(bool)
result.CancelAccount = global["cancel_account"].(bool)
result.LongviewSubscription = global["longview_subscription"].(bool)

Expand Down
4 changes: 4 additions & 0 deletions linode/user/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ func TestAccResourceUser_grants(t *testing.T) {
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_linodes", "true"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_longview", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_nodebalancers", "true"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_placement_groups", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_stackscripts", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_volumes", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_vpcs", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.cancel_account", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.longview_subscription", "false"),
resource.TestCheckResourceAttr(testUserResName, "linode_grant.#", "0"),
Expand All @@ -119,8 +121,10 @@ func TestAccResourceUser_grants(t *testing.T) {
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_linodes", "true"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_longview", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_nodebalancers", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_placement_groups", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_stackscripts", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_volumes", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.add_vpcs", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.cancel_account", "false"),
resource.TestCheckResourceAttr(testUserResName, "global_grants.0.longview_subscription", "false"),
resource.TestCheckResourceAttr(testUserResName, "linode_grant.#", "1"),
Expand Down
12 changes: 12 additions & 0 deletions linode/user/schema_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ func resourceLinodeUserGrantsGlobal() *schema.Resource {
Optional: true,
Default: false,
},
"add_placement_groups": {
Type: schema.TypeBool,
Description: "If true, this User may add Placement Groups.",
Optional: true,
Default: false,
},
"add_stackscripts": {
Type: schema.TypeBool,
Description: "If true, this User may add StackScripts.",
Expand All @@ -117,6 +123,12 @@ func resourceLinodeUserGrantsGlobal() *schema.Resource {
Optional: true,
Default: false,
},
"add_vpcs": {
Type: schema.TypeBool,
Description: "If true, this User may add Virtual Private Clouds (VPCs).",
Optional: true,
Default: false,
},
"cancel_account": {
Type: schema.TypeBool,
Description: "If true, this User may cancel the entire Account.",
Expand Down

0 comments on commit 98f08dc

Please sign in to comment.