Skip to content

Commit 7d320a8

Browse files
authored
Merge pull request #3461 from zeborg/clusterawsadm-amilist-ownerid
Added `owner-id` flag for `clusterawsadm ami list`
2 parents c775275 + c2d2b2d commit 7d320a8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cmd/clusterawsadm/ami/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type ListInput struct {
3333
Region string
3434
KubernetesVersion string
3535
OperatingSystem string
36+
OwnerID string
3637
}
3738

3839
const lastNReleases = 3
@@ -81,7 +82,7 @@ func List(input ListInput) (*amiv1.AWSAMIList, error) {
8182
}
8283

8384
ec2Client := ec2.New(sess)
84-
imagesForRegion, err := getAllImages(ec2Client, "")
85+
imagesForRegion, err := getAllImages(ec2Client, input.OwnerID)
8586
if err != nil {
8687
return nil, err
8788
}

cmd/clusterawsadm/cmd/ami/list/list.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var (
3232
kubernetesVersion string
3333
opSystem string
3434
outputPrinter string
35+
ownerID string
3536
)
3637

3738
// ListAMICmd is a CLI command that will list AMIs from the default AWS account where AMIs are stored.
@@ -67,6 +68,7 @@ func ListAMICmd() *cobra.Command {
6768
Region: region,
6869
KubernetesVersion: kubernetesVersion,
6970
OperatingSystem: opSystem,
71+
OwnerID: ownerID,
7072
})
7173
if err != nil {
7274
return err
@@ -87,6 +89,7 @@ func ListAMICmd() *cobra.Command {
8789
addOsFlag(newCmd)
8890
addKubernetesVersionFlag(newCmd)
8991
addOutputFlag(newCmd)
92+
addOwnerIDFlag(newCmd)
9093
return newCmd
9194
}
9295

@@ -101,3 +104,7 @@ func addKubernetesVersionFlag(c *cobra.Command) {
101104
func addOutputFlag(c *cobra.Command) {
102105
c.Flags().StringVarP(&outputPrinter, "output", "o", "table", "The output format of the results. Possible values: table,json,yaml")
103106
}
107+
108+
func addOwnerIDFlag(c *cobra.Command) {
109+
c.Flags().StringVarP(&ownerID, "owner-id", "", "", "The owner ID of the AWS account to be used for listing AMIs")
110+
}

0 commit comments

Comments
 (0)