@@ -135,6 +135,27 @@ func buildRequest(ctx context.Context, apiClient *ske.APIClient) ske.ApiListProv
135
135
}
136
136
137
137
func outputResult (p * print.Printer , model * inputModel , options * ske.ProviderOptions ) error {
138
+ // filter output based on the flags
139
+ if ! model .AvailabilityZones {
140
+ options .AvailabilityZones = nil
141
+ }
142
+
143
+ if ! model .KubernetesVersions {
144
+ options .KubernetesVersions = nil
145
+ }
146
+
147
+ if ! model .MachineImages {
148
+ options .MachineImages = nil
149
+ }
150
+
151
+ if ! model .MachineTypes {
152
+ options .MachineTypes = nil
153
+ }
154
+
155
+ if ! model .VolumeTypes {
156
+ options .VolumeTypes = nil
157
+ }
158
+
138
159
switch model .OutputFormat {
139
160
case print .JSONOutputFormat :
140
161
details , err := json .MarshalIndent (options , "" , " " )
@@ -152,33 +173,25 @@ func outputResult(p *print.Printer, model *inputModel, options *ske.ProviderOpti
152
173
153
174
return nil
154
175
default :
155
- return outputResultAsTable (p , model , options )
176
+ return outputResultAsTable (p , options )
156
177
}
157
178
}
158
179
159
- func outputResultAsTable (p * print.Printer , model * inputModel , options * ske.ProviderOptions ) error {
180
+ func outputResultAsTable (p * print.Printer , options * ske.ProviderOptions ) error {
160
181
content := ""
161
- if model .AvailabilityZones {
162
- content += renderAvailabilityZones (options )
163
- }
164
- if model .KubernetesVersions {
165
- kubernetesVersionsRendered , err := renderKubernetesVersions (options )
166
- if err != nil {
167
- return fmt .Errorf ("render Kubernetes versions: %w" , err )
168
- }
169
- content += kubernetesVersionsRendered
170
- }
171
- if model .MachineImages {
172
- content += renderMachineImages (options )
173
- }
174
- if model .MachineTypes {
175
- content += renderMachineTypes (options )
176
- }
177
- if model .VolumeTypes {
178
- content += renderVolumeTypes (options )
182
+ content += renderAvailabilityZones (options )
183
+
184
+ kubernetesVersionsRendered , err := renderKubernetesVersions (options )
185
+ if err != nil {
186
+ return fmt .Errorf ("render Kubernetes versions: %w" , err )
179
187
}
188
+ content += kubernetesVersionsRendered
189
+
190
+ content += renderMachineImages (options )
191
+ content += renderMachineTypes (options )
192
+ content += renderVolumeTypes (options )
180
193
181
- err : = p .PagerDisplay (content )
194
+ err = p .PagerDisplay (content )
182
195
if err != nil {
183
196
return fmt .Errorf ("display output: %w" , err )
184
197
}
@@ -187,6 +200,10 @@ func outputResultAsTable(p *print.Printer, model *inputModel, options *ske.Provi
187
200
}
188
201
189
202
func renderAvailabilityZones (resp * ske.ProviderOptions ) string {
203
+ if resp .AvailabilityZones == nil {
204
+ return ""
205
+ }
206
+
190
207
zones := * resp .AvailabilityZones
191
208
192
209
table := tables .NewTable ()
@@ -200,6 +217,10 @@ func renderAvailabilityZones(resp *ske.ProviderOptions) string {
200
217
}
201
218
202
219
func renderKubernetesVersions (resp * ske.ProviderOptions ) (string , error ) {
220
+ if resp .KubernetesVersions == nil {
221
+ return "" , nil
222
+ }
223
+
203
224
versions := * resp .KubernetesVersions
204
225
205
226
table := tables .NewTable ()
@@ -221,6 +242,10 @@ func renderKubernetesVersions(resp *ske.ProviderOptions) (string, error) {
221
242
}
222
243
223
244
func renderMachineImages (resp * ske.ProviderOptions ) string {
245
+ if resp .MachineImages == nil {
246
+ return ""
247
+ }
248
+
224
249
images := * resp .MachineImages
225
250
226
251
table := tables .NewTable ()
@@ -250,6 +275,10 @@ func renderMachineImages(resp *ske.ProviderOptions) string {
250
275
}
251
276
252
277
func renderMachineTypes (resp * ske.ProviderOptions ) string {
278
+ if resp .MachineTypes == nil {
279
+ return ""
280
+ }
281
+
253
282
types := * resp .MachineTypes
254
283
255
284
table := tables .NewTable ()
@@ -263,6 +292,10 @@ func renderMachineTypes(resp *ske.ProviderOptions) string {
263
292
}
264
293
265
294
func renderVolumeTypes (resp * ske.ProviderOptions ) string {
295
+ if resp .VolumeTypes == nil {
296
+ return ""
297
+ }
298
+
266
299
types := * resp .VolumeTypes
267
300
268
301
table := tables .NewTable ()
0 commit comments