Skip to content
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

Feature: metadata post ga changes in instance and templates #4352

Merged
merged 1 commit into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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