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

Added field hidden to coantainerinfra_v1_clustertemplate #1472

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ func dataSourceContainerInfraClusterTemplateV1() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"hidden": {
Type: schema.TypeBool,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand Down
15 changes: 15 additions & 0 deletions openstack/resource_openstack_containerinfra_clustertemplate_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ func resourceContainerInfraClusterTemplateV1() *schema.Resource {
Optional: true,
ForceNew: false,
},

"hidden": {
Type: schema.TypeBool,
Optional: true,
ForceNew: false,
},
},
}
}
Expand All @@ -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{})
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand Down Expand Up @@ -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"),
),
},
},
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down