Skip to content

Commit c73274d

Browse files
committed
Add optional cos-instance-name parameter for image import
Allow the COS instance name to be optionally specified on image import. This can be used to overcome pagination issues during Cloud Object Storage name lookup when more than 100 service instances exist in an account.
1 parent ac8ba93 commit c73274d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

cmd/image/import/import.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-1003
101101
return err
102102
}
103103

104-
instances, _, err := resourceController.ResourceControllerV2.ListResourceInstances(resourceController.ResourceControllerV2.NewListResourceInstancesOptions().SetType("service_instance"))
104+
serviceListOptions := resourceController.ResourceControllerV2.NewListResourceInstancesOptions().SetType("service_instance")
105+
if opt.COSInstanceName != "" {
106+
serviceListOptions.SetName(opt.COSInstanceName)
107+
}
108+
instances, _, err := resourceController.ResourceControllerV2.ListResourceInstances(serviceListOptions)
105109
if err != nil {
106110
return err
107111
}
@@ -239,6 +243,7 @@ func init() {
239243
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.InstanceName, "pvs-instance-name", "n", "", "PowerVS Instance name.")
240244
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.InstanceID, "pvs-instance-id", "i", "", "PowerVS Instance ID.")
241245
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.BucketName, "bucket", "b", "", "Cloud Object Storage bucket name.")
246+
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.COSInstanceName, "cos-instance-name", "s", "", "Cloud Object Storage instance name.")
242247
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.Region, "bucket-region", "r", "", "Cloud Object Storage bucket location.")
243248
Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.ImageFilename, "object", "o", "", "Cloud Object Storage object name.")
244249
Cmd.Flags().StringVar(&pkg.ImageCMDOptions.AccessKey, "accesskey", "", "Cloud Object Storage HMAC access key.")

pkg/client/s3client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func NewS3Client(c *Client, instanceName, region string) (s3client *S3Client, er
5050
var instanceID string
5151
svcs, err := c.ResourceClient.ListInstances(controllerv2.ServiceInstanceQuery{
5252
Type: "service_instance",
53+
Name: instanceName,
5354
})
5455
if err != nil {
5556
return s3client, fmt.Errorf("failed to list the resource instances: %v", err)

pkg/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type imageCMDOptions struct {
5858
ServicePlan string
5959
ObjectName string
6060
//import options
61+
COSInstanceName string
6162
ImageFilename string
6263
AccessKey string
6364
SecretKey string

0 commit comments

Comments
 (0)