Skip to content

Commit 0729fa7

Browse files
committed
feat(legacy_vendor_images):  fixed review comments
1 parent 460e59d commit 0729fa7

File tree

6 files changed

+65
-41
lines changed

6 files changed

+65
-41
lines changed

common/github.com/IBM/vpc-go-sdk/vpcv1/vpc_v1.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4925,9 +4925,11 @@ func (vpc *VpcV1) ListImagesWithContext(ctx context.Context, listImagesOptions *
49254925
builder.AddHeader(headerName, headerValue)
49264926
}
49274927
builder.AddHeader("Accept", "application/json")
4928+
builder.AddQuery("future_version", fmt.Sprint("true"))
4929+
builder.AddQuery("version", fmt.Sprint("2025-06-30"))
49284930

4929-
builder.AddQuery("version", fmt.Sprint(*vpc.Version))
49304931
builder.AddQuery("generation", fmt.Sprint(*vpc.Generation))
4932+
builder.AddQuery("maturity", fmt.Sprint("development"))
49314933
if listImagesOptions.Start != nil {
49324934
builder.AddQuery("start", fmt.Sprint(*listImagesOptions.Start))
49334935
}
@@ -78033,7 +78035,7 @@ type LoadBalancerPool struct {
7803378035
//
7803478036
// For more information, see [Private Path network load balancer frequently asked
7803578037
// questions](https://cloud.ibm.com/docs/vpc?topic=vpc-nlb-faqs#ppnlb-faqs).
78036-
HealthMonitor LoadBalancerPoolHealthMonitor `json:"health_monitor" validate:"required"`
78038+
HealthMonitor LoadBalancerPoolHealthMonitorIntf `json:"health_monitor" validate:"required"`
7803778039

7803878040
// The URL for this load balancer pool.
7803978041
Href *string `json:"href" validate:"required"`

ibm/service/vpc/data_source_ibm_is_image.go

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,23 @@ func imageGetById(d *schema.ResourceData, meta interface{}, identifier string) e
437437
fmt.Printf("[WARN] Given image %s is deprecated and soon will be obsolete.", name)
438438
}
439439

