Skip to content

Commit

Permalink
add container options to kubernetes resource
Browse files Browse the repository at this point in the history
  • Loading branch information
zentron committed Mar 27, 2024
1 parent 5d1a9f0 commit 1a2270b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
5 changes: 5 additions & 0 deletions octopusdeploy/schema_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions octopusdeploy/schema_kubernetes_cluster_deployment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions terraform/47-k8stargetwithcert/machine.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resource octopusdeploy_kubernetes_cluster_deployment_target test_eks{
tenants = []
thumbprint = ""
uri = ""
container_options = "foobar"

endpoint {
communication_style = "Kubernetes"
Expand Down

0 comments on commit 1a2270b

Please sign in to comment.