Skip to content

Commit

Permalink
Add containerinfra nodegroup support for mergelabels
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@cern.ch>
  • Loading branch information
MrFreezeex committed Jun 16, 2022
1 parent 7c84936 commit 8d96bba
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions openstack/resource_openstack_containerinfra_nodegroup_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ func resourceContainerInfraNodeGroupV1() *schema.Resource {
Computed: true,
},

"merge_labels": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},

"role": {
Type: schema.TypeString,
ForceNew: true,
Expand Down Expand Up @@ -168,6 +174,11 @@ func resourceContainerInfraNodeGroupV1Create(ctx context.Context, d *schema.Reso
createOpts.MaxNodeCount = &maxNodeCount
}

mergeLabels := d.Get("merge_labels").(bool)
if mergeLabels {
createOpts.MergeLabels = &mergeLabels
}

log.Printf("[DEBUG] openstack_containerinfra_nodegroup_v1 create options: %#v", createOpts)

clusterId := d.Get("cluster_id").(string)
Expand Down Expand Up @@ -219,8 +230,12 @@ func resourceContainerInfraNodeGroupV1Read(_ context.Context, d *schema.Resource

log.Printf("[DEBUG] Retrieved openstack_containerinfra_nodegroup_v1 %s: %#v", d.Id(), nodeGroup)

if err := d.Set("labels", nodeGroup.Labels); err != nil {
return diag.Errorf("Unable to set labels: %s", err)
labels := nodeGroup.Labels
if d.Get("merge_labels").(bool) {
labels = containerInfraV1GetLabelsMerged(nodeGroup.LabelsAdded, nodeGroup.LabelsOverridden, nodeGroup.Labels)
}
if err := d.Set("labels", labels); err != nil {
return diag.Errorf("Unable to set openstack_containerinfra_nodegroup_v1 labels: %s", err)
}

d.Set("cluster_id", clusterId)
Expand Down

0 comments on commit 8d96bba

Please sign in to comment.