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 17, 2022
1 parent 1228248 commit d908d53
Show file tree
Hide file tree
Showing 2 changed files with 20 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.LabelsSkipped, 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
3 changes: 3 additions & 0 deletions website/docs/r/containerinfra_nodegroup_v1.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ The following arguments are supported:
* `labels` - (Optional) The list of key value pairs representing additional
properties of the node group. Changing this creates a new node group.

* `merge_labels` - (Optional) Indicates whether the provided labels should be
merged with cluster labels. Changing this creates a new nodegroup.

* `node_count` - (Optional) The number of nodes for the node group. Changing
this update the number of nodes of the node group.

Expand Down

0 comments on commit d908d53

Please sign in to comment.