Skip to content

Commit

Permalink
Merge branch 'master' into backup-clone
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwal-ibm committed Feb 20, 2023
2 parents 3c62f8e + e91be0e commit f64c13a
Show file tree
Hide file tree
Showing 20 changed files with 638 additions and 56 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ github.com/IBM/schematics-go-sdk v0.2.1 h1:byATysGD+Z1k/wdtNqQmKALcAPjgSLuSyzcab
github.com/IBM/schematics-go-sdk v0.2.1/go.mod h1:Tw2OSAPdpC69AxcwoyqcYYaGTTW6YpERF9uNEU+BFRQ=
github.com/IBM/secrets-manager-go-sdk v1.0.50-0.20230202132733-fd8f31729d57 h1:/l0OC4K6m+xiruPvXiOtqawg+uwwg+18e8LqEAIUcyk=
github.com/IBM/secrets-manager-go-sdk v1.0.50-0.20230202132733-fd8f31729d57/go.mod h1:QyDSznC6gJEXIGaj+JPxoEVtyXfkaxzId87mxcEb+vM=
github.com/IBM/vpc-go-sdk v0.30.0 h1:OCHTcU6j4tFmpoW/SJD58UjfmtuPz9SvRxc5V9qBY8g=
github.com/IBM/vpc-go-sdk v0.30.0/go.mod h1:jYjS3EySPkC7DuOg33gMHtm8DcIf75Tc+Gxo3zmMBTQ=
github.com/IBM/vpc-go-sdk v0.32.0 h1:LDuU8xkeBISvLc6/artN7aQ1YsdKvDWRXalfsPHUBu4=
github.com/IBM/vpc-go-sdk v0.32.0/go.mod h1:jYjS3EySPkC7DuOg33gMHtm8DcIf75Tc+Gxo3zmMBTQ=
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0=
Expand Down
3 changes: 2 additions & 1 deletion ibm/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,8 @@ func (c *Config) ClientSession() (interface{}, error) {
}
session.bmxUserDetails = userConfig