440-
if image.Remote != nil {
441-
imageRemoteMap, err := dataSourceImageRemote(*image)
442-
if err != nil {
443-
return err
440+
if image.Remote != nil && image.Remote.Account != nil {
441+
accountMap := map[string]interface{}{}
442+
443+
if image.Remote.Account.ID != nil {
444+
accountMap["id"] = *image.Remote.Account.ID
445+
}
446+
if image.Remote.Account.ResourceType != nil {
447+
accountMap["resource_type"] = *image.Remote.Account.ResourceType
448+
}
449+
450+
remoteMap := map[string]interface{}{
451+
"account": []interface{}{accountMap},
444452
}
445-
if len(imageRemoteMap) > 0 {
446-
imageRemoteList := []map[string]interface{}{imageRemoteMap}
447-
d.Set(isImageRemote, imageRemoteList)
453+
remoteList := []interface{}{remoteMap}
454+
455+
if err := d.Set(isImageRemote, remoteList); err != nil {
456+
return fmt.Errorf("error setting image remote: %s", err)
448457
}
449458
}
450459

@@ -550,24 +559,24 @@ func dataSourceImageCollectionCatalogOfferingToMap(imageCatalogOfferingItem vpcv
550559
}
551560

552561
func dataSourceImageRemote(imageRemote vpcv1.Image) (map[string]interface{}, error) {
553-
result := map[string]interface{}{}
562+
if imageRemote.Remote == nil || imageRemote.Remote.Account == nil {
563+
return nil, nil
564+
}
554565

555-
if imageRemote.Remote != nil && imageRemote.Remote.Account != nil {
556-
accountMap := map[string]interface{}{}
566+
accountMap := map[string]interface{}{}
557567

558-
if imageRemote.Remote.Account.ID != nil {
559-
accountMap["id"] = *imageRemote.Remote.Account.ID
560-
}
561-
if imageRemote.Remote.Account.ResourceType != nil {
562-
accountMap["resource_type"] = *imageRemote.Remote.Account.ResourceType
563-
}
568+
if imageRemote.Remote.Account.ID != nil {
569+
accountMap["id"] = *imageRemote.Remote.Account.ID
570+
}
571+
if imageRemote.Remote.Account.ResourceType != nil {
572+
accountMap["resource_type"] = *imageRemote.Remote.Account.ResourceType
573+
}
564574

565-
result["remote"] = map[string]interface{}{
566-
"account": accountMap,
567-
}
575+
remoteMap := map[string]interface{}{
576+
"account": []interface{}{accountMap},
568577
}
569578

570-
return result, nil
579+
return remoteMap, nil
571580
}
572581

573582
func dataSourceIBMIsImageFlattenStatusReasons(result []vpcv1.ImageStatusReason) (statusReasons []map[string]interface{}) {

ibm/service/vpc/data_source_ibm_is_images.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const (
1818
isImages = "images"
1919
isImagesResourceGroupID = "resource_group"
2020
isImageCatalogManaged = "catalog_managed"
21+
isImageRemoteAccountId = "remote_account_id"
2122
)
2223

2324
func DataSourceIBMISImages() *schema.Resource {
@@ -53,8 +54,9 @@ func DataSourceIBMISImages() *schema.Resource {
5354
Description: "Whether the image is publicly visible or private to the account",
5455
},
5556
isImageRemoteAccountId: {
56-
Type: schema.TypeString,
57-
Optional: true,
57+
Type: schema.TypeString,
58+
Optional: true,
59+
Description: "Filters the collection to images with a remote.account.id property matching the specified account identifier.",
5860
},
5961
isImageUserDataFormat: {
6062
Type: schema.TypeSet,
@@ -370,7 +372,6 @@ func imageList(d *schema.ResourceData, meta interface{}) error {
370372
if v, ok := d.GetOk(isImageRemoteAccountId); ok {
371373
remoteAccountId = v.(string)
372374
}
373-
374375
var status string
375376
if v, ok := d.GetOk(isImageStatus); ok {
376377
status = v.(string)
@@ -389,7 +390,11 @@ func imageList(d *schema.ResourceData, meta interface{}) error {
389390
}
390391

391392
if remoteAccountId != "" {
392-
if remoteAccountId == "null" || remoteAccountId == "not:null" {
393+
if remoteAccountId == "user" {
394+
remoteAccountId = "null"
395+
listImagesOptions.SetRemoteAccountID(remoteAccountId)
396+
} else if remoteAccountId == "provider" {
397+
remoteAccountId = "not:null"
393398
listImagesOptions.SetRemoteAccountID(remoteAccountId)
394399
} else {
395400
listImagesOptions.SetRemoteAccountID(remoteAccountId)
@@ -501,8 +506,7 @@ func imageList(d *schema.ResourceData, meta interface{}) error {
501506
return err
502507
}
503508
if len(imageRemoteMap) > 0 {
504-
imageRemoteList := []map[string]interface{}{imageRemoteMap}
505-
l["remote"] = imageRemoteList
509+
l["remote"] = []interface{}{imageRemoteMap}
506510
}
507511
}
508512

ibm/service/vpc/resource_ibm_is_image.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const (
2929
isImageFile = "file"
3030
isImageVolume = "source_volume"
3131
isImageMinimumProvisionedSize = "size"
32-
isImageRemoteAccountId = "remote_account_id"
3332

3433
isImageResourceGroup = "resource_group"
3534
isImageEncryptedDataKey = "encrypted_data_key"

website/docs/d/is_image.html.markdown

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ data "ibm_is_image" "example" {
3434
}
3535
```
3636

37-
```terraform
38-
data "ibm_is_image" "example" {
39-
remote{
40-
account{
41-
id = "addgdfdfd"
42-
}
43-
}
44-
}
45-
```
46-
4737
## Argument reference
4838
Review the argument references that you can specify for your data source.
4939

@@ -57,7 +47,6 @@ Review the argument references that you can specify for your data source.
5747

5848
- `visibility` - (Optional, String) The visibility of the image. Accepted values are `public` or `private`.
5949

60-
- `remote-account-id` - (Optional, String) Accepted values are `provider` or `user` or valid account_id.
6150

6251
## Attribute reference
6352
In addition to all argument reference list, you can access the following attribute references after your data source is created.
@@ -115,6 +104,12 @@ In addition to all argument reference list, you can access the following attribu
115104

116105
- `source_volume` - The source volume id of the image.
117106
- `user_data_format` - (String) The user data format for this image.
107+
- `remote` - (Optional, List) If present, this property indicates that the resource associated with this referenceis remote and therefore may not be directly retrievable.
108+
Nested schema for **remote**:
109+
- `account` - (Optional, List) If present, this property indicates that the referenced resource is remote to thisaccount, and identifies the owning account.
110+
Nested schema for **account**:
111+
- `id` - (Computed, String) The unique identifier for this account.
112+
- `resource_type` - (Computed, String) The resource type.
118113

119114
~> **Note:** </br> Supported values are : </br>
120115
**&#x2022;** `cloud_init`: user_data will be interpreted according to the cloud-init standard.</br>

website/docs/d/is_images.html.markdown

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ data "ibm_is_images" "ds_images" {
3131
visibility = "public"
3232
}
3333
34+
```terraform
35+
data "ibm_is_image" "example" {
36+
remote_account_id = "provider"
37+
}
38+
```
39+
3440
```
3541
## Argument reference
3642
@@ -41,7 +47,9 @@ Review the argument references that you can specify for your data source.
4147
- `name` - (Optional, string) The name of the image.
4248
- `visibility` - (Optional, string) Visibility of the image. Accepted values : **private**, **public**
4349
- `status` - (Optional, string) Status of the image. Accepted value : **available**, **deleting**, **deprecated**, **failed**, **obsolete**, **pending**, **unusable**
44-
- `user_data_format` - (String) The user data format for this image.
50+
- `user_data_format` - (String) The user data format for this image.
51+
- `remote-account-id` - (Optional, String) Accepted values are `provider` or `user` or valid account_id.
52+
4553
4654
~> **Note:** </br> Allowed values are : </br>
4755
**&#x2022;** `cloud_init`: user_data will be interpreted according to the cloud-init standard.</br>
@@ -103,4 +111,11 @@ You can access the following attribute references after your data source is crea
103111
- `more_info` - (String) Link to documentation about this status reason
104112
- `visibility` - (String) The visibility of the image public or private.
105113
- `source_volume` - The source volume id of the image.
114+
- `remote` - (Optional, List) If present, this property indicates that the resource associated with this referenceis remote and therefore may not be directly retrievable.
115+
Nested schema for **remote**:
116+
- `account` - (Optional, List) If present, this property indicates that the referenced resource is remote to thisaccount, and identifies the owning account.
117+
Nested schema for **account**:
118+
- `id` - (Computed, String) The unique identifier for this account.
119+
- `resource_type` - (Computed, String) The resource type.
120+
106121

0 commit comments

Comments
 (0)