@@ -25,11 +25,13 @@ type inputModel struct {
2525 * globalflags.GlobalFlagModel
2626 LabelSelector * string
2727 Limit * int64
28+ All * bool
2829}
2930
3031const (
3132 labelSelectorFlag = "label-selector"
3233 limitFlag = "limit"
34+ allFlag = "all"
3335)
3436
3537func NewCmd (params * types.CmdParams ) * cobra.Command {
@@ -40,7 +42,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
4042 Args : args .NoArgs ,
4143 Example : examples .Build (
4244 examples .NewExample (
43- `List all images` ,
45+ `List images in your project ` ,
4446 `$ stackit image list` ,
4547 ),
4648 examples .NewExample (
@@ -51,6 +53,10 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
5153 `List the first 10 images` ,
5254 `$ stackit image list --limit=10` ,
5355 ),
56+ examples .NewExample (
57+ `List all images` ,
58+ `$ stackit image list --all` ,
59+ ),
5460 ),
5561 RunE : func (cmd * cobra.Command , args []string ) error {
5662 ctx := context .Background ()
@@ -103,6 +109,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
103109func configureFlags (cmd * cobra.Command ) {
104110 cmd .Flags ().String (labelSelectorFlag , "" , "Filter by label" )
105111 cmd .Flags ().Int64 (limitFlag , 0 , "Limit the output to the first n elements" )
112+ cmd .Flags ().Bool (allFlag , false , "List all images available" )
106113}
107114
108115func parseInput (p * print.Printer , cmd * cobra.Command , _ []string ) (* inputModel , error ) {
@@ -123,6 +130,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
123130 GlobalFlagModel : globalFlags ,
124131 LabelSelector : flags .FlagToStringPointer (p , cmd , labelSelectorFlag ),
125132 Limit : limit ,
133+ All : flags .FlagToBoolPointer (p , cmd , allFlag ),
126134 }
127135
128136 p .DebugInputModel (model )
@@ -134,20 +142,26 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
134142 if model .LabelSelector != nil {
135143 request = request .LabelSelector (* model .LabelSelector )
136144 }
145+ if model .All != nil {
146+ request = request .All (* model .All )
147+ }
137148
138149 return request
139150}
151+
140152func outputResult (p * print.Printer , outputFormat string , items []iaas.Image ) error {
141153 return p .OutputResult (outputFormat , items , func () error {
142154 table := tables .NewTable ()
143- table .SetHeader ("ID" , "NAME" , "OS" , "ARCHITECTURE" , "DISTRIBUTION" , "VERSION" , "LABELS" )
155+ table .SetHeader ("ID" , "NAME" , "OS" , "ARCHITECTURE" , "DISTRIBUTION" , "VERSION" , "SCOPE" , "OWNER" , " LABELS" )
144156 for i := range items {
145157 item := items [i ]
146158 var (
147159 architecture = "n/a"
148160 os = "n/a"
149161 distro = "n/a"
150162 version = "n/a"
163+ owner = "n/a"
164+ scope = "n/a"
151165 )
152166 if cfg := item .Config ; cfg != nil {
153167 if v := cfg .Architecture ; v != nil {
@@ -163,12 +177,21 @@ func outputResult(p *print.Printer, outputFormat string, items []iaas.Image) err
163177 version = * v .Get ()
164178 }
165179 }
180+ if v := item .GetOwner (); v != "" {
181+ owner = v
182+ }
183+ if v := item .GetScope (); v != "" {
184+ scope = v
185+ }
186+
166187 table .AddRow (utils .PtrString (item .Id ),
167188 utils .PtrString (item .Name ),
168189 os ,
169190 architecture ,
170191 distro ,
171192 version ,
193+ scope ,
194+ owner ,
172195 utils .JoinStringKeysPtr (* item .Labels , "," ))
173196 }
174197 err := table .Display (p )
0 commit comments