if sess.SoftLayerSession != nil && sess.SoftLayerSession.IAMToken != "" {
if sess.SoftLayerSession != nil && sess.SoftLayerSession.APIKey == "" {
log.Println("Configuring SoftLayer Session with token from IBM Cloud Session")
sess.SoftLayerSession.IAMToken = sess.BluemixSession.Config.IAMAccessToken
sess.SoftLayerSession.IAMRefreshToken = sess.BluemixSession.Config.IAMRefreshToken
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2022 All Rights Reserved.
// Copyright IBM Corp. 2023 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0

package cdtoolchain
Expand Down Expand Up @@ -91,20 +91,30 @@ func DataSourceIBMCdToolchainToolSecretsmanager() *schema.Resource {
Computed: true,
Description: "The name used to identify this tool integration. Secret references include this name to identify the secrets store where the secrets reside. All secrets store tools integrated into a toolchain should have a unique name to allow secret resolution to function properly.",
},
"instance_id_type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The type of service instance identifier. When absent defaults to `instance-name`.",
},
"instance_name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The name of the Secrets Manager service instance.",
Description: "The name of the Secrets Manager service instance, only relevant when using `instance-name` as the `instance_id_type`.",
},
"instance_crn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The Secrets Manager service instance CRN (Cloud Resource Name), only relevant when using `instance-crn` as the `instance_id_type`.",
},
"location": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The IBM Cloud location where the Secrets Manager service instance is located.",
Description: "The IBM Cloud location of the Secrets Manager service instance, only relevant when using `instance-name` as the `instance_id_type`.",
},
"resource_group_name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The name of the resource group where the Secrets Manager service instance is located.",
Description: "The name of the resource group where the Secrets Manager service instance is located, only relevant when using `instance-name` as the `instance_id_type`.",
},
},
},
Expand Down Expand Up @@ -180,9 +190,11 @@ func dataSourceIBMCdToolchainToolSecretsmanagerRead(context context.Context, d *
parameters := []map[string]interface{}{}
if toolchainTool.Parameters != nil {
remapFields := map[string]string{
"instance_id_type": "instance-id-type",
"location": "region",
"resource_group_name": "resource-group",
"instance_name": "instance-name",
"instance_crn": "instance-crn",
}
modelMap := GetParametersFromRead(toolchainTool.Parameters, DataSourceIBMCdToolchainToolSecretsmanager(), remapFields)
parameters = append(parameters, modelMap)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright IBM Corp. 2022 All Rights Reserved.
// Copyright IBM Corp. 2023 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0

package cdtoolchain
Expand Down Expand Up @@ -46,20 +46,30 @@ func ResourceIBMCdToolchainToolSecretsmanager() *schema.Resource {
Required: true,
Description: "The name used to identify this tool integration. Secret references include this name to identify the secrets store where the secrets reside. All secrets store tools integrated into a toolchain should have a unique name to allow secret resolution to function properly.",
},
"instance_id_type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "The type of service instance identifier. When absent defaults to `instance-name`.",
},
"instance_name": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "The name of the Secrets Manager service instance.",
Optional: true,
Description: "The name of the Secrets Manager service instance, only relevant when using `instance-name` as the `instance_id_type`.",
},
"instance_crn": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "The Secrets Manager service instance CRN (Cloud Resource Name), only relevant when using `instance-crn` as the `instance_id_type`.",
},
"location": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "The IBM Cloud location where the Secrets Manager service instance is located.",
Optional: true,
Description: "The IBM Cloud location of the Secrets Manager service instance, only relevant when using `instance-name` as the `instance_id_type`.",
},
"resource_group_name": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "The name of the resource group where the Secrets Manager service instance is located.",
Optional: true,
Description: "The name of the resource group where the Secrets Manager service instance is located, only relevant when using `instance-name` as the `instance_id_type`.",
},
},
},
Expand Down Expand Up @@ -166,9 +176,11 @@ func resourceIBMCdToolchainToolSecretsmanagerCreate(context context.Context, d *
createToolOptions.SetToolchainID(d.Get("toolchain_id").(string))
createToolOptions.SetToolTypeID("secretsmanager")
remapFields := map[string]string{
"instance_id_type": "instance-id-type",
"location": "region",
"resource_group_name": "resource-group",
"instance_name": "instance-name",
"instance_crn": "instance-crn",
}
parametersModel := GetParametersForCreate(d, ResourceIBMCdToolchainToolSecretsmanager(), remapFields)
createToolOptions.SetParameters(parametersModel)
Expand Down Expand Up @@ -217,9 +229,11 @@ func resourceIBMCdToolchainToolSecretsmanagerRead(context context.Context, d *sc
return diag.FromErr(fmt.Errorf("Error setting toolchain_id: %s", err))
}
remapFields := map[string]string{
"instance_id_type": "instance-id-type",
"location": "region",
"resource_group_name": "resource-group",
"instance_name": "instance-name",
"instance_crn": "instance-crn",
}
parametersMap := GetParametersFromRead(toolchainTool.Parameters, ResourceIBMCdToolchainToolSecretsmanager(), remapFields)
if err = d.Set("parameters", []map[string]interface{}{parametersMap}); err != nil {
Expand Down Expand Up @@ -285,9 +299,11 @@ func resourceIBMCdToolchainToolSecretsmanagerUpdate(context context.Context, d *
}
if d.HasChange("parameters") {
remapFields := map[string]string{
"instance_id_type": "instance-id-type",
"location": "region",
"resource_group_name": "resource-group",
"instance_name": "instance-name",
"instance_crn": "instance-crn",
}
parameters := GetParametersForUpdate(d, ResourceIBMCdToolchainToolSecretsmanager(), remapFields)
patchVals.Parameters = parameters
Expand Down
40 changes: 40 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,32 @@ func DataSourceIBMISInstance() *schema.Resource {
Computed: true,
Description: "Indicates whether the metadata service endpoint is available to the virtual server instance",
},
isInstanceMetadataService: {
Type: schema.TypeList,
Computed: true,
Description: "The metadata service configuration",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
isInstanceMetadataServiceEnabled1: {
Type: schema.TypeBool,
Computed: true,
Description: "Indicates whether the metadata service endpoint will be available to the virtual server instance",
},

isInstanceMetadataServiceProtocol: {
Type: schema.TypeString,
Computed: true,
Description: "The communication protocol to use for the metadata service endpoint. Applies only when the metadata service is enabled.",
},

isInstanceMetadataServiceRespHopLimit: {
Type: schema.TypeInt,
Computed: true,
Description: "The hop limit (IP time to live) for IP response packets from the metadata service",
},
},
},
},
isInstancePEM: {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -713,7 +738,22 @@ func instanceGetByName(d *schema.ResourceData, meta interface{}, name string) er
}
if instance.MetadataService != nil {
d.Set(isInstanceMetadataServiceEnabled, instance.MetadataService.Enabled)

metadataService := []map[string]interface{}{}
metadataServiceMap := map[string]interface{}{}

metadataServiceMap[isInstanceMetadataServiceEnabled1] = instance.MetadataService.Enabled
if instance.MetadataService.Protocol != nil {
metadataServiceMap[isInstanceMetadataServiceProtocol] = instance.MetadataService.Protocol
}
if instance.MetadataService.ResponseHopLimit != nil {
metadataServiceMap[isInstanceMetadataServiceRespHopLimit] = instance.MetadataService.ResponseHopLimit
}

metadataService = append(metadataService, metadataServiceMap)
d.Set(isInstanceMetadataService, metadataService)
}

if instance.AvailabilityPolicy != nil && instance.AvailabilityPolicy.HostFailure != nil {
d.Set(isInstanceAvailablePolicyHostFailure, *instance.AvailabilityPolicy.HostFailure)
}
Expand Down
53 changes: 53 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_instance_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,32 @@ func DataSourceIBMISInstanceTemplate() *schema.Resource {
Computed: true,
Description: "Indicates whether the metadata service endpoint is available to the virtual server instance",
},
isInstanceMetadataService: {
Type: schema.TypeList,
Computed: true,
Description: "The metadata service configuration",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
isInstanceMetadataServiceEnabled1: {
Type: schema.TypeBool,
Computed: true,
Description: "Indicates whether the metadata service endpoint will be available to the virtual server instance",
},

isInstanceMetadataServiceProtocol: {
Type: schema.TypeString,
Computed: true,
Description: "The communication protocol to use for the metadata service endpoint. Applies only when the metadata service is enabled.",
},

isInstanceMetadataServiceRespHopLimit: {
Type: schema.TypeInt,
Computed: true,
Description: "The hop limit (IP time to live) for IP response packets from the metadata service",
},
},
},
},
isInstanceAvailablePolicyHostFailure: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -448,6 +474,20 @@ func dataSourceIBMISInstanceTemplateRead(context context.Context, d *schema.Reso

if instance.MetadataService != nil {
d.Set(isInstanceTemplateMetadataServiceEnabled, instance.MetadataService.Enabled)

metadataService := []map[string]interface{}{}
metadataServiceMap := map[string]interface{}{}

metadataServiceMap[isInstanceMetadataServiceEnabled1] = instance.MetadataService.Enabled
if instance.MetadataService.Protocol != nil {
metadataServiceMap[isInstanceMetadataServiceProtocol] = instance.MetadataService.Protocol
}
if instance.MetadataService.ResponseHopLimit != nil {
metadataServiceMap[isInstanceMetadataServiceRespHopLimit] = instance.MetadataService.ResponseHopLimit
}

metadataService = append(metadataService, metadataServiceMap)
d.Set(isInstanceMetadataService, metadataService)
}

if instance.Profile != nil {
Expand Down Expand Up @@ -729,6 +769,19 @@ func dataSourceIBMISInstanceTemplateRead(context context.Context, d *schema.Reso

if instance.MetadataService != nil {
d.Set(isInstanceTemplateMetadataServiceEnabled, instance.MetadataService.Enabled)
metadataService := []map[string]interface{}{}
metadataServiceMap := map[string]interface{}{}

metadataServiceMap[isInstanceMetadataServiceEnabled1] = instance.MetadataService.Enabled
if instance.MetadataService.Protocol != nil {
metadataServiceMap[isInstanceMetadataServiceProtocol] = instance.MetadataService.Protocol
}
if instance.MetadataService.ResponseHopLimit != nil {
metadataServiceMap[isInstanceMetadataServiceRespHopLimit] = instance.MetadataService.ResponseHopLimit
}

metadataService = append(metadataService, metadataServiceMap)
d.Set(isInstanceMetadataService, metadataService)
}

if instance.Profile != nil {
Expand Down
41 changes: 41 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_instance_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,32 @@ func DataSourceIBMISInstanceTemplates() *schema.Resource {
Computed: true,
Description: "Indicates whether the metadata service endpoint is available to the virtual server instance",
},
isInstanceMetadataService: {
Type: schema.TypeList,
Computed: true,
Description: "The metadata service configuration",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
isInstanceMetadataServiceEnabled1: {
Type: schema.TypeBool,
Computed: true,
Description: "Indicates whether the metadata service endpoint will be available to the virtual server instance",
},

isInstanceMetadataServiceProtocol: {
Type: schema.TypeString,
Computed: true,
Description: "The communication protocol to use for the metadata service endpoint. Applies only when the metadata service is enabled.",
},

isInstanceMetadataServiceRespHopLimit: {
Type: schema.TypeInt,
Computed: true,
Description: "The hop limit (IP time to live) for IP response packets from the metadata service",
},
},
},
},
isInstanceTemplatesHref: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -151,6 +177,7 @@ func DataSourceIBMISInstanceTemplates() *schema.Resource {
Computed: true,
Description: "The unique identifier or CRN of the default IAM trusted profile to use for this virtual server instance.",
},

isInstanceTemplateVolumeAttachments: {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -473,6 +500,20 @@ func dataSourceIBMISInstanceTemplatesRead(d *schema.ResourceData, meta interface

if instance.MetadataService != nil {
template[isInstanceTemplateMetadataServiceEnabled] = *instance.MetadataService.Enabled

metadataService := []map[string]interface{}{}
metadataServiceMap := map[string]interface{}{}

metadataServiceMap[isInstanceMetadataServiceEnabled1] = instance.MetadataService.Enabled
if instance.MetadataService.Protocol != nil {
metadataServiceMap[isInstanceMetadataServiceProtocol] = instance.MetadataService.Protocol
}
if instance.MetadataService.ResponseHopLimit != nil {
metadataServiceMap[isInstanceMetadataServiceRespHopLimit] = instance.MetadataService.ResponseHopLimit
}

metadataService = append(metadataService, metadataServiceMap)
template[isInstanceMetadataService] = metadataService
}

if instance.AvailabilityPolicy != nil && instance.AvailabilityPolicy.HostFailure != nil {
Expand Down
38 changes: 38 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,32 @@ func DataSourceIBMISInstances() *schema.Resource {
Computed: true,
Description: "Indicates whether the metadata service endpoint is available to the virtual server instance",
},
isInstanceMetadataService: {
Type: schema.TypeList,
Computed: true,
Description: "The metadata service configuration",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
isInstanceMetadataServiceEnabled1: {
Type: schema.TypeBool,
Computed: true,
Description: "Indicates whether the metadata service endpoint will be available to the virtual server instance",
},

isInstanceMetadataServiceProtocol: {
Type: schema.TypeString,
Computed: true,
Description: "The communication protocol to use for the metadata service endpoint. Applies only when the metadata service is enabled.",
},

isInstanceMetadataServiceRespHopLimit: {
Type: schema.TypeInt,
Computed: true,
Description: "The hop limit (IP time to live) for IP response packets from the metadata service",
},
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -806,6 +832,18 @@ func instancesList(d *schema.ResourceData, meta interface{}) error {
l["memory"] = *instance.Memory
if instance.MetadataService != nil {
l[isInstanceMetadataServiceEnabled] = *instance.MetadataService.Enabled
metadataService := []map[string]interface{}{}
metadataServiceMap := map[string]interface{}{}

metadataServiceMap[isInstanceMetadataServiceEnabled1] = instance.MetadataService.Enabled
if instance.MetadataService.Protocol != nil {
metadataServiceMap[isInstanceMetadataServiceProtocol] = instance.MetadataService.Protocol
}
if instance.MetadataService.ResponseHopLimit != nil {
metadataServiceMap[isInstanceMetadataServiceRespHopLimit] = instance.MetadataService.ResponseHopLimit
}
metadataService = append(metadataService, metadataServiceMap)
l[isInstanceMetadataService] = metadataService
}
l["status"] = *instance.Status
l["resource_group"] = *instance.ResourceGroup.ID
Expand Down
Loading

0 comments on commit f64c13a

Please sign in to comment.