Skip to content

Commit 5da19a4

Browse files
committed
feat(image): list all
Signed-off-by: Lukas Hoehl <lukas.hoehl@stackit.cloud>
1 parent c8bf589 commit 5da19a4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/cmd/image/list/list.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ type inputModel struct {
2424
*globalflags.GlobalFlagModel
2525
LabelSelector *string
2626
Limit *int64
27+
All *bool
2728
}
2829

2930
const (
3031
labelSelectorFlag = "label-selector"
3132
limitFlag = "limit"
33+
allFlag = "all"
3234
)
3335

3436
func NewCmd(params *types.CmdParams) *cobra.Command {
@@ -102,6 +104,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
102104
func configureFlags(cmd *cobra.Command) {
103105
cmd.Flags().String(labelSelectorFlag, "", "Filter by label")
104106
cmd.Flags().Int64(limitFlag, 0, "Limit the output to the first n elements")
107+
cmd.Flags().Bool(allFlag, false, "List all images available")
105108
}
106109

107110
func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) {
@@ -122,6 +125,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
122125
GlobalFlagModel: globalFlags,
123126
LabelSelector: flags.FlagToStringPointer(p, cmd, labelSelectorFlag),
124127
Limit: limit,
128+
All: flags.FlagToBoolPointer(p, cmd, allFlag),
125129
}
126130

127131
p.DebugInputModel(model)
@@ -133,9 +137,13 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
133137
if model.LabelSelector != nil {
134138
request = request.LabelSelector(*model.LabelSelector)
135139
}
140+
if model.All != nil {
141+
request = request.All(*model.All)
142+
}
136143

137144
return request
138145
}
146+
139147
func outputResult(p *print.Printer, outputFormat string, items []iaas.Image) error {
140148
return p.OutputResult(outputFormat, items, func() error {
141149
table := tables.NewTable()

0 commit comments

Comments
 (0)