Skip to content

Commit e406dfc

Browse files
author
Anthony Berger
committed
fix : set desired_nodes without max_nodes and min_nodes
1 parent b0e7435 commit e406dfc

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

ovh/helpers/helpers.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ func GetNilStringPointerFromData(data interface{}, id string) *string {
229229
// GetNilIntPointerFromDataAndNilIfNotPresent similar to GetNilIntPointerFromData but use terraform function schema.ResourceData.Get instead of schema.ResourceData.GetOk
230230
func GetNilIntPointerFromDataAndNilIfNotPresent(data interface{}, id string) *int {
231231
if resourceData, tok := data.(*schema.ResourceData); tok {
232-
if val, ok := resourceData.GetOk(id); ok {
232+
if val, ok := resourceData.GetOkExists(id); ok {
233233
return GetNilIntPointer(val)
234234
}
235-
return GetNilIntPointer(resourceData.Get(id)) // read the 0 value
235+
return nil //key doesn't exist
236236
} else if mapData, tok := data.(map[string]interface{}); tok {
237237
if val, ok := mapData[id]; ok {
238238
return GetNilIntPointer(val)

ovh/resource_cloud_project_kube_nodepool_test.go

+31-2
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ resource "ovh_cloud_project_kube_nodepool" "pool" {
290290
291291
`
292292

293-
func TestAccCloudProjectKubeNodePool(t *testing.T) {
293+
func TestAccCloudProjectKubeNodePoolRessource(t *testing.T) {
294294
name := acctest.RandomWithPrefix(test_prefix)
295295
region := os.Getenv("OVH_CLOUD_PROJECT_KUBE_REGION_TEST")
296296
version := os.Getenv("OVH_CLOUD_PROJECT_KUBE_VERSION_TEST")
@@ -316,7 +316,13 @@ func TestAccCloudProjectKubeNodePool(t *testing.T) {
316316
region,
317317
version,
318318
)
319-
319+
configWithoutMaxMinNodes := fmt.Sprintf(
320+
testAccCloudProjectKubeNodePoolConfigWithoutMaxMin,
321+
os.Getenv("OVH_CLOUD_PROJECT_SERVICE_TEST"),
322+
name,
323+
region,
324+
version,
325+
)
320326
resource.Test(t, resource.TestCase{
321327
PreCheck: func() {
322328
testAccPreCheckCloud(t)
@@ -325,6 +331,29 @@ func TestAccCloudProjectKubeNodePool(t *testing.T) {
325331
},
326332
Providers: testAccProviders,
327333
Steps: []resource.TestStep{
334+
{
335+
Config: configWithoutMaxMinNodes,
336+
Check: resource.ComposeTestCheckFunc(
337+
resource.TestCheckResourceAttr("ovh_cloud_project_kube.cluster", "region", region),
338+
resource.TestCheckResourceAttrSet("ovh_cloud_project_kube.cluster", "kubeconfig"),
339+
resource.TestCheckResourceAttr("ovh_cloud_project_kube.cluster", "name", name),
340+
resource.TestCheckResourceAttr("ovh_cloud_project_kube.cluster", "version", version),
341+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "name", name),
342+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "flavor_name", "b2-7"),
343+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "desired_nodes", "1"),
344+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "min_nodes", "0"),
345+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "max_nodes", "100"),
346+
347+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.annotations.a1", "av1"),
348+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.finalizers.0", "finalizer.extensions/v1beta1"),
349+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.labels.l1", "lv1"),
350+
351+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.0.effect", "PreferNoSchedule"),
352+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.0.key", "t1"),
353+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.0.value", "tv1"),
354+
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.unschedulable", "false"),
355+
),
356+
},
328357
{
329358
Config: config,
330359
Check: resource.ComposeTestCheckFunc(

0 commit comments

Comments
 (0)