-
Notifications
You must be signed in to change notification settings - Fork 666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug fix #5723
Merged
Merged
bug fix #5723
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
required_version = ">=1.0.0, <2.0" | ||
required_providers { | ||
ibm = { | ||
source = "terraform.local/ibm-cloud/ibm" | ||
source = "registry.terraform.io/ibm-cloud/ibm" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ package configurationaggregator | |
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
@@ -77,75 +78,17 @@ func DataSourceIbmConfigAggregatorConfigurations() *schema.Resource { | |
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"about": &schema.Schema{ | ||
Type: schema.TypeList, | ||
Type: schema.TypeMap, | ||
Computed: true, | ||
Description: "The basic metadata fetched from the query API.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"account_id": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The account ID in which the resource exists.", | ||
}, | ||
"config_type": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The type of configuration of the retrieved resource.", | ||
}, | ||
"resource_crn": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The unique CRN of the IBM Cloud resource.", | ||
}, | ||
"resource_group_id": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The account ID.", | ||
}, | ||
"service_name": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The name of the service to which the resources belongs.", | ||
}, | ||
"resource_name": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "User defined name of the resource.", | ||
}, | ||
"last_config_refresh_time": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Date/time stamp identifying when the information was last collected. Must be in the RFC 3339 format.", | ||
}, | ||
"location": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Location of the resource specified.", | ||
}, | ||
"tags": &schema.Schema{ | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Description: "Tags associated with the resource.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"tag": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The name of the tag.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
}, | ||
"config": &schema.Schema{ | ||
Type: schema.TypeList, | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The configuration of the resource.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -166,8 +109,6 @@ func dataSourceIbmConfigAggregatorConfigurationsRead(context context.Context, d | |
instanceId := d.Get("instance_id").(string) | ||
log.Printf("Fetching config for instance_id: %s", instanceId) | ||
configurationAggregatorClient = getClientWithConfigurationInstanceEndpoint(configurationAggregatorClient, instanceId, region) | ||
fmt.Println("Logging endpoint from datasource") | ||
fmt.Println(configurationAggregatorClient.GetServiceURL()) | ||
|
||
listConfigsOptions := &configurationaggregatorv1.ListConfigsOptions{} | ||
|
||
|
@@ -244,12 +185,12 @@ func DataSourceIbmConfigAggregatorConfigurationsConfigToMap(model *configuration | |
if err != nil { | ||
return modelMap, err | ||
} | ||
modelMap["about"] = []map[string]interface{}{aboutMap} | ||
modelMap["about"] = aboutMap | ||
configMap, err := DataSourceIbmConfigAggregatorConfigurationsConfigurationToMap(model.Config) | ||
if err != nil { | ||
return modelMap, err | ||
} | ||
modelMap["config"] = []map[string]interface{}{configMap} | ||
modelMap["config"] = configMap | ||
return modelMap, nil | ||
} | ||
|
||
|
@@ -263,13 +204,7 @@ func DataSourceIbmConfigAggregatorConfigurationsAboutToMap(model *configurationa | |
modelMap["resource_name"] = *model.ResourceName | ||
modelMap["last_config_refresh_time"] = model.LastConfigRefreshTime.String() | ||
modelMap["location"] = *model.Location | ||
if model.Tags != nil { | ||
tagsMap, err := DataSourceIbmConfigAggregatorConfigurationsTagsToMap(model.Tags) | ||
if err != nil { | ||
return modelMap, err | ||
} | ||
modelMap["tags"] = []map[string]interface{}{tagsMap} | ||
} | ||
// modelMap["tags"] = make(map[string]interface{}) | ||
return modelMap, nil | ||
} | ||
|
||
|
@@ -281,7 +216,16 @@ func DataSourceIbmConfigAggregatorConfigurationsTagsToMap(model *configurationag | |
return modelMap, nil | ||
} | ||
|
||
func DataSourceIbmConfigAggregatorConfigurationsConfigurationToMap(model *configurationaggregatorv1.Configuration) (map[string]interface{}, error) { | ||
modelMap := make(map[string]interface{}) | ||
return modelMap, nil | ||
func DataSourceIbmConfigAggregatorConfigurationsConfigurationToMap(model *configurationaggregatorv1.Configuration) (string, error) { | ||
checkMap := model.GetProperties() | ||
tryMap := make(map[string]interface{}) | ||
for i, v := range checkMap { | ||
tryMap[i] = v | ||
} | ||
jsonData, err := json.Marshal(tryMap) | ||
if err != nil { | ||
return "", err | ||
} | ||
fmt.Println(string(jsonData)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this fmt stmt |
||
return string(jsonData), nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go with Typemap then we have limitation from Terraform only can hold only string type. If you have combination of multiple types (string ,int, bool) then this will not be compatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you think of declaring it string as json
https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_key#credentials_json chk this code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All fields of this attribute are of type string so there is no modification required.