Skip to content

Commit

Permalink
Add host set resource
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferai committed Sep 14, 2020
1 parent 306ebfe commit 595ef90
Show file tree
Hide file tree
Showing 8 changed files with 320 additions and 284 deletions.
13 changes: 9 additions & 4 deletions internal/provider/const.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package provider

const (
NameKey = "name"
DescriptionKey = "description"
ScopeIdKey = "scope_id"
TypeKey = "type"
// Key used for common "name" resource attribute
NameKey = "name"
// Key used for common "description" resource attribute
DescriptionKey = "description"
// Key used for common "scope_id" resource attribute
ScopeIdKey = "scope_id"
// Key used for common "type" resource attribute
TypeKey = "type"
// Key used for common "host_catalog_id" resource attribute
HostCatalogIdKey = "host_catalog_id"
)
250 changes: 0 additions & 250 deletions internal/provider/needs-porting/resource_host_set.go

This file was deleted.

2 changes: 1 addition & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ func New() *schema.Provider {
"boundary_group": resourceGroup(),
"boundary_host": resourceHost(),
"boundary_host_catalog": resourceHostCatalog(),
"boundary_host_set": resourceHostset(),
"boundary_scope": resourceScope(),
"boundary_user": resourceUser(),
/*
"boundary_host_set": resourceHostset(),
"boundary_role": resourceRole(),
"boundary_target": resourceTarget(),
*/
Expand Down
11 changes: 6 additions & 5 deletions internal/provider/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ func resourceGroupCreate(ctx context.Context, d *schema.ResourceData, meta inter
return diag.Errorf("error setting principals on role: %v", err)
}

if err := d.Set(groupMemberIdsKey, memberIds); err != nil {
return diag.FromErr(err)
}
d.Set(groupMemberIdsKey, memberIds)
}

if name != nil {
Expand Down Expand Up @@ -199,13 +197,16 @@ func resourceGroupUpdate(ctx context.Context, d *schema.ResourceData, meta inter
d.Set(DescriptionKey, desc)
}

// The above call may not actually happen, so we use d.Id() and automatic
// versioning here
if d.HasChange(groupMemberIdsKey) {
var memberIds []string
if membersVal, ok := d.GetOk(groupMemberIdsKey); ok {
members := membersVal.(*schema.Set).List()
for _, member := range members {
memberIds = append(memberIds, member.(string))
}

}
_, apiErr, err := grps.SetMembers(
ctx,
Expand All @@ -214,10 +215,10 @@ func resourceGroupUpdate(ctx context.Context, d *schema.ResourceData, meta inter
memberIds,
groups.WithAutomaticVersioning(true))
if err != nil {
return diag.Errorf("error updating members on group: %v", err)
return diag.Errorf("error updating members in group: %v", err)
}
if apiErr != nil {
return diag.Errorf("error updating members on group: %s", apiErr.Message)
return diag.Errorf("error updating members in group: %s", apiErr.Message)
}
d.Set(groupMemberIdsKey, memberIds)
}
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/resource_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func resourceHostCreate(ctx context.Context, d *schema.ResourceData, meta interf
return diag.Errorf("no type provided")
}
switch typeStr {
// NOTE: When other types are added, ensure they don't accept address if
// it's not allowed
case hostTypeStatic:
if address != nil {
opts = append(opts, hosts.WithStaticHostAddress(*address))
Expand Down
Loading

0 comments on commit 595ef90

Please sign in to comment.