Skip to content

Commit

Permalink
Add k8s_hubble parameter to k8s resource (#402)
Browse files Browse the repository at this point in the history
* add k8s_hubble parameter to k8s resource

* update k8s resource doc
  • Loading branch information
nvthongswansea authored Nov 11, 2024
1 parent b94e21b commit 443d3a7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gridscale/resource_gridscale_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ func (rgk8sm *ResourceGridscaleK8sModeler) buildInputSchema() map[string]*schema
Computed: true,
Optional: true,
},
"k8s_hubble": {
Type: schema.TypeBool,
Description: "Enables Hubble Integration.",
Computed: true,
Optional: true,
},
}
}

Expand Down Expand Up @@ -754,6 +760,13 @@ func resourceGridscaleK8sRead(d *schema.ResourceData, meta interface{}) error {
}
}

// Set hubble if it is set
if hubble, isHubbleSet := props.Parameters["k8s_hubble"].(bool); isHubbleSet {
if err = d.Set("k8s_hubble", hubble); err != nil {
return fmt.Errorf("%s error setting k8s_hubble: %v", errorPrefix, err)
}
}

//Get listen ports
listenPorts := make([]interface{}, 0)
for _, value := range props.ListenPorts {
Expand Down Expand Up @@ -1010,6 +1023,12 @@ func resourceGridscaleK8sCreate(d *schema.ResourceData, meta interface{}) error
if logDeliveryEndpoint, isLogDeliveryEndpointSet := d.GetOk("log_delivery_endpoint"); isLogDeliveryEndpointSet {
parameters["k8s_log_delivery_endpoint"] = logDeliveryEndpoint
}

// Set hubble if it is set
if hubble, isHubbleSet := d.GetOk("hubble"); isHubbleSet {
parameters["k8s_hubble"] = hubble.(bool)
}

requestBody.Parameters = parameters

ctx, cancel := context.WithTimeout(context.Background(), d.Timeout(schema.TimeoutCreate))
Expand Down Expand Up @@ -1176,6 +1195,11 @@ func resourceGridscaleK8sUpdate(d *schema.ResourceData, meta interface{}) error
if logDeliveryEndpoint, isLogDeliveryEndpointSet := d.GetOk("log_delivery_endpoint"); isLogDeliveryEndpointSet {
parameters["k8s_log_delivery_endpoint"] = logDeliveryEndpoint
}

// Set hubble if it is set
if hubble, isHubbleSet := d.GetOk("hubble"); isHubbleSet {
parameters["k8s_hubble"] = hubble
}
requestBody.Parameters = parameters

ctx, cancel := context.WithTimeout(context.Background(), d.Timeout(schema.TimeoutUpdate))
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/k8s.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ The following arguments are supported:

* `oidc_ca_pem` - (Optional) Custom CA from customer in pem format as string.

* `k8s_hubble` - (Optional) Enable Hubble for the k8s cluster.


## Timeouts

Expand Down Expand Up @@ -140,6 +142,7 @@ This resource exports the following attributes:
* `oidc_username_prefix` - See Argument Reference above.
* `oidc_required_claim` - See Argument Reference above.
* `oidc_ca_pem` - See Argument Reference above.
* `k8s_hubble` - See Argument Reference above.
* `usage_in_minutes` - The amount of minutes the IP address has been in use.
* `create_time` - The time the object was created.
* `change_time` - Defines the date and time of the last object change.
Expand Down

0 comments on commit 443d3a7

Please sign in to comment.