Skip to content

Commit

Permalink
terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardo-angelilli committed Dec 20, 2023
1 parent 952d7c9 commit af5d9f9
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 27 deletions.
32 changes: 23 additions & 9 deletions ibm/service/project/resource_ibm_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,17 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[s
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
model.Inputs = newMap
}
}
if modelMap["settings"] != nil {
bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Settings = newMap
if len(newMap) > 0 {
model.Settings = newMap
}
}
if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 {
ComplianceProfileModel, err := resourceIbmProjectMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{}))
Expand All @@ -616,7 +620,7 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[s
if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" {
model.LocatorID = core.StringPtr(modelMap["locator_id"].(string))
}
if modelMap["resource_crns"] != nil {
if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 {
resourceCrns := []string{}
for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) {
resourceCrns = append(resourceCrns, resourceCrnsItem.(string))
Expand Down Expand Up @@ -682,13 +686,17 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlockDAConfigDefinit
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
model.Inputs = newMap
}
}
if modelMap["settings"] != nil {
bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Settings = newMap
if len(newMap) > 0 {
model.Settings = newMap
}
}
if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 {
ComplianceProfileModel, err := resourceIbmProjectMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{}))
Expand Down Expand Up @@ -725,15 +733,19 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlockResourceConfigD
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
model.Inputs = newMap
}
}
if modelMap["settings"] != nil {
bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Settings = newMap
if len(newMap) > 0 {
model.Settings = newMap
}
}
if modelMap["resource_crns"] != nil {
if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 {
resourceCrns := []string{}
for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) {
resourceCrns = append(resourceCrns, resourceCrnsItem.(string))
Expand Down Expand Up @@ -778,7 +790,9 @@ func resourceIbmProjectMapToEnvironmentDefinitionRequiredProperties(modelMap map
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
model.Inputs = newMap
}
}
if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 {
ComplianceProfileModel, err := resourceIbmProjectMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{}))
Expand Down
56 changes: 40 additions & 16 deletions ibm/service/project/resource_ibm_project_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,13 +658,17 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
model.Inputs = newMap
}
}
if modelMap["settings"] != nil {
bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Settings = newMap
if len(newMap) > 0 {
model.Settings = newMap
}
}
if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 {
ComplianceProfileModel, err := resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{}))
Expand All @@ -676,7 +680,7 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap
if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" {
model.LocatorID = core.StringPtr(modelMap["locator_id"].(string))
}
if modelMap["resource_crns"] != nil {
if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 {
resourceCrns := []string{}
for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) {
resourceCrns = append(resourceCrns, resourceCrnsItem.(string))
Expand Down Expand Up @@ -742,13 +746,17 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlockDAConfigD
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
model.Inputs = newMap
}
}
if modelMap["settings"] != nil {
bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Settings = newMap
if len(newMap) > 0 {
model.Settings = newMap
}
}
if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 {
ComplianceProfileModel, err := resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{}))
Expand Down Expand Up @@ -785,15 +793,19 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlockResourceC
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
model.Inputs = newMap
}
}
if modelMap["settings"] != nil {
bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Settings = newMap
if len(newMap) > 0 {
model.Settings = newMap
}
}
if modelMap["resource_crns"] != nil {
if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 {
resourceCrns := []string{}
for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) {
resourceCrns = append(resourceCrns, resourceCrnsItem.(string))
Expand Down Expand Up @@ -833,13 +845,17 @@ func resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlock(modelMap map
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
model.Inputs = newMap
}
}
if modelMap["settings"] != nil {
bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Settings = newMap
if len(newMap) > 0 {
model.Settings = newMap
}
}
if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 {
ComplianceProfileModel, err := resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{}))
Expand All @@ -851,7 +867,7 @@ func resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlock(modelMap map
if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" {
model.LocatorID = core.StringPtr(modelMap["locator_id"].(string))
}
if modelMap["resource_crns"] != nil {
if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 {
resourceCrns := []string{}
for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) {
resourceCrns = append(resourceCrns, resourceCrnsItem.(string))
Expand Down Expand Up @@ -883,13 +899,17 @@ func resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlockDAConfigDefin
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
model.Inputs = newMap
}
}
if modelMap["settings"] != nil {
bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Settings = newMap
if len(newMap) > 0 {
model.Settings = newMap
}
}
if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 {
ComplianceProfileModel, err := resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{}))
Expand Down Expand Up @@ -926,15 +946,19 @@ func resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlockResourceConfi
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
model.Inputs = newMap
}
}
if modelMap["settings"] != nil {
bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Settings = newMap
if len(newMap) > 0 {
model.Settings = newMap
}
}
if modelMap["resource_crns"] != nil {
if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 {
resourceCrns := []string{}
for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) {
resourceCrns = append(resourceCrns, resourceCrnsItem.(string))
Expand Down
8 changes: 6 additions & 2 deletions ibm/service/project/resource_ibm_project_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ func resourceIbmProjectEnvironmentMapToEnvironmentDefinitionRequiredProperties(m
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
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{}))
Expand Down Expand Up @@ -445,7 +447,9 @@ func resourceIbmProjectEnvironmentMapToEnvironmentDefinitionProperties(modelMap
bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{}))
newMap := make(map[string]interface{})
json.Unmarshal(bytes, &newMap)
model.Inputs = newMap
if len(newMap) > 0 {
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{}))
Expand Down

0 comments on commit af5d9f9

Please sign in to comment.