From 1bb8e0577ebba4c965e2deda0b997f0300168e3f Mon Sep 17 00:00:00 2001 From: Riccardo Angelilli Date: Fri, 8 Dec 2023 17:00:36 +0100 Subject: [PATCH] Regenerate Projects TF to fix generated doc and samples (#4961) * fix integration test * fix integration test * fix integration test * fix name * pr comments * pr comments * fix doc * fix doc * new version * new version * new version * new version * update code to the latest SDK level * fix integration tests * fix integration tests * fix integration tests * fix integration tests * address PR comment * 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 --------- Co-authored-by: dvesperini Co-authored-by: knee-na <130502432+knee-na@users.noreply.github.com> Co-authored-by: Mark-Kulube --- .secrets.baseline | 44 +++---- examples/ibm-project/README.md | 4 +- examples/ibm-project/main.tf | 8 +- go.mod | 2 +- go.sum | 6 +- .../project/data_source_ibm_project_config.go | 53 ++++---- .../data_source_ibm_project_config_test.go | 4 +- .../data_source_ibm_project_environment.go | 24 ++-- ibm/service/project/resource_ibm_project.go | 33 ++--- .../project/resource_ibm_project_config.go | 113 ++++++++---------- .../resource_ibm_project_environment.go | 54 ++++----- website/docs/d/project_config.html.markdown | 12 +- .../docs/d/project_environment.html.markdown | 7 +- website/docs/r/project_config.html.markdown | 18 +-- .../docs/r/project_environment.html.markdown | 3 +- 15 files changed, 159 insertions(+), 226 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 3a62206e9a..0d0d86addf 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-11-29T02:05:13Z", + "generated_at": "2023-12-05T09:48:48Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -560,7 +560,7 @@ "hashed_secret": "06d988e96c3d9325c9fbc7c0ef3c6c0f2b4eb8e7", "is_secret": false, "is_verified": false, - "line_number": 45, + "line_number": 41, "type": "Secret Keyword", "verified_result": null } @@ -794,7 +794,7 @@ "hashed_secret": "c427f185ddcb2440be9b77c8e45f1cd487a2e790", "is_secret": false, "is_verified": false, - "line_number": 1449, + "line_number": 1450, "type": "Base64 High Entropy String", "verified_result": null }, @@ -802,7 +802,7 @@ "hashed_secret": "1f7e33de15e22de9d2eaf502df284ed25ca40018", "is_secret": false, "is_verified": false, - "line_number": 1516, + "line_number": 1517, "type": "Secret Keyword", "verified_result": null }, @@ -810,7 +810,7 @@ "hashed_secret": "1f614c2eb6b3da22d89bd1b9fd47d7cb7c8fc670", "is_secret": false, "is_verified": false, - "line_number": 3325, + "line_number": 3326, "type": "Secret Keyword", "verified_result": null }, @@ -818,7 +818,7 @@ "hashed_secret": "7abfce65b8504403afc25c9790f358d513dfbcc6", "is_secret": false, "is_verified": false, - "line_number": 3338, + "line_number": 3339, "type": "Secret Keyword", "verified_result": null }, @@ -826,7 +826,7 @@ "hashed_secret": "0c2d85bf9a9b1579b16f220a4ea8c3d62b2e24b1", "is_secret": false, "is_verified": false, - "line_number": 3379, + "line_number": 3380, "type": "Secret Keyword", "verified_result": null } @@ -864,7 +864,7 @@ "hashed_secret": "c8b6f5ef11b9223ac35a5663975a466ebe7ebba9", "is_secret": false, "is_verified": false, - "line_number": 1807, + "line_number": 1815, "type": "Secret Keyword", "verified_result": null }, @@ -872,7 +872,7 @@ "hashed_secret": "8abf4899c01104241510ba87685ad4de76b0c437", "is_secret": false, "is_verified": false, - "line_number": 1813, + "line_number": 1821, "type": "Secret Keyword", "verified_result": null } @@ -2876,7 +2876,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 334, + "line_number": 335, "type": "Secret Keyword", "verified_result": null }, @@ -2884,7 +2884,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 654, + "line_number": 663, "type": "Secret Keyword", "verified_result": null } @@ -2904,7 +2904,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 119, + "line_number": 120, "type": "Secret Keyword", "verified_result": null }, @@ -2912,7 +2912,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 293, + "line_number": 298, "type": "Secret Keyword", "verified_result": null } @@ -2932,7 +2932,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 236, + "line_number": 237, "type": "Secret Keyword", "verified_result": null }, @@ -2940,7 +2940,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 884, + "line_number": 875, "type": "Secret Keyword", "verified_result": null } @@ -2960,7 +2960,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 72, + "line_number": 73, "type": "Secret Keyword", "verified_result": null }, @@ -2968,7 +2968,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 504, + "line_number": 499, "type": "Secret Keyword", "verified_result": null } @@ -4505,16 +4505,6 @@ "verified_result": null } ], - "website/docs/r/logs_router_tenant.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 78, - "type": "Secret Keyword", - "verified_result": null - } - ], "website/docs/r/metrics_router_route.html.markdown": [ { "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 8d4faefa78..479c92419c 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -69,8 +69,8 @@ data "project" "project_instance" { project_environment data source: ```hcl -data "ibm_project_environment" "project_environment_instance" { - project_id = ibm_project_environment.project_environment_instance.project_id +data "project_environment" "project_environment_instance" { + project_id = ibm_project.project_instance.id project_environment_id = ibm_project_environment.project_environment_instance.project_environment_id } ``` diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index 038e99910a..f07c03de9e 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -13,13 +13,9 @@ resource "ibm_project_config" "project_config_instance" { api_key = "" } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" - input { + inputs = { name = "app_repo_name" } - setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" - } } } @@ -61,5 +57,5 @@ data "ibm_project" "project_instance" { // Create project_environment data source data "ibm_project_environment" "project_environment_instance" { project_id = ibm_project.project_instance.id - project_environment_id = var.project_environment_project_environment_id + project_environment_id = ibm_project_environment.project_environment_instance.project_environment_id } diff --git a/go.mod b/go.mod index fe7c351529..fdf9de1fb1 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/IBM/logs-router-go-sdk v1.0.0 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.54.0 - github.com/IBM/project-go-sdk v0.1.1 + github.com/IBM/project-go-sdk v0.1.4 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.1.3 github.com/IBM/schematics-go-sdk v0.2.2 diff --git a/go.sum b/go.sum index 77c54968b8..f53d313116 100644 --- a/go.sum +++ b/go.sum @@ -100,8 +100,6 @@ github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3 github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.4.4/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/IBM-Cloud/bluemix-go v0.0.0-20231123082353-50e8cc9c6959 h1:dvvI4ybsYx6M7fFGrg3HjlNnYxEBi9jJdSU0JhjJbG8= -github.com/IBM-Cloud/bluemix-go v0.0.0-20231123082353-50e8cc9c6959/go.mod h1:jIGLnIfj+uBv2ALz3rVHzNbNwt0V/bEWNeJKECa8Q+k= github.com/IBM-Cloud/bluemix-go v0.0.0-20231204080125-462fa9e436bc h1:AeooCa6UMWycgKJ9n0do9PEZaNlYZZHqspfwUzPvopc= github.com/IBM-Cloud/bluemix-go v0.0.0-20231204080125-462fa9e436bc/go.mod h1:jIGLnIfj+uBv2ALz3rVHzNbNwt0V/bEWNeJKECa8Q+k= github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20231106114255-c50117860a3c h1:tRS4VuOG3lHNG+yrsh3vZZQDVNLuFJB0oZbTJp9YXds= @@ -161,8 +159,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.54.0 h1:WjHWm9ZAJvlq07E1WXXtEe+d/B0sazWD6cEWVT7EMLU= github.com/IBM/platform-services-go-sdk v0.54.0/go.mod h1:CWSprvsCsXWvujmBzbtoJSmbRZS9FVV3O594b0t/GiM= -github.com/IBM/project-go-sdk v0.1.1 h1:x1PkGUTkKpgxoXs/6IG4U1mk5BgaPEaRMVpXTs52rE4= -github.com/IBM/project-go-sdk v0.1.1/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.1.4 h1:QGehJxpp/QqfrBYSmN2FRYwuGejlHlVscB/9QGQfdLk= +github.com/IBM/project-go-sdk v0.1.4/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4= github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5/go.mod h1:b07XHUVh0XYnQE9s2mqgjYST1h9buaQNqN4EcKhOsX0= github.com/IBM/sarama v1.41.2 h1:ZDBZfGPHAD4uuAtSv4U22fRZBgst0eEwGFzLj0fb85c= diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 38ddf87947..8fadc48a9f 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -135,7 +136,7 @@ func DataSourceIbmProjectConfig() *schema.Resource { "workspace_crn": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "An existing schematics workspace CRN.", + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", }, "validate_pre_script": &schema.Schema{ Type: schema.TypeList, @@ -377,22 +378,22 @@ func DataSourceIbmProjectConfig() *schema.Resource { "locator_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "A unique concatenation of catalogID.versionID that identifies the DA in the catalog.", + Description: "A unique concatenation of catalogID.versionID that identifies the DA in the catalog. Either schematics.workspace_crn, definition.locator_id, or both must be specified.", }, "inputs": &schema.Schema{ - Type: schema.TypeList, + Type: schema.TypeMap, Computed: true, Description: "The input variables for configuration definition and environment.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, "settings": &schema.Schema{ - Type: schema.TypeList, + Type: schema.TypeMap, Computed: true, - Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, }, @@ -626,18 +627,26 @@ func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *proje } modelMap["locator_id"] = model.LocatorID if model.Inputs != nil { - inputsMap, err := dataSourceIbmProjectConfigInputVariableToMap(model.Inputs) - if err != nil { - return modelMap, err + 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) } - modelMap["inputs"] = []map[string]interface{}{inputsMap} + modelMap["inputs"] = inputs } if model.Settings != nil { - settingsMap, err := dataSourceIbmProjectConfigProjectConfigSettingToMap(model.Settings) - if err != nil { - return modelMap, err + 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) } - modelMap["settings"] = []map[string]interface{}{settingsMap} + modelMap["settings"] = settings } return modelMap, nil } @@ -675,13 +684,3 @@ func dataSourceIbmProjectConfigProjectComplianceProfileToMap(model *projectv1.Pr } return modelMap, nil } - -func dataSourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index 785e6ff684..e009ba0704 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -56,8 +56,8 @@ func testAccCheckIbmProjectConfigDataSourceConfigBasic() string { authorizations { method = "api_key" api_key = "%s" - } - locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" + } + locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.cd596f95-95a2-4f21-9b84-477f21fd1e95-global" } lifecycle { ignore_changes = [ diff --git a/ibm/service/project/data_source_ibm_project_environment.go b/ibm/service/project/data_source_ibm_project_environment.go index e42f488a05..dc095eea94 100644 --- a/ibm/service/project/data_source_ibm_project_environment.go +++ b/ibm/service/project/data_source_ibm_project_environment.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -126,11 +127,11 @@ func DataSourceIbmProjectEnvironment() *schema.Resource { }, }, "inputs": &schema.Schema{ - Type: schema.TypeList, + Type: schema.TypeMap, Computed: true, Description: "The input variables for configuration definition and environment.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, "compliance_profile": &schema.Schema{ @@ -265,11 +266,15 @@ func dataSourceIbmProjectEnvironmentEnvironmentDefinitionRequiredPropertiesToMap modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } if model.Inputs != nil { - inputsMap, err := dataSourceIbmProjectEnvironmentInputVariableToMap(model.Inputs) - if err != nil { - return modelMap, err + 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) } - modelMap["inputs"] = []map[string]interface{}{inputsMap} + modelMap["inputs"] = inputs } if model.ComplianceProfile != nil { complianceProfileMap, err := dataSourceIbmProjectEnvironmentProjectComplianceProfileToMap(model.ComplianceProfile) @@ -295,11 +300,6 @@ func dataSourceIbmProjectEnvironmentProjectConfigAuthToMap(model *projectv1.Proj return modelMap, nil } -func dataSourceIbmProjectEnvironmentInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} - func dataSourceIbmProjectEnvironmentProjectComplianceProfileToMap(model *projectv1.ProjectComplianceProfile) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 1147380c19..4e51734983 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -566,19 +567,17 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[s if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) } - if modelMap["inputs"] != nil && len(modelMap["inputs"].([]interface{})) > 0 { - InputsModel, err := resourceIbmProjectMapToInputVariable(modelMap["inputs"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Inputs = InputsModel + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + model.Inputs = newMap } - if modelMap["settings"] != nil && len(modelMap["settings"].([]interface{})) > 0 { - SettingsModel, err := resourceIbmProjectMapToProjectConfigSetting(modelMap["settings"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Settings = SettingsModel + if modelMap["settings"] != nil { + bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + model.Settings = newMap } return model, nil } @@ -617,16 +616,6 @@ func resourceIbmProjectMapToProjectComplianceProfile(modelMap map[string]interfa return model, nil } -func resourceIbmProjectMapToInputVariable(modelMap map[string]interface{}) (*projectv1.InputVariable, error) { - model := &projectv1.InputVariable{} - return model, nil -} - -func resourceIbmProjectMapToProjectConfigSetting(modelMap map[string]interface{}) (*projectv1.ProjectConfigSetting, error) { - model := &projectv1.ProjectConfigSetting{} - return model, nil -} - func resourceIbmProjectMapToSchematicsWorkspace(modelMap map[string]interface{}) (*projectv1.SchematicsWorkspace, error) { model := &projectv1.SchematicsWorkspace{} if modelMap["workspace_crn"] != nil && modelMap["workspace_crn"].(string) != "" { diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 5594fbd5b7..161c7a41f1 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -44,7 +45,7 @@ func ResourceIbmProjectConfig() *schema.Resource { "workspace_crn": &schema.Schema{ Type: schema.TypeString, Optional: true, - Description: "An existing schematics workspace CRN.", + Description: "An IBM Cloud resource name, which uniquely identifies a resource.", }, "validate_pre_script": &schema.Schema{ Type: schema.TypeList, @@ -281,25 +282,19 @@ func ResourceIbmProjectConfig() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - Description: "A unique concatenation of catalogID.versionID that identifies the DA in the catalog.", + Description: "A unique concatenation of catalogID.versionID that identifies the DA in the catalog. Either schematics.workspace_crn, definition.locator_id, or both must be specified.", }, "inputs": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, + Type: schema.TypeMap, Optional: true, Description: "The input variables for configuration definition and environment.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, + Elem: &schema.Schema{Type: schema.TypeString}, }, "settings": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, + Type: schema.TypeMap, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, @@ -649,19 +644,17 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) } - if modelMap["inputs"] != nil && len(modelMap["inputs"].([]interface{})) > 0 { - InputsModel, err := resourceIbmProjectConfigMapToInputVariable(modelMap["inputs"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Inputs = InputsModel + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + model.Inputs = newMap } - if modelMap["settings"] != nil && len(modelMap["settings"].([]interface{})) > 0 { - SettingsModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(modelMap["settings"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Settings = SettingsModel + if modelMap["settings"] != nil { + bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + model.Settings = newMap } return model, nil } @@ -700,16 +693,6 @@ func resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap map[string]i return model, nil } -func resourceIbmProjectConfigMapToInputVariable(modelMap map[string]interface{}) (*projectv1.InputVariable, error) { - model := &projectv1.InputVariable{} - return model, nil -} - -func resourceIbmProjectConfigMapToProjectConfigSetting(modelMap map[string]interface{}) (*projectv1.ProjectConfigSetting, error) { - model := &projectv1.ProjectConfigSetting{} - return model, nil -} - func resourceIbmProjectConfigMapToSchematicsWorkspace(modelMap map[string]interface{}) (*projectv1.SchematicsWorkspace, error) { model := &projectv1.SchematicsWorkspace{} if modelMap["workspace_crn"] != nil && modelMap["workspace_crn"].(string) != "" { @@ -746,19 +729,17 @@ func resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlock(modelMap map if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) } - if modelMap["inputs"] != nil && len(modelMap["inputs"].([]interface{})) > 0 { - InputsModel, err := resourceIbmProjectConfigMapToInputVariable(modelMap["inputs"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Inputs = InputsModel + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + model.Inputs = newMap } - if modelMap["settings"] != nil && len(modelMap["settings"].([]interface{})) > 0 { - SettingsModel, err := resourceIbmProjectConfigMapToProjectConfigSetting(modelMap["settings"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Settings = SettingsModel + if modelMap["settings"] != nil { + bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + model.Settings = newMap } return model, nil } @@ -854,20 +835,30 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *project } modelMap["locator_id"] = model.LocatorID if model.Inputs != nil { - inputsMap, err := resourceIbmProjectConfigInputVariableToMap(model.Inputs) - if err != nil { - return modelMap, err + 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) } - if len(inputsMap) > 0 { - modelMap["inputs"] = []map[string]interface{}{inputsMap} + if len(inputs) > 0 { + modelMap["inputs"] = inputs } } if model.Settings != nil { - settingsMap, err := resourceIbmProjectConfigProjectConfigSettingToMap(model.Settings) - if err != nil { - return modelMap, err + 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) + } + if len(settings) > 0 { + modelMap["settings"] = settings } - modelMap["settings"] = []map[string]interface{}{settingsMap} } return modelMap, nil } @@ -906,16 +897,6 @@ func resourceIbmProjectConfigProjectComplianceProfileToMap(model *projectv1.Proj return modelMap, nil } -func resourceIbmProjectConfigInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} - -func resourceIbmProjectConfigProjectConfigSettingToMap(model *projectv1.ProjectConfigSetting) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} - func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name diff --git a/ibm/service/project/resource_ibm_project_environment.go b/ibm/service/project/resource_ibm_project_environment.go index 3dda07d3a2..d9fa73b4d9 100644 --- a/ibm/service/project/resource_ibm_project_environment.go +++ b/ibm/service/project/resource_ibm_project_environment.go @@ -5,6 +5,7 @@ package project import ( "context" + "encoding/json" "fmt" "log" @@ -79,13 +80,10 @@ func ResourceIbmProjectEnvironment() *schema.Resource { }, }, "inputs": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, + Type: schema.TypeMap, Optional: true, Description: "The input variables for configuration definition and environment.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, + Elem: &schema.Schema{Type: schema.TypeString}, }, "compliance_profile": &schema.Schema{ Type: schema.TypeList, @@ -370,12 +368,11 @@ func resourceIbmProjectEnvironmentMapToEnvironmentDefinitionRequiredProperties(m } model.Authorizations = AuthorizationsModel } - if modelMap["inputs"] != nil && len(modelMap["inputs"].([]interface{})) > 0 { - InputsModel, err := resourceIbmProjectEnvironmentMapToInputVariable(modelMap["inputs"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Inputs = InputsModel + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + model.Inputs = newMap } if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { ComplianceProfileModel, err := resourceIbmProjectEnvironmentMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) @@ -401,11 +398,6 @@ func resourceIbmProjectEnvironmentMapToProjectConfigAuth(modelMap map[string]int return model, nil } -func resourceIbmProjectEnvironmentMapToInputVariable(modelMap map[string]interface{}) (*projectv1.InputVariable, error) { - model := &projectv1.InputVariable{} - return model, nil -} - func resourceIbmProjectEnvironmentMapToProjectComplianceProfile(modelMap map[string]interface{}) (*projectv1.ProjectComplianceProfile, error) { model := &projectv1.ProjectComplianceProfile{} if modelMap["id"] != nil && modelMap["id"].(string) != "" { @@ -441,12 +433,11 @@ func resourceIbmProjectEnvironmentMapToEnvironmentDefinitionProperties(modelMap } model.Authorizations = AuthorizationsModel } - if modelMap["inputs"] != nil && len(modelMap["inputs"].([]interface{})) > 0 { - InputsModel, err := resourceIbmProjectEnvironmentMapToInputVariable(modelMap["inputs"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Inputs = InputsModel + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + model.Inputs = newMap } if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { ComplianceProfileModel, err := resourceIbmProjectEnvironmentMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) @@ -472,12 +463,16 @@ func resourceIbmProjectEnvironmentEnvironmentDefinitionRequiredPropertiesToMap(m modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } if model.Inputs != nil { - inputsMap, err := resourceIbmProjectEnvironmentInputVariableToMap(model.Inputs) - if err != nil { - return modelMap, err + 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) } - if len(inputsMap) > 0 { - modelMap["inputs"] = []map[string]interface{}{inputsMap} + if len(inputs) > 0 { + modelMap["inputs"] = inputs } } if model.ComplianceProfile != nil { @@ -506,11 +501,6 @@ func resourceIbmProjectEnvironmentProjectConfigAuthToMap(model *projectv1.Projec return modelMap, nil } -func resourceIbmProjectEnvironmentInputVariableToMap(model *projectv1.InputVariable) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - return modelMap, nil -} - func resourceIbmProjectEnvironmentProjectComplianceProfileToMap(model *projectv1.ProjectComplianceProfile) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 4db739e668..8a3b1e183b 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -61,14 +61,12 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^\\x00-\\x1F]*$/`. * `environment_id` - (String) The ID of the project environment. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `inputs` - (List) The input variables for configuration definition and environment. - Nested schema for **inputs**: - * `locator_id` - (Forces new resource, String) A unique concatenation of catalogID.versionID that identifies the DA in the catalog. + * `inputs` - (Map) The input variables for configuration definition and environment. + * `locator_id` - (Forces new resource, String) A unique concatenation of catalogID.versionID that identifies the DA in the catalog. Either schematics.workspace_crn, definition.locator_id, or both must be specified. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (String) The configuration name. It is unique within the account across projects and regions. * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `settings` - (List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. - Nested schema for **settings**: + * `settings` - (Map) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. @@ -151,8 +149,8 @@ Nested schema for **schematics**: * Constraints: The maximum length is `256` characters. The minimum length is `0` characters. The value must match regular expression `/$|^(?!\\s)(?!.*\\s$)[^\\x00-\\x1F]*$/`. * `type` - (String) The type of the script. * Constraints: The maximum length is `7` characters. The minimum length is `7` characters. The value must match regular expression `/^(ansible)$/`. - * `workspace_crn` - (String) An existing schematics workspace CRN. - * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `workspace_crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/(?!\\s)(?!.*\\s$)^(crn)[^'"`<>{}\\s\\x00-\\x1F]*/`. * `state` - (String) The state of the configuration. * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. diff --git a/website/docs/d/project_environment.html.markdown b/website/docs/d/project_environment.html.markdown index 3b9420d3fe..e7c6fd774c 100644 --- a/website/docs/d/project_environment.html.markdown +++ b/website/docs/d/project_environment.html.markdown @@ -14,8 +14,8 @@ Provides a read-only data source to retrieve information about a project_environ ```hcl data "ibm_project_environment" "project_environment" { - project_environment_id = ibm_project_environment.project_environment.project_environment_id - project_id = ibm_project_environment.project_environment.project_id + project_environment_id = ibm_project_environment.project_environment_instance.project_environment_id + project_id = ibm_project_environment.project_environment_instance.project_id } ``` @@ -59,8 +59,7 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (String) The description of the environment. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^\\x00-\\x1F]*$/`. - * `inputs` - (List) The input variables for configuration definition and environment. - Nested schema for **inputs**: + * `inputs` - (Map) The input variables for configuration definition and environment. * `name` - (String) The name of the environment. It is unique within the account across projects and regions. * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 995dfa3570..86be477768 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -22,13 +22,9 @@ resource "ibm_project_config" "project_config_instance" { api_key = "" } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" - input { + inputs = { name = "app_repo_name" } - setting { - name = "app_repo_name" - value = "static-website-dev-app-repo" - } } project_id = ibm_project.project_instance.id } @@ -64,14 +60,12 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^\\x00-\\x1F]*$/`. * `environment_id` - (Optional, String) The ID of the project environment. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. - * `inputs` - (Optional, List) The input variables for configuration definition and environment. - Nested schema for **inputs**: - * `locator_id` - (Required, Forces new resource, String) A unique concatenation of catalogID.versionID that identifies the DA in the catalog. + * `inputs` - (Optional, Map) The input variables for configuration definition and environment. + * `locator_id` - (Required, Forces new resource, String) A unique concatenation of catalogID.versionID that identifies the DA in the catalog. Either schematics.workspace_crn, definition.locator_id, or both must be specified. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (Required, String) The configuration name. It is unique within the account across projects and regions. * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. - * `settings` - (Optional, List) Schematics environment variables to use to deploy the configuration.Settings are only available if they were specified when the configuration was initially created. - Nested schema for **settings**: + * `settings` - (Optional, Map) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `schematics` - (Optional, List) A schematics workspace associated to a project configuration, with scripts. @@ -124,8 +118,8 @@ Nested schema for **schematics**: * Constraints: The maximum length is `256` characters. The minimum length is `0` characters. The value must match regular expression `/$|^(?!\\s)(?!.*\\s$)[^\\x00-\\x1F]*$/`. * `type` - (Computed, String) The type of the script. * Constraints: The maximum length is `7` characters. The minimum length is `7` characters. The value must match regular expression `/^(ansible)$/`. - * `workspace_crn` - (Optional, String) An existing schematics workspace CRN. - * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. + * `workspace_crn` - (Optional, String) An IBM Cloud resource name, which uniquely identifies a resource. + * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/(?!\\s)(?!.*\\s$)^(crn)[^'"`<>{}\\s\\x00-\\x1F]*/`. ## Attribute Reference diff --git a/website/docs/r/project_environment.html.markdown b/website/docs/r/project_environment.html.markdown index f9783845eb..99299f2fd4 100644 --- a/website/docs/r/project_environment.html.markdown +++ b/website/docs/r/project_environment.html.markdown @@ -54,8 +54,7 @@ Nested schema for **definition**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^`<>\\x00-\\x1F]*$/`. * `description` - (Optional, String) The description of the environment. * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^\\x00-\\x1F]*$/`. - * `inputs` - (Optional, List) The input variables for configuration definition and environment. - Nested schema for **inputs**: + * `inputs` - (Optional, Map) The input variables for configuration definition and environment. * `name` - (Required, String) The name of the environment. It is unique within the account across projects and regions. * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. * `project_id` - (Required, Forces new resource, String) The unique project ID.