From 443d3a7d692aa3dfa3961427432c4725be7d51e5 Mon Sep 17 00:00:00 2001 From: Van Thong Nguyen Date: Mon, 11 Nov 2024 18:13:54 +0100 Subject: [PATCH] Add k8s_hubble parameter to k8s resource (#402) * add k8s_hubble parameter to k8s resource * update k8s resource doc --- gridscale/resource_gridscale_k8s.go | 24 ++++++++++++++++++++++++ website/docs/r/k8s.html.md | 3 +++ 2 files changed, 27 insertions(+) diff --git a/gridscale/resource_gridscale_k8s.go b/gridscale/resource_gridscale_k8s.go index 5d50807a..95b950bb 100644 --- a/gridscale/resource_gridscale_k8s.go +++ b/gridscale/resource_gridscale_k8s.go @@ -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, + }, } } @@ -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 { @@ -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)) @@ -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)) diff --git a/website/docs/r/k8s.html.md b/website/docs/r/k8s.html.md index 1dfa0c61..f23abb45 100644 --- a/website/docs/r/k8s.html.md +++ b/website/docs/r/k8s.html.md @@ -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 @@ -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.