From 740cb68591f9ebf8264c30d985cab32da8cb992d Mon Sep 17 00:00:00 2001 From: Riccardo Angelilli Date: Thu, 18 Jan 2024 10:32:17 +0100 Subject: [PATCH] Projects issue #2672 - "Terraform sees inputs as changed when they have not" (#5042) * typo * typo * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * add wait for create and delete * add wait for create and delete * . * fix integration tests * fix integration tests * fix integration tests * fix integration tests * fix integration tests * regenerate * new code generation * new generated code * point to latest sdk * point to latest sdk * adjust test cases and doc * adjust samples * update to latest node sdk * merge with master * Update project_instance.html.markdown Fixing formatting issues * Update project_event_notification.html.markdown * Update README.md * Update variables.tf * Update project_event_notification.html.markdown * new version * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * feat: projects graph fragment pattern * align with origin/master * update test cases * restore README.md and versions.tf to master branch * remove duplicated entries * feat: graph fragment pattern poc * feat: restore definition blocks * regenerate the terraform code based on latest YAML * regenerate the terraform code based on latest YAML * regenerate the terraform code based on latest YAML * update doc * update doc * fix test cases * commit generated code * commit fix * commit fix * test cases * test cases * test cases * test cases * updates * upgrade to latest go sdk * update generated doc * update generated code * updated secrets baseline * update code to latest API changes * secrets * fix secrets * update samples with real values * update secrets * update secrets * update generated code to the latest API definition * update secrets baseline * merge with master * merge with master * merge with master * update code to the latest SDK level * address some review comments * address PR comments * address PR comments * update to latest sdk level * update to latest sdk level * update to latest sdk level * merge with master * update to the latest sdk level * format test case * regenerate the code with generator fixes * regenerate code * fix "inputs" and "settings" properties * regenerated doc and samples * fix samples * terraform * terraform * terraform * terraform * terraform * fix marshal strings * secrets * resolve conflicts --------- Co-authored-by: knee-na <130502432+knee-na@users.noreply.github.com> Co-authored-by: Mark-Kulube --- .secrets.baseline | 38 ++++++++-------- .../project/data_source_ibm_project_config.go | 43 +++---------------- .../data_source_ibm_project_environment.go | 7 +-- .../project/resource_ibm_project_config.go | 42 +++--------------- .../resource_ibm_project_environment.go | 6 +-- 5 files changed, 35 insertions(+), 101 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 41dd2077b3..0a39cbdebe 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2024-01-16T23:03:03Z", + "generated_at": "2024-01-17T17:15:00Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -760,7 +760,7 @@ "hashed_secret": "731438016c5ab94431f61820f35e3ae5f8ad6004", "is_secret": false, "is_verified": false, - "line_number": 436, + "line_number": 434, "type": "Secret Keyword", "verified_result": null }, @@ -768,7 +768,7 @@ "hashed_secret": "12da2e35d6b50c902c014f1ab9e3032650368df7", "is_secret": false, "is_verified": false, - "line_number": 442, + "line_number": 440, "type": "Secret Keyword", "verified_result": null }, @@ -776,7 +776,7 @@ "hashed_secret": "813274ccae5b6b509379ab56982d862f7b5969b6", "is_secret": false, "is_verified": false, - "line_number": 1165, + "line_number": 1175, "type": "Base64 High Entropy String", "verified_result": null } @@ -794,7 +794,7 @@ "hashed_secret": "c427f185ddcb2440be9b77c8e45f1cd487a2e790", "is_secret": false, "is_verified": false, - "line_number": 1451, + "line_number": 1454, "type": "Base64 High Entropy String", "verified_result": null }, @@ -802,7 +802,7 @@ "hashed_secret": "1f7e33de15e22de9d2eaf502df284ed25ca40018", "is_secret": false, "is_verified": false, - "line_number": 1518, + "line_number": 1521, "type": "Secret Keyword", "verified_result": null }, @@ -810,7 +810,7 @@ "hashed_secret": "1f614c2eb6b3da22d89bd1b9fd47d7cb7c8fc670", "is_secret": false, "is_verified": false, - "line_number": 3338, + "line_number": 3342, "type": "Secret Keyword", "verified_result": null }, @@ -818,7 +818,7 @@ "hashed_secret": "7abfce65b8504403afc25c9790f358d513dfbcc6", "is_secret": false, "is_verified": false, - "line_number": 3351, + "line_number": 3355, "type": "Secret Keyword", "verified_result": null }, @@ -826,7 +826,7 @@ "hashed_secret": "0c2d85bf9a9b1579b16f220a4ea8c3d62b2e24b1", "is_secret": false, "is_verified": false, - "line_number": 3392, + "line_number": 3396, "type": "Secret Keyword", "verified_result": null } @@ -846,7 +846,7 @@ "hashed_secret": "da8cae6284528565678de15e03d461e23fe22538", "is_secret": false, "is_verified": false, - "line_number": 1858, + "line_number": 1884, "type": "Secret Keyword", "verified_result": null }, @@ -854,7 +854,7 @@ "hashed_secret": "1a0334cfa65f4be58b9d914b8e96e9d9478bfbac", "is_secret": false, "is_verified": false, - "line_number": 3239, + "line_number": 3265, "type": "Secret Keyword", "verified_result": null } @@ -2900,7 +2900,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 342, + "line_number": 341, "type": "Secret Keyword", "verified_result": null }, @@ -2908,7 +2908,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 700, + "line_number": 687, "type": "Secret Keyword", "verified_result": null } @@ -2928,7 +2928,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 125, + "line_number": 124, "type": "Secret Keyword", "verified_result": null }, @@ -2936,7 +2936,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 307, + "line_number": 302, "type": "Secret Keyword", "verified_result": null } @@ -2964,7 +2964,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 1091, + "line_number": 1107, "type": "Secret Keyword", "verified_result": null } @@ -3062,7 +3062,7 @@ "hashed_secret": "3c2ecad9b250fd6d99893e4d05ec02ca19aa95d0", "is_secret": false, "is_verified": false, - "line_number": 389, + "line_number": 396, "type": "Secret Keyword", "verified_result": null } @@ -4954,7 +4954,7 @@ "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", "is_secret": false, "is_verified": false, - "line_number": 191, + "line_number": 192, "type": "Secret Keyword", "verified_result": null }, @@ -4962,7 +4962,7 @@ "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", "is_secret": false, "is_verified": false, - "line_number": 193, + "line_number": 194, "type": "Secret Keyword", "verified_result": null } diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index b9b7dc91b1..04ac065b5e 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -531,11 +530,7 @@ func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (m if model.Value != nil { value := make(map[string]interface{}) for k, v := range model.Value { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - value[k] = string(bytes) + value[k] = fmt.Sprintf("%v", v) } modelMap["value"] = value } @@ -650,22 +645,14 @@ func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model projec if model.Inputs != nil { inputs := make(map[string]interface{}) for k, v := range model.Inputs { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - inputs[k] = string(bytes) + inputs[k] = fmt.Sprintf("%v", v) } modelMap["inputs"] = inputs } if model.Settings != nil { settings := make(map[string]interface{}) for k, v := range model.Settings { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - settings[k] = string(bytes) + settings[k] = fmt.Sprintf("%v", v) } modelMap["settings"] = settings } @@ -743,22 +730,14 @@ func dataSourceIbmProjectConfigProjectConfigResponseDefinitionDAConfigDefinition if model.Inputs != nil { inputs := make(map[string]interface{}) for k, v := range model.Inputs { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - inputs[k] = string(bytes) + inputs[k] = fmt.Sprintf("%v", v) } modelMap["inputs"] = inputs } if model.Settings != nil { settings := make(map[string]interface{}) for k, v := range model.Settings { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - settings[k] = string(bytes) + settings[k] = fmt.Sprintf("%v", v) } modelMap["settings"] = settings } @@ -796,22 +775,14 @@ func dataSourceIbmProjectConfigProjectConfigResponseDefinitionResourceConfigDefi if model.Inputs != nil { inputs := make(map[string]interface{}) for k, v := range model.Inputs { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - inputs[k] = string(bytes) + inputs[k] = fmt.Sprintf("%v", v) } modelMap["inputs"] = inputs } if model.Settings != nil { settings := make(map[string]interface{}) for k, v := range model.Settings { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - settings[k] = string(bytes) + settings[k] = fmt.Sprintf("%v", v) } modelMap["settings"] = settings } diff --git a/ibm/service/project/data_source_ibm_project_environment.go b/ibm/service/project/data_source_ibm_project_environment.go index 4e052b847b..514e19f289 100644 --- a/ibm/service/project/data_source_ibm_project_environment.go +++ b/ibm/service/project/data_source_ibm_project_environment.go @@ -5,7 +5,6 @@ package project import ( "context" - "encoding/json" "fmt" "log" @@ -277,11 +276,7 @@ func dataSourceIbmProjectEnvironmentEnvironmentDefinitionRequiredPropertiesToMap if model.Inputs != nil { inputs := make(map[string]interface{}) for k, v := range model.Inputs { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - inputs[k] = string(bytes) + inputs[k] = fmt.Sprintf("%v", v) } modelMap["inputs"] = inputs } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index f0ef27eeef..7b748c63c3 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -1059,11 +1059,7 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model projectv if model.Inputs != nil { inputs := make(map[string]interface{}) for k, v := range model.Inputs { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - inputs[k] = string(bytes) + inputs[k] = fmt.Sprintf("%v", v) } if len(inputs) > 0 { modelMap["inputs"] = inputs @@ -1072,11 +1068,7 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model projectv if model.Settings != nil { settings := make(map[string]interface{}) for k, v := range model.Settings { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - settings[k] = string(bytes) + settings[k] = fmt.Sprintf("%v", v) } if len(settings) > 0 { modelMap["settings"] = settings @@ -1160,11 +1152,7 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionDAConfigDefinitionPr if model.Inputs != nil { inputs := make(map[string]interface{}) for k, v := range model.Inputs { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - inputs[k] = string(bytes) + inputs[k] = fmt.Sprintf("%v", v) } if len(inputs) > 0 { modelMap["inputs"] = inputs @@ -1173,11 +1161,7 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionDAConfigDefinitionPr if model.Settings != nil { settings := make(map[string]interface{}) for k, v := range model.Settings { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - settings[k] = string(bytes) + settings[k] = fmt.Sprintf("%v", v) } if len(settings) > 0 { modelMap["settings"] = settings @@ -1219,11 +1203,7 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionResourceConfigDefini if model.Inputs != nil { inputs := make(map[string]interface{}) for k, v := range model.Inputs { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - inputs[k] = string(bytes) + inputs[k] = fmt.Sprintf("%v", v) } if len(inputs) > 0 { modelMap["inputs"] = inputs @@ -1232,11 +1212,7 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionResourceConfigDefini if model.Settings != nil { settings := make(map[string]interface{}) for k, v := range model.Settings { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - settings[k] = string(bytes) + settings[k] = fmt.Sprintf("%v", v) } if len(settings) > 0 { modelMap["settings"] = settings @@ -1257,11 +1233,7 @@ func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map if model.Value != nil { value := make(map[string]interface{}) for k, v := range model.Value { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - value[k] = string(bytes) + value[k] = fmt.Sprintf("%v", v) } modelMap["value"] = value } diff --git a/ibm/service/project/resource_ibm_project_environment.go b/ibm/service/project/resource_ibm_project_environment.go index 615895028e..d44f2b0497 100644 --- a/ibm/service/project/resource_ibm_project_environment.go +++ b/ibm/service/project/resource_ibm_project_environment.go @@ -479,11 +479,7 @@ func resourceIbmProjectEnvironmentEnvironmentDefinitionRequiredPropertiesToMap(m if model.Inputs != nil { inputs := make(map[string]interface{}) for k, v := range model.Inputs { - bytes, err := json.Marshal(v) - if err != nil { - return modelMap, err - } - inputs[k] = string(bytes) + inputs[k] = fmt.Sprintf("%v", v) } if len(inputs) > 0 { modelMap["inputs"] = inputs