Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add k8s_hubble parameter to k8s resource #402

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading