diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 64d88730ea..8d8c6d96dd 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -20,7 +20,7 @@ jobs: id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3.2.0 + uses: actions/checkout@v3.3.0 - name: Get dependencies run: | diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index 384dc14d54..753f09dfc0 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -6,7 +6,7 @@ jobs: labelIssues: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.2.0 + - uses: actions/checkout@v3.3.0 - name: Apply Issue Labels uses: github/issue-labeler@v2.5 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7271d204f6..7b17d81d82 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3.2.0 + uses: actions/checkout@v3.3.0 - name: Unshallow run: git fetch --prune --unshallow diff --git a/ibm/service/schematics/resource_ibm_schematics_workspace.go b/ibm/service/schematics/resource_ibm_schematics_workspace.go index 7556e205b4..2cd3ecd838 100644 --- a/ibm/service/schematics/resource_ibm_schematics_workspace.go +++ b/ibm/service/schematics/resource_ibm_schematics_workspace.go @@ -224,7 +224,111 @@ func ResourceIBMSchematicsWorkspace() *schema.Resource { Optional: true, Computed: true, Description: "List of values metadata.", - Elem: &schema.Schema{Type: schema.TypeMap}, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Type of the variable.", + }, + "aliases": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The list of aliases for the variable name.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The description of the meta data.", + }, + "cloud_data_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Cloud data type of the variable. eg. resource_group_id, region, vpc_id.", + }, + "default_value": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Default value for the variable only if the override value is not specified.", + }, + "link_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The status of the link.", + }, + "secure": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "Is the variable secure or sensitive ?.", + }, + "immutable": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "Is the variable readonly ?.", + }, + "hidden": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "If **true**, the variable is not displayed on UI or Command line.", + }, + "required": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "If the variable required?.", + }, + "options": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The list of possible values for this variable. If type is **integer** or **date**, then the array of string is converted to array of integers or date during the runtime.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "min_value": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The minimum value of the variable. Applicable for the integer type.", + }, + "max_value": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The maximum value of the variable. Applicable for the integer type.", + }, + "min_length": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The minimum length of the variable value. Applicable for the string type.", + }, + "max_length": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The maximum length of the variable value. Applicable for the string type.", + }, + "matches": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The regex for the variable value.", + }, + "position": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "The relative position of this variable in a list.", + }, + "group_by": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The display name of the group this variable belongs to.", + }, + "source": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The source of this meta-data.", + }, + }, + }, }, "template_inputs": { Type: schema.TypeList, @@ -759,7 +863,8 @@ func resourceIBMSchematicsWorkspaceMapToTemplateSourceDataRequest(templateSource if templateSourceDataRequestMap["values_metadata"] != nil { valuesMetadata := make([]schematicsv1.VariableMetadata, 0) for _, valuesMetadataItem := range templateSourceDataRequestMap["values_metadata"].([]interface{}) { - valuesMetadata = append(valuesMetadata, valuesMetadataItem.(schematicsv1.VariableMetadata)) + valuesMetadataItemModel := resourceIBMSchematicsWorkspaceMapToWorkspaceValuesMetadataRequest(valuesMetadataItem.(map[string]interface{})) + valuesMetadata = append(valuesMetadata, valuesMetadataItemModel) } templateSourceDataRequest.ValuesMetadata = valuesMetadata } @@ -775,6 +880,69 @@ func resourceIBMSchematicsWorkspaceMapToTemplateSourceDataRequest(templateSource return templateSourceDataRequest } +func resourceIBMSchematicsWorkspaceMapToWorkspaceValuesMetadataRequest(workspaceValuesMetadataRequestMap map[string]interface{}) schematicsv1.VariableMetadata { + workspaceValuesMetadataRequest := schematicsv1.VariableMetadata{} + + if workspaceValuesMetadataRequestMap["cloud_data_type"] != nil { + workspaceValuesMetadataRequest.CloudDataType = core.StringPtr(workspaceValuesMetadataRequestMap["cloud_data_type"].(string)) + } + if workspaceValuesMetadataRequestMap["default_value"] != nil { + workspaceValuesMetadataRequest.DefaultValue = core.StringPtr(workspaceValuesMetadataRequestMap["default_value"].(string)) + } + if workspaceValuesMetadataRequestMap["link_status"] != nil { + workspaceValuesMetadataRequest.LinkStatus = core.StringPtr(workspaceValuesMetadataRequestMap["link_status"].(string)) + } + if workspaceValuesMetadataRequestMap["required"] != nil { + workspaceValuesMetadataRequest.Required = core.BoolPtr(workspaceValuesMetadataRequestMap["required"].(bool)) + } + if workspaceValuesMetadataRequestMap["hidden"] != nil { + workspaceValuesMetadataRequest.Hidden = core.BoolPtr(workspaceValuesMetadataRequestMap["hidden"].(bool)) + } + if workspaceValuesMetadataRequestMap["immutable"] != nil { + workspaceValuesMetadataRequest.Immutable = core.BoolPtr(workspaceValuesMetadataRequestMap["immutable"].(bool)) + } + if workspaceValuesMetadataRequestMap["options"] != nil { + workspaceValuesMetadataRequest.Options = workspaceValuesMetadataRequestMap["options"].([]string) + } + if workspaceValuesMetadataRequestMap["aliases"] != nil { + workspaceValuesMetadataRequest.Aliases = workspaceValuesMetadataRequestMap["aliases"].([]string) + } + if workspaceValuesMetadataRequestMap["matches"] != nil { + workspaceValuesMetadataRequest.Matches = core.StringPtr(workspaceValuesMetadataRequestMap["matches"].(string)) + } + if workspaceValuesMetadataRequestMap["source"] != nil { + workspaceValuesMetadataRequest.Source = core.StringPtr(workspaceValuesMetadataRequestMap["source"].(string)) + } + if workspaceValuesMetadataRequestMap["group_by"] != nil { + workspaceValuesMetadataRequest.GroupBy = core.StringPtr(workspaceValuesMetadataRequestMap["group_by"].(string)) + } + if workspaceValuesMetadataRequestMap["max_length"] != nil { + workspaceValuesMetadataRequest.MaxLength = core.Int64Ptr(workspaceValuesMetadataRequestMap["max_length"].(int64)) + } + if workspaceValuesMetadataRequestMap["min_length"] != nil { + workspaceValuesMetadataRequest.MinLength = core.Int64Ptr(workspaceValuesMetadataRequestMap["min_length"].(int64)) + } + if workspaceValuesMetadataRequestMap["max_value"] != nil { + workspaceValuesMetadataRequest.MaxValue = core.Int64Ptr(workspaceValuesMetadataRequestMap["max_value"].(int64)) + } + if workspaceValuesMetadataRequestMap["min_value"] != nil { + workspaceValuesMetadataRequest.MinValue = core.Int64Ptr(workspaceValuesMetadataRequestMap["min_value"].(int64)) + } + if workspaceValuesMetadataRequestMap["position"] != nil { + workspaceValuesMetadataRequest.Position = core.Int64Ptr(workspaceValuesMetadataRequestMap["position"].(int64)) + } + if workspaceValuesMetadataRequestMap["description"] != nil { + workspaceValuesMetadataRequest.Description = core.StringPtr(workspaceValuesMetadataRequestMap["description"].(string)) + } + if workspaceValuesMetadataRequestMap["secure"] != nil { + workspaceValuesMetadataRequest.Secure = core.BoolPtr(workspaceValuesMetadataRequestMap["secure"].(bool)) + } + if workspaceValuesMetadataRequestMap["type"] != nil { + workspaceValuesMetadataRequest.Type = core.StringPtr(workspaceValuesMetadataRequestMap["type"].(string)) + } + + return workspaceValuesMetadataRequest +} func resourceIBMSchematicsWorkspaceMapToWorkspaceVariableRequest(workspaceVariableRequestMap map[string]interface{}) schematicsv1.WorkspaceVariableRequest { workspaceVariableRequest := schematicsv1.WorkspaceVariableRequest{} @@ -1257,10 +1425,18 @@ func resourceIBMSchematicsWorkspaceTemplateSourceDataResponseToMap(templateSourc templateSourceDataResponseMap["folder"] = templateSourceDataResponse.Folder templateSourceDataResponseMap["uninstall_script_name"] = templateSourceDataResponse.UninstallScriptName templateSourceDataResponseMap["values"] = templateSourceDataResponse.Values + // if templateSourceDataResponse.ValuesMetadata != nil { + // valuesMetadata := []interface{}{} + // for _, valuesMetadataItem := range templateSourceDataResponse.ValuesMetadata { + // valuesMetadata = append(valuesMetadata, valuesMetadataItem) + // } + // templateSourceDataResponseMap["values_metadata"] = valuesMetadata + // } if templateSourceDataResponse.ValuesMetadata != nil { - valuesMetadata := []interface{}{} + valuesMetadata := []map[string]interface{}{} for _, valuesMetadataItem := range templateSourceDataResponse.ValuesMetadata { - valuesMetadata = append(valuesMetadata, valuesMetadataItem) + valuesMetadataItemMap := dataSourceIbmSchematicsWorkspaceVariableMetadataToMap(&valuesMetadataItem) + valuesMetadata = append(valuesMetadata, valuesMetadataItemMap) } templateSourceDataResponseMap["values_metadata"] = valuesMetadata } diff --git a/website/docs/r/schematics_workspace.html.markdown b/website/docs/r/schematics_workspace.html.markdown index a85b53f2b7..69d51cd954 100644 --- a/website/docs/r/schematics_workspace.html.markdown +++ b/website/docs/r/schematics_workspace.html.markdown @@ -64,6 +64,28 @@ Nested scheme for **shared_data**: * `template_uninstall_script_name` - (Optional, String) Uninstall script name. * `template_values` - (Optional, String) A list of variable values that you want to apply during the Helm chart installation. The list must be provided in JSON format, such as `"autoscaling: enabled: true minReplicas: 2"`. The values that you define here override the default Helm chart values. This field is supported only for IBM Cloud catalog offerings that are provisioned by using the Terraform Helm provider. * `template_values_metadata` - (Optional, List) List of values metadata. +Nested scheme for **template_values_metadata**: + * `aliases` - (Optional, List) The list of aliases for the variable name. + * `cloud_data_type` - (Optional, String) Cloud data type of the variable. eg. resource_group_id, region, vpc_id. + * `default_value` - (Optional, String) Default value for the variable only if the override value is not specified. + * `description` - (Optional, String) The description of the meta data. + * `group_by` - (Optional, String) The display name of the group this variable belongs to. + * `hidden` - (Optional, Boolean) If **true**, the variable is not displayed on UI or Command line. + * `immutable` - (Optional, Boolean) Is the variable readonly ?. + * `link_status` - (Optional, String) The status of the link. + * Constraints: Allowable values are: `normal`, `broken`. + * `matches` - (Optional, String) The regex for the variable value. + * `max_length` - (Optional, Integer) The maximum length of the variable value. Applicable for the string type. + * `max_value` - (Optional, Integer) The maximum value of the variable. Applicable for the integer type. + * `min_length` - (Optional, Integer) The minimum length of the variable value. Applicable for the string type. + * `min_value` - (Optional, Integer) The minimum value of the variable. Applicable for the integer type. + * `options` - (Optional, List) The list of possible values for this variable. If type is **integer** or **date**, then the array of string is converted to array of integers or date during the runtime. + * `position` - (Optional, Integer) The relative position of this variable in a list. + * `required` - (Optional, Boolean) If the variable required?. + * `secure` - (Optional, Boolean) Is the variable secure or sensitive ?. + * `source` - (Optional, String) The source of this meta-data. + * `type` - (Optional, String) Type of the variable. + * Constraints: Allowable values are: `boolean`, `string`, `integer`, `date`, `array`, `list`, `map`, `complex`, `link`. * `template_inputs` - (Optional, List) VariablesRequest -. Nested scheme for **variablestore**: * `description` - (Optional, String) The description of your input variable.