Skip to content

Commit

Permalink
Change user tags to set
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Kita committed Oct 2, 2024
1 parent b77c23a commit 4dc5143
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 0 additions & 1 deletion ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const (
Arg_SysType = "pi_sys_type"
Arg_TargetStorageTier = "pi_target_storage_tier"
Arg_UserData = "pi_user_data"
Arg_UserTags = "pi_user_tags"
Arg_VirtualCoresAssigned = "pi_virtual_cores_assigned"
Arg_VirtualOpticalDevice = "pi_virtual_optical_device"
Arg_VolumeCloneName = "pi_volume_clone_name"
Expand Down
9 changes: 5 additions & 4 deletions ibm/service/power/resource_ibm_pi_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ func ResourceIBMPIHost() *schema.Resource {
Type: schema.TypeString,
},
Attr_UserTags: {
Description: "List of user tags.",
Description: "List of user tags attached to the resource.",
Elem: &schema.Schema{Type: schema.TypeString},
ForceNew: true,
Optional: true,
Type: schema.TypeList,
Set: schema.HashString,
Type: schema.TypeSet,
},
},
},
Expand Down Expand Up @@ -184,8 +185,8 @@ func resourceIBMPIHostCreate(ctx context.Context, d *schema.ResourceData, meta i
DisplayName: core.StringPtr(host[Attr_DisplayName].(string)),
SysType: core.StringPtr(host[Attr_SysType].(string)),
}
if len(host[Attr_UserTags].([]interface{})) > 0 {
hs.UserTags = flex.ExpandStringList(host[Attr_UserTags].([]interface{}))
if len(flex.FlattenSet(host[Attr_UserTags].(*schema.Set))) > 0 {
hs.UserTags = flex.FlattenSet(host[Attr_UserTags].(*schema.Set))
}
hostBody = append(hostBody, &hs)
}
Expand Down
12 changes: 10 additions & 2 deletions ibm/service/power/resource_ibm_pi_host_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ func ResourceIBMPIHostGroup() *schema.Resource {
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
},
Attr_UserTags: {
Description: "List of user tags attached to the resource.",
Elem: &schema.Schema{Type: schema.TypeString},
ForceNew: true,
Optional: true,
Set: schema.HashString,
Type: schema.TypeSet,
},
},
},
Required: true,
Expand Down Expand Up @@ -354,8 +362,8 @@ func hostMapToAddHost(modelMap map[string]interface{}) *models.AddHost {
host := &models.AddHost{}
host.DisplayName = core.StringPtr(modelMap[Attr_DisplayName].(string))
host.SysType = core.StringPtr(modelMap[Attr_SysType].(string))
if len(modelMap[Attr_UserTags].([]interface{})) > 0 {
host.UserTags = flex.ExpandStringList(modelMap[Attr_UserTags].([]interface{}))
if len(flex.FlattenSet(modelMap[Attr_UserTags].(*schema.Set))) > 0 {
host.UserTags = flex.FlattenSet(modelMap[Attr_UserTags].(*schema.Set))
}
return host
}
Expand Down

0 comments on commit 4dc5143

Please sign in to comment.