Skip to content

Commit

Permalink
Feature: metadata post ga changes in instance and templates
Browse files Browse the repository at this point in the history
reverted image id in test

template data source fixes

instance template metadata support and doc

template forcenew revert

refactoring instance and template

template fixes

rebased, fixed doc and updated data sources

test changes

removed custom sdk and updated vpc sdk version
  • Loading branch information
deepaksibm authored and hkantare committed Feb 20, 2023
1 parent 04789ce commit fd64f5d
Show file tree
Hide file tree
Showing 16 changed files with 584 additions and 36 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/IBM/scc-go-sdk/v4 v4.0.2
github.com/IBM/schematics-go-sdk v0.2.1
github.com/IBM/secrets-manager-go-sdk v1.0.49
github.com/IBM/vpc-go-sdk v0.30.0
github.com/IBM/vpc-go-sdk v0.32.0
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5
github.com/Shopify/sarama v1.29.1
github.com/apache/openwhisk-client-go v0.0.0-20200201143223-a804fb82d105
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ 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=
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56/go.mod h1:Zb3OT4l0mf7P/GOs2w2Ilj5sdm5Whoq3pa24dAEBHFc=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
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 fd64f5d

Please sign in to comment.