From 1a2270b3a63b9f75edf731822605c36177fec7a7 Mon Sep 17 00:00:00 2001 From: zentron Date: Wed, 27 Mar 2024 19:47:19 +1000 Subject: [PATCH] add container options to kubernetes resource --- go.mod | 2 +- go.sum | 4 ++-- octopusdeploy/schema_endpoint.go | 5 +++++ .../schema_kubernetes_cluster_deployment_target.go | 11 +++++++++++ terraform/47-k8stargetwithcert/machine.tf | 1 + 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 208286b84..fecfdc270 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/OctopusDeploy/terraform-provider-octopusdeploy go 1.21 require ( - github.com/OctopusDeploy/go-octopusdeploy/v2 v2.40.0 + github.com/OctopusDeploy/go-octopusdeploy/v2 v2.40.3 github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240314225537-8e0a92384cf9 github.com/google/uuid v1.6.0 github.com/gruntwork-io/terratest v0.41.11 diff --git a/go.sum b/go.sum index 879d694df..ff7f4ed4c 100644 --- a/go.sum +++ b/go.sum @@ -68,8 +68,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.40.0 h1:0Q3Vfbuza9GysMjQk56WphA3Lu2Kw/A/T6suJ78RMec= -github.com/OctopusDeploy/go-octopusdeploy/v2 v2.40.0/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= +github.com/OctopusDeploy/go-octopusdeploy/v2 v2.40.3 h1:Gi3tlcwFJPQe9mmdIV0NcScnHGvOcTFcoM67L+dx6gE= +github.com/OctopusDeploy/go-octopusdeploy/v2 v2.40.3/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240314225537-8e0a92384cf9 h1:uaKQwRn5iIJnHRbRCRQrIRZKd0tqTfnOle6jSXk4wKs= github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240314225537-8e0a92384cf9/go.mod h1:vE83OjlckiC+7quEvpR2KzQq3hvv9b+usqxaNNT4GCs= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= diff --git a/octopusdeploy/schema_endpoint.go b/octopusdeploy/schema_endpoint.go index 7982ac148..4654829e9 100644 --- a/octopusdeploy/schema_endpoint.go +++ b/octopusdeploy/schema_endpoint.go @@ -65,6 +65,7 @@ func flattenEndpointResource(endpoint *machines.EndpointResource) []interface{} "communication_style": endpoint.CommunicationStyle, "connection_endpoint": endpoint.ConnectionEndpoint, "container": flattenContainer(endpoint.Container), + "container_options": endpoint.ContainerOptions, "default_worker_pool_id": endpoint.DefaultWorkerPoolID, "destination": flattenOfflinePackageDropDestination(endpoint.Destination), "dot_net_core_platform": endpoint.DotNetCorePlatform, @@ -191,6 +192,10 @@ func getEndpointSchema() map[string]*schema.Schema { Optional: true, Type: schema.TypeList, }, + "container_options": { + Optional: true, + Type: schema.TypeString, + }, "default_worker_pool_id": { Optional: true, Type: schema.TypeString, diff --git a/octopusdeploy/schema_kubernetes_cluster_deployment_target.go b/octopusdeploy/schema_kubernetes_cluster_deployment_target.go index ac59a6072..6dcbd6a35 100644 --- a/octopusdeploy/schema_kubernetes_cluster_deployment_target.go +++ b/octopusdeploy/schema_kubernetes_cluster_deployment_target.go @@ -46,6 +46,10 @@ func expandKubernetesClusterDeploymentTarget(d *schema.ResourceData) *machines.D endpoint.Container = expandContainer(v) } + if v, ok := d.GetOk("container_options"); ok { + endpoint.ContainerOptions = v.(string) + } + if v, ok := d.GetOk("default_worker_pool_id"); ok { endpoint.DefaultWorkerPoolID = v.(string) } @@ -86,6 +90,7 @@ func flattenKubernetesClusterDeploymentTarget(deploymentTarget *machines.Deploym flattenedDeploymentTarget["cluster_certificate"] = endpointResource.ClusterCertificate flattenedDeploymentTarget["cluster_certificate_path"] = endpointResource.ClusterCertificatePath flattenedDeploymentTarget["container"] = flattenContainer(endpointResource.Container) + flattenedDeploymentTarget["container_options"] = endpointResource.ContainerOptions flattenedDeploymentTarget["default_worker_pool_id"] = endpointResource.DefaultWorkerPoolID flattenedDeploymentTarget["namespace"] = endpointResource.Namespace flattenedDeploymentTarget["proxy_id"] = endpointResource.ProxyID @@ -212,6 +217,11 @@ func getKubernetesClusterDeploymentTargetSchema() map[string]*schema.Schema { Type: schema.TypeList, } + kubernetesClusterDeploymentTargetSchema["container_options"] = &schema.Schema{ + Optional: true, + Type: schema.TypeString, + } + kubernetesClusterDeploymentTargetSchema["default_worker_pool_id"] = &schema.Schema{ Optional: true, Type: schema.TypeString, @@ -268,6 +278,7 @@ func setKubernetesClusterDeploymentTarget(ctx context.Context, d *schema.Resourc d.Set("proxy_id", endpointResource.ProxyID) d.Set("running_in_container", endpointResource.RunningInContainer) d.Set("skip_tls_verification", endpointResource.SkipTLSVerification) + d.Set("container_options", endpointResource.ContainerOptions) if endpointResource.ClusterURL != nil { d.Set("cluster_url", endpointResource.ClusterURL.String()) diff --git a/terraform/47-k8stargetwithcert/machine.tf b/terraform/47-k8stargetwithcert/machine.tf index 62fb2b838..852fefb62 100644 --- a/terraform/47-k8stargetwithcert/machine.tf +++ b/terraform/47-k8stargetwithcert/machine.tf @@ -19,6 +19,7 @@ resource octopusdeploy_kubernetes_cluster_deployment_target test_eks{ tenants = [] thumbprint = "" uri = "" + container_options = "foobar" endpoint { communication_style = "Kubernetes"