From fabbeee5daa160dffbae2527bab73c10bf13573b Mon Sep 17 00:00:00 2001 From: Bartosz Leszczynski Date: Tue, 31 Jan 2023 11:01:58 +0100 Subject: [PATCH 1/3] Added field hidden to coantainerinfra_v1_clustertemplate --- go.mod | 4 ++-- go.sum | 4 ++++ ...openstack_containerinfra_clustertemplate_v1.go | 6 ++++++ ...tack_containerinfra_clustertemplate_v1_test.go | 1 + ...openstack_containerinfra_clustertemplate_v1.go | 15 +++++++++++++++ ...tack_containerinfra_clustertemplate_v1_test.go | 8 ++++++-- ...ontainerinfra_clustertemplate_v1.html.markdown | 2 ++ ...ontainerinfra_clustertemplate_v1.html.markdown | 5 +++++ 8 files changed, 41 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 29e9369c0..c44d64101 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/terraform-provider-openstack/terraform-provider-openstack go 1.17 require ( - github.com/gophercloud/gophercloud v1.0.1-0.20220927110532-5c912b0995dc + github.com/gophercloud/gophercloud v1.2.0 github.com/gophercloud/utils v0.0.0-20220307143606-8e7800759d16 github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0 github.com/mitchellh/go-homedir v1.1.0 @@ -51,7 +51,7 @@ require ( github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.2 // indirect github.com/zclconf/go-cty v1.10.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/net v0.0.0-20220615171555-694bf12d69de // indirect golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect golang.org/x/text v0.3.7 // indirect diff --git a/go.sum b/go.sum index d46d1c209..7de4fb6b0 100644 --- a/go.sum +++ b/go.sum @@ -101,6 +101,8 @@ github.com/gophercloud/gophercloud v1.0.1-0.20220908162354-a75271e0e3ad h1:SJD7B github.com/gophercloud/gophercloud v1.0.1-0.20220908162354-a75271e0e3ad/go.mod h1:Q8fZtyi5zZxPS/j9aj3sSxtvj41AdQMDwyo1myduD5c= github.com/gophercloud/gophercloud v1.0.1-0.20220927110532-5c912b0995dc h1:sP3Vvq6K7Ql2HjD5svT9q5GfzvIbwSuAYhECS/ktLxU= github.com/gophercloud/gophercloud v1.0.1-0.20220927110532-5c912b0995dc/go.mod h1:Q8fZtyi5zZxPS/j9aj3sSxtvj41AdQMDwyo1myduD5c= +github.com/gophercloud/gophercloud v1.2.0 h1:1oXyj4g54KBg/kFtCdMM6jtxSzeIyg8wv4z1HoGPp1E= +github.com/gophercloud/gophercloud v1.2.0/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM= github.com/gophercloud/utils v0.0.0-20220307143606-8e7800759d16 h1:slt/exMiitZNY+5OrKJ6ZvSogqN+SyzeYzAtyI6db9A= github.com/gophercloud/utils v0.0.0-20220307143606-8e7800759d16/go.mod h1:qOGlfG6OIJ193/c3Xt/XjOfHataNZdQcVgiu93LxBUM= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= @@ -275,6 +277,8 @@ golang.org/x/crypto v0.0.0-20211202192323-5770296d904e h1:MUP6MR3rJ7Gk9LEia0LP2y golang.org/x/crypto v0.0.0-20211202192323-5770296d904e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= diff --git a/openstack/data_source_openstack_containerinfra_clustertemplate_v1.go b/openstack/data_source_openstack_containerinfra_clustertemplate_v1.go index 1b3f2425d..6af6745ee 100644 --- a/openstack/data_source_openstack_containerinfra_clustertemplate_v1.go +++ b/openstack/data_source_openstack_containerinfra_clustertemplate_v1.go @@ -175,6 +175,11 @@ func dataSourceContainerInfraClusterTemplateV1() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "hidden": { + Type: schema.TypeBool, + Computed: true, + }, }, } } @@ -222,6 +227,7 @@ func dataSourceContainerInfraClusterTemplateV1Read(ctx context.Context, d *schem d.Set("server_type", ct.ServerType) d.Set("tls_disabled", ct.TLSDisabled) d.Set("volume_driver", ct.VolumeDriver) + d.Set("hidden", ct.Hidden) if err := d.Set("created_at", ct.CreatedAt.Format(time.RFC3339)); err != nil { log.Printf("[DEBUG] Unable to set openstack_containerinfra_clustertemplate_v1 created_at: %s", err) diff --git a/openstack/data_source_openstack_containerinfra_clustertemplate_v1_test.go b/openstack/data_source_openstack_containerinfra_clustertemplate_v1_test.go index c0be17e07..25284d3bd 100644 --- a/openstack/data_source_openstack_containerinfra_clustertemplate_v1_test.go +++ b/openstack/data_source_openstack_containerinfra_clustertemplate_v1_test.go @@ -65,6 +65,7 @@ func TestAccContainerInfraV1ClusterTemplateDataSource_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "server_type", "vm"), resource.TestCheckResourceAttr(resourceName, "tls_disabled", "false"), resource.TestCheckResourceAttr(resourceName, "volume_driver", "cinder"), + resource.TestCheckResourceAttr(resourceName, "hidden", "false"), ), }, }, diff --git a/openstack/resource_openstack_containerinfra_clustertemplate_v1.go b/openstack/resource_openstack_containerinfra_clustertemplate_v1.go index 4e6f60f59..9ecdfb92c 100644 --- a/openstack/resource_openstack_containerinfra_clustertemplate_v1.go +++ b/openstack/resource_openstack_containerinfra_clustertemplate_v1.go @@ -228,6 +228,12 @@ func resourceContainerInfraClusterTemplateV1() *schema.Resource { Optional: true, ForceNew: false, }, + + "hidden": { + Type: schema.TypeBool, + Optional: true, + ForceNew: false, + }, }, } } @@ -245,6 +251,7 @@ func resourceContainerInfraClusterTemplateV1Create(ctx context.Context, d *schem public := d.Get("public").(bool) registryEnabled := d.Get("registry_enabled").(bool) tlsDisabled := d.Get("tls_disabled").(bool) + hidden := d.Get("hidden").(bool) // Get and check labels map. rawLabels := d.Get("labels").(map[string]interface{}) @@ -278,6 +285,7 @@ func resourceContainerInfraClusterTemplateV1Create(ctx context.Context, d *schem ServerType: d.Get("server_type").(string), TLSDisabled: &tlsDisabled, VolumeDriver: d.Get("volume_driver").(string), + Hidden: &hidden, } // Set int parameters that will be passed by reference. @@ -350,6 +358,7 @@ func resourceContainerInfraClusterTemplateV1Read(_ context.Context, d *schema.Re d.Set("name", s.Name) d.Set("project_id", s.ProjectID) d.Set("user_id", s.UserID) + d.Set("hidden", s.Hidden) if err := d.Set("created_at", s.CreatedAt.Format(time.RFC3339)); err != nil { log.Printf("[DEBUG] Unable to set openstack_containerinfra_clustertemplate_v1 created_at: %s", err) @@ -519,6 +528,12 @@ func resourceContainerInfraClusterTemplateV1Update(ctx context.Context, d *schem updateOpts = containerInfraClusterTemplateV1AppendUpdateOpts(updateOpts, "volume_driver", v) } + if d.HasChange("hidden") { + v := d.Get("hidden").(bool) + hidden := strconv.FormatBool(v) + updateOpts = containerInfraClusterTemplateV1AppendUpdateOpts(updateOpts, "hidden", hidden) + } + log.Printf( "[DEBUG] Updating openstack_containerinfra_clustertemplate_v1 %s with options: %#v", d.Id(), updateOpts) diff --git a/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go b/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go index f08a7cb2b..fe8a50d4d 100644 --- a/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go +++ b/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go @@ -65,6 +65,7 @@ func TestAccContainerInfraV1ClusterTemplate_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "server_type", "vm"), resource.TestCheckResourceAttr(resourceName, "tls_disabled", "false"), resource.TestCheckResourceAttr(resourceName, "volume_driver", "cinder"), + resource.TestCheckResourceAttr(resourceName, "hidden", "false"), ), }, { @@ -105,6 +106,7 @@ func TestAccContainerInfraV1ClusterTemplate_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "server_type", "vm"), resource.TestCheckResourceAttr(resourceName, "tls_disabled", "true"), resource.TestCheckResourceAttr(resourceName, "volume_driver", "cinder"), + resource.TestCheckResourceAttr(resourceName, "hidden", "true"), ), }, }, @@ -197,7 +199,8 @@ resource "openstack_containerinfra_clustertemplate_v1" "clustertemplate_1" { registry_enabled = "true" server_type = "vm" tls_disabled = "false" - volume_driver = "cinder" + volume_driver = "cinder" + hidden = "false" } `, osRegionName, clusterTemplateName, osExtGwID, osMagnumFlavor, osMagnumFlavor, osMagnumHTTPProxy, osMagnumHTTPSProxy, osMagnumImage, osMagnumNoProxy) } @@ -235,7 +238,8 @@ resource "openstack_containerinfra_clustertemplate_v1" "clustertemplate_1" { registry_enabled = "false" server_type = "vm" tls_disabled = "true" - volume_driver = "cinder" + volume_driver = "cinder" + hidden = "true" } `, osRegionName, clusterTemplateName, osExtGwID, osMagnumFlavor, osMagnumFlavor, osMagnumImage) } diff --git a/website/docs/d/containerinfra_clustertemplate_v1.html.markdown b/website/docs/d/containerinfra_clustertemplate_v1.html.markdown index 51ae17ec4..02ff8d0f9 100644 --- a/website/docs/d/containerinfra_clustertemplate_v1.html.markdown +++ b/website/docs/d/containerinfra_clustertemplate_v1.html.markdown @@ -109,3 +109,5 @@ attributes are exported: * `volume_driver` - The name of the driver that is used for the volumes of the cluster nodes. + +* `hidden` - Indicates whether the ClusterTemplate is hidden or not. diff --git a/website/docs/r/containerinfra_clustertemplate_v1.html.markdown b/website/docs/r/containerinfra_clustertemplate_v1.html.markdown index cfaeba4b7..1fab79c97 100644 --- a/website/docs/r/containerinfra_clustertemplate_v1.html.markdown +++ b/website/docs/r/containerinfra_clustertemplate_v1.html.markdown @@ -159,6 +159,10 @@ The following arguments are supported: volumes of the cluster nodes. Changing this updates the volume driver of the existing cluster template. +* `hidden` - (Optional) Indicates whether the ClusterTemplate is hidden or not. + Changing this updates the hidden attribute of the existing cluster + template. + ## Attributes reference The following attributes are exported: @@ -195,6 +199,7 @@ The following attributes are exported: * `server_type` - See Argument Reference above. * `tls_disabled` - See Argument Reference above. * `volume_driver` - See Argument Reference above. +* `hidden` - See Argument Reference above. ## Import From aa89a459be89a942704597d56d9d14670c032556 Mon Sep 17 00:00:00 2001 From: Bartosz Leszczynski Date: Thu, 2 Feb 2023 13:49:41 +0100 Subject: [PATCH 2/3] Fix indent tab->space --- ...source_openstack_containerinfra_clustertemplate_v1_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go b/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go index fe8a50d4d..ea7266f48 100644 --- a/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go +++ b/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go @@ -200,7 +200,7 @@ resource "openstack_containerinfra_clustertemplate_v1" "clustertemplate_1" { server_type = "vm" tls_disabled = "false" volume_driver = "cinder" - hidden = "false" + hidden = "false" } `, osRegionName, clusterTemplateName, osExtGwID, osMagnumFlavor, osMagnumFlavor, osMagnumHTTPProxy, osMagnumHTTPSProxy, osMagnumImage, osMagnumNoProxy) } @@ -239,7 +239,7 @@ resource "openstack_containerinfra_clustertemplate_v1" "clustertemplate_1" { server_type = "vm" tls_disabled = "true" volume_driver = "cinder" - hidden = "true" + hidden = "true" } `, osRegionName, clusterTemplateName, osExtGwID, osMagnumFlavor, osMagnumFlavor, osMagnumImage) } From d80551ab41ee2c36aedd00514370a02aaf4ad0db Mon Sep 17 00:00:00 2001 From: Bartosz Leszczynski Date: Thu, 2 Feb 2023 13:54:26 +0100 Subject: [PATCH 3/3] Fix field indent tab->space --- ...source_openstack_containerinfra_clustertemplate_v1_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go b/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go index ea7266f48..72a584388 100644 --- a/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go +++ b/openstack/resource_openstack_containerinfra_clustertemplate_v1_test.go @@ -200,7 +200,7 @@ resource "openstack_containerinfra_clustertemplate_v1" "clustertemplate_1" { server_type = "vm" tls_disabled = "false" volume_driver = "cinder" - hidden = "false" + hidden = "false" } `, osRegionName, clusterTemplateName, osExtGwID, osMagnumFlavor, osMagnumFlavor, osMagnumHTTPProxy, osMagnumHTTPSProxy, osMagnumImage, osMagnumNoProxy) } @@ -239,7 +239,7 @@ resource "openstack_containerinfra_clustertemplate_v1" "clustertemplate_1" { server_type = "vm" tls_disabled = "true" volume_driver = "cinder" - hidden = "true" + hidden = "true" } `, osRegionName, clusterTemplateName, osExtGwID, osMagnumFlavor, osMagnumFlavor, osMagnumImage) }