From 16fd208323c2452d4c7db2be16d133fc3bcd2f7d Mon Sep 17 00:00:00 2001 From: Olaf Klischat Date: Mon, 12 Feb 2024 23:39:59 +0100 Subject: [PATCH] K8s-9382 optional server group setting for node deployments --- Makefile | 2 +- go.mod | 2 +- go.sum | 4 ++++ metakube/resource_node_deployment_schema.go | 11 +++++++++++ metakube/resource_node_deployment_structure.go | 10 ++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 84aa7d6..2316b3e 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ DOMAIN=syseleven.de NAMESPACE=syseleven PKG_NAME=metakube BINARY=terraform-provider-${PKG_NAME} -VERSION=5.1.0 +VERSION=5.3.0 PLATFORM?=darwin_arm64 SWEEP_DIR?=./metakube SWEEP?=all diff --git a/go.mod b/go.mod index 291d84b..7aea5c8 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 github.com/mitchellh/go-homedir v1.1.0 - github.com/syseleven/go-metakube v0.0.0-20230901105753-2acbd56de0ef + github.com/syseleven/go-metakube v0.0.0-20240214142853-81d7b38e0508 go.uber.org/zap v1.19.0 golang.org/x/mod v0.14.0 ) diff --git a/go.sum b/go.sum index 9460b65..d31eae9 100644 --- a/go.sum +++ b/go.sum @@ -238,6 +238,10 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/syseleven/go-metakube v0.0.0-20230901105753-2acbd56de0ef h1:vHHN4hkSmM1hkdDwO3/Ty3Ywwk5KHF69POdzRmo5sgk= github.com/syseleven/go-metakube v0.0.0-20230901105753-2acbd56de0ef/go.mod h1:Wmf9qWGkFXBGAJxXuwGH+SH6eq9txahkGRpTUz/JFhY= +github.com/syseleven/go-metakube v0.0.0-20240211202621-277eddb8f1a0 h1:pJzmO6gQjkg7z+vWCbZTyOD2V0i2qcJQt5zFCFjlRaA= +github.com/syseleven/go-metakube v0.0.0-20240211202621-277eddb8f1a0/go.mod h1:Wmf9qWGkFXBGAJxXuwGH+SH6eq9txahkGRpTUz/JFhY= +github.com/syseleven/go-metakube v0.0.0-20240214142853-81d7b38e0508 h1:rScPM+QK5iFQgm9rKo88jI9HuDMS9F5MWy22VgLhGVE= +github.com/syseleven/go-metakube v0.0.0-20240214142853-81d7b38e0508/go.mod h1:Wmf9qWGkFXBGAJxXuwGH+SH6eq9txahkGRpTUz/JFhY= github.com/syseleven/terraform-plugin-sdk/v2 v2.31.0-sys11-2 h1:vywVVW9AnKcEiqgbZe16wwuaQaZ8VtMe+xmNBdvdMnU= github.com/syseleven/terraform-plugin-sdk/v2 v2.31.0-sys11-2/go.mod h1:i2C41tszDjiWfziPQDL5R/f3Zp0gahXe5No/MIO9rCE= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= diff --git a/metakube/resource_node_deployment_schema.go b/metakube/resource_node_deployment_schema.go index f00039a..842ec81 100644 --- a/metakube/resource_node_deployment_schema.go +++ b/metakube/resource_node_deployment_schema.go @@ -335,6 +335,17 @@ func matakubeResourceNodeDeploymentCloudOpenstackSchema() map[string]*schema.Sch Description: "Specifies how long should the controller check if instance is ready before timing out", ValidateDiagFunc: isNonEmptyDurationString, }, + "server_group_id": { + Type: schema.TypeString, + Optional: true, + Default: "", + DiffSuppressFunc: func(k, oldValue, newValue string, d *schema.ResourceData) bool { + // if the value is set in the state and unset in the config, the update will not change it + // => suppress the diff + return oldValue != "" && newValue == "" + }, + Description: "Specifies the ID of the server group for nodes in the nodes deployment. Defaults to the cluster setting", + }, } } diff --git a/metakube/resource_node_deployment_structure.go b/metakube/resource_node_deployment_structure.go index d7c4ef6..2c9e4aa 100644 --- a/metakube/resource_node_deployment_structure.go +++ b/metakube/resource_node_deployment_structure.go @@ -246,6 +246,10 @@ func metakubeNodeDeploymentFlattenOpenstackSpec(in *models.OpenstackNodeSpec) [] att["disk_size"] = in.RootDiskSizeGB } + if in.ServerGroupID != "" { + att["server_group_id"] = in.ServerGroupID + } + return []interface{}{att} } @@ -670,6 +674,12 @@ func metakubeNodeDeploymentExpandOpenstackSpec(p []interface{}) *models.Openstac } } + if v, ok := in["server_group_id"]; ok { + if vv, ok := v.(string); ok { + obj.ServerGroupID = vv + } + } + return obj }