Skip to content

Commit e6dd696

Browse files
committed
fix make lint bug
1 parent 8e9e564 commit e6dd696

9 files changed

Lines changed: 43 additions & 40 deletions

File tree

pkg/cmd/addon/addon.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ func newListCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Co
130130
Use: "list",
131131
Short: "List addons.",
132132
Aliases: []string{"ls"},
133-
ValidArgsFunction: util.ResourceNameCompletionFunc(f, o.GVR),
133+
ValidArgsFunction: util.ResourceNameCompletionFunc(f, o.ListOptions.GVR),
134134
Run: func(cmd *cobra.Command, args []string) {
135-
o.Names = args
135+
o.ListOptions.Names = args
136136
util.CheckErr(addonListRun(o))
137137
},
138138
}
139-
o.AddFlags(cmd, true)
139+
o.ListOptions.AddFlags(cmd, true)
140140
cmd.Flags().StringArrayVar(&o.status, "status", []string{}, "Filter addons by status")
141141
cmd.Flags().BoolVar(&o.listEngines, "engines", false, "List engine addons only")
142142
return cmd
@@ -225,8 +225,8 @@ func newEnableCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.
225225
util.CheckErr(o.fetchAddonObj())
226226
util.CheckErr(o.validate())
227227
util.CheckErr(o.complete(o, cmd, []string{name}))
228-
util.CheckErr(o.CmdComplete(cmd))
229-
util.CheckErr(o.Run())
228+
util.CheckErr(o.PatchOptions.CmdComplete(cmd))
229+
util.CheckErr(o.PatchOptions.Run())
230230
if isEngineAddon(&o.addon) {
231231
util.CheckErr(clusterCmd.RegisterClusterChart(f, streams, "", name, getAddonVersion(&o.addon), types.ClusterChartsRepoURL))
232232
}
@@ -293,7 +293,7 @@ func newDisableCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra
293293
util.CheckErr(o.checkBeforeDisable())
294294
util.CheckErr(o.complete(o, cmd, []string{name}))
295295
util.CheckErr(o.CmdComplete(cmd))
296-
util.CheckErr(o.Run())
296+
util.CheckErr(o.PatchOptions.Run())
297297
}
298298
},
299299
}
@@ -303,7 +303,7 @@ func newDisableCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra
303303
}
304304

305305
func (o *addonCmdOpts) init(args []string) error {
306-
o.Names = args
306+
o.PatchOptions.Names = args
307307
if o.dynamic == nil {
308308
var err error
309309
if o.dynamic, err = o.Factory.DynamicClient(); err != nil {
@@ -353,7 +353,7 @@ func (o *addonCmdOpts) validate() error {
353353
}
354354
for _, s := range o.addon.Spec.Installable.Selectors {
355355
if !s.MatchesFromConfig() {
356-
return fmt.Errorf("addon %s INSTALLABLE-SELECTOR has no matching requirement", o.Names)
356+
return fmt.Errorf("addon %s INSTALLABLE-SELECTOR has no matching requirement", o.PatchOptions.Names)
357357
}
358358
}
359359

@@ -819,20 +819,20 @@ func (o *addonCmdOpts) buildPatch(flags []*pflag.Flag) error {
819819
if err != nil {
820820
return err
821821
}
822-
o.Patch = string(bytes)
822+
o.PatchOptions.Patch = string(bytes)
823823
return nil
824824
}
825825

826826
func addonListRun(o *addonListOpts) error {
827827
// if format is JSON or YAML, use default printer to output the result.
828-
if o.Format == printer.JSON || o.Format == printer.YAML {
829-
_, err := o.Run()
828+
if o.ListOptions.Format == printer.JSON || o.ListOptions.Format == printer.YAML {
829+
_, err := o.ListOptions.Run()
830830
return err
831831
}
832832

833833
// get and output the result
834-
o.Print = false
835-
r, err := o.Run()
834+
o.ListOptions.Print = false
835+
r, err := o.ListOptions.Run()
836836
if err != nil {
837837
return err
838838
}
@@ -921,7 +921,7 @@ func addonListRun(o *addonListOpts) error {
921921
return nil
922922
}
923923

924-
if o.Format == printer.Wide {
924+
if o.ListOptions.Format == printer.Wide {
925925
if err = printer.PrintTable(o.Out, nil, printRows,
926926
"NAME", "VERSION", "PROVIDER", "STATUS", "AUTO-INSTALL", "AUTO-INSTALLABLE-SELECTOR", "EXTRAS"); err != nil {
927927
return err

pkg/cmd/addon/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ func uniqueByName(objects []searchResult) []searchResult {
7878
func checkAddonInstalled(objects *[]searchResult, o *addonListOpts) error {
7979
// list installed addons
8080
var installedAddons []string
81-
o.Print = false
81+
o.ListOptions.Print = false
8282
// get and output the result
83-
o.Print = false
83+
o.ListOptions.Print = false
8484
r, _ := o.Run()
8585
if r == nil {
8686
return nil

pkg/cmd/backuprepo/list.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func newListCommand(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobr
6363
Example: listExample,
6464
ValidArgsFunction: util.ResourceNameCompletionFunc(f, types.BackupRepoGVR()),
6565
Run: func(cmd *cobra.Command, args []string) {
66-
o.Names = args
66+
o.ListOptions.Names = args
6767
cmdutil.CheckErr(o.Complete())
6868
cmdutil.CheckErr(printBackupRepoList(o))
6969
},
@@ -74,7 +74,7 @@ func newListCommand(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobr
7474

7575
func (o *listBackupRepoOptions) Complete() error {
7676
var err error
77-
o.dynamic, err = o.Factory.DynamicClient()
77+
o.dynamic, err = o.ListOptions.Factory.DynamicClient()
7878
if err != nil {
7979
return err
8080
}
@@ -83,14 +83,14 @@ func (o *listBackupRepoOptions) Complete() error {
8383

8484
func printBackupRepoList(o *listBackupRepoOptions) error {
8585
// if format is JSON or YAML, use default printer to output the result.
86-
if o.Format == printer.JSON || o.Format == printer.YAML {
86+
if o.ListOptions.Format == printer.JSON || o.ListOptions.Format == printer.YAML {
8787
_, err := o.Run()
8888
return err
8989
}
9090

9191
backupRepoList, err := o.dynamic.Resource(types.BackupRepoGVR()).List(context.TODO(), metav1.ListOptions{
92-
LabelSelector: o.LabelSelector,
93-
FieldSelector: o.FieldSelector,
92+
LabelSelector: o.ListOptions.LabelSelector,
93+
FieldSelector: o.ListOptions.FieldSelector,
9494
})
9595
if err != nil {
9696
return err
@@ -140,7 +140,7 @@ func printBackupRepoList(o *listBackupRepoOptions) error {
140140
return nil
141141
}
142142

143-
if err = printer.PrintTable(o.Out, nil, printRows,
143+
if err = printer.PrintTable(o.ListOptions.Out, nil, printRows,
144144
"NAME", "STATUS", "STORAGE-PROVIDER", "ACCESS-METHOD", "DEFAULT", "BACKUPS", "TOTAL-SIZE"); err != nil {
145145
return err
146146
}

pkg/cmd/cluster/config_edit.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var (
6363

6464
func (o *editConfigOptions) Run(fn func() error) error {
6565
wrapper := o.wrapper
66-
cfgEditContext := newConfigContext(o.CreateOptions, o.Name, wrapper.ComponentName(), wrapper.ConfigSpecName(), wrapper.ConfigFile())
66+
cfgEditContext := newConfigContext(o.CreateOptions, o.CreateOptions.Name, wrapper.ComponentName(), wrapper.ConfigSpecName(), wrapper.ConfigFile())
6767
if err := cfgEditContext.prepare(); err != nil {
6868
return err
6969
}
@@ -88,7 +88,7 @@ func (o *editConfigOptions) Run(fn func() error) error {
8888
fmt.Println("Edit cancelled, no changes made.")
8989
return nil
9090
}
91-
util.DisplayDiffWithColor(o.IOStreams.Out, diff)
91+
util.DisplayDiffWithColor(o.CreateOptions.IOStreams.Out, diff)
9292

9393
if hasSchemaForFile(wrapper.rctx, wrapper.ConfigFile()) {
9494
return o.runWithConfigConstraints(cfgEditContext, wrapper.rctx, fn)
@@ -131,7 +131,7 @@ func (o *editConfigOptions) runWithConfigConstraints(cfgEditContext *configEditC
131131
return nil
132132
}
133133

134-
fmt.Fprintf(o.Out, "Config patch(updated parameters): \n%s\n\n", string(configPatch.UpdateConfig[o.CfgFile]))
134+
fmt.Fprintf(o.CreateOptions.Out, "Config patch(updated parameters): \n%s\n\n", string(configPatch.UpdateConfig[o.CfgFile]))
135135
if !o.enableDelete {
136136
if err := core.ValidateConfigPatch(configPatch, rctx.ConfigRender.Spec); err != nil {
137137
return err
@@ -199,14 +199,14 @@ func (o *editConfigOptions) confirmReconfigure(promptStr string) (bool, error) {
199199
const noStr = "no"
200200

201201
confirmStr := []string{yesStr, noStr}
202-
printer.Warning(o.Out, promptStr)
202+
printer.Warning(o.CreateOptions.Out, promptStr)
203203
input, err := prompt.NewPrompt("Please type [Yes/No] to confirm:",
204204
func(input string) error {
205205
if !slices.Contains(confirmStr, strings.ToLower(input)) {
206206
return fmt.Errorf("typed \"%s\" does not match \"%s\"", input, confirmStr)
207207
}
208208
return nil
209-
}, o.In).Run()
209+
}, o.CreateOptions.In).Run()
210210
if err != nil {
211211
return false, err
212212
}
@@ -239,7 +239,7 @@ func NewEditConfigureCmd(f cmdutil.Factory, streams genericiooptions.IOStreams)
239239
Example: editConfigExample,
240240
ValidArgsFunction: util.ResourceNameCompletionFunc(f, types.ClusterGVR()),
241241
Run: func(cmd *cobra.Command, args []string) {
242-
o.Args = args
242+
o.CreateOptions.Args = args
243243
cmdutil.CheckErr(o.CreateOptions.Complete())
244244
util.CheckErr(o.Complete())
245245
util.CheckErr(o.Validate())

pkg/cmd/cluster/config_observer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (r *configObserverOptions) printComponentConfigSpecsDescribe(rctx *Reconfig
113113
resolveParameterTemplate := func(tpl string) string {
114114
for _, config := range rctx.Cmpd.Spec.Configs {
115115
if config.Name == tpl {
116-
return config.TemplateRef
116+
return config.Template
117117
}
118118
}
119119
return ""

pkg/cmd/cluster/config_ops.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ func (o *configOpsOptions) Validate() error {
138138
return err
139139
}
140140

141-
classifyParams := configctrl.ClassifyComponentParameters(o.KeyValues, rctx.ParametersDefs, rctx.Cmpd.Spec.Configs, tplObjs)
141+
classifyParams, err := configctrl.ClassifyComponentParameters(o.KeyValues, rctx.ParametersDefs, rctx.Cmpd.Spec.Configs, tplObjs, rctx.ConfigRender)
142+
if err != nil {
143+
return err
144+
}
142145
if err := util.ValidateParametersModified(classifyParams, rctx.ParametersDefs); err != nil {
143146
return err
144147
}

pkg/cmd/cluster/config_util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,15 @@ func resolveConfigTemplate(rctx *ReconfigureContext, dynamic dynamic.Interface)
280280
if _, ok := tplObjs[tpl]; ok {
281281
continue
282282
}
283-
index := generics.FindFirstFunc(rctx.Cmpd.Spec.Configs, func(spec appsv1.ComponentTemplateSpec) bool {
283+
index := generics.FindFirstFunc(rctx.Cmpd.Spec.Configs, func(spec appsv1.ComponentFileTemplate) bool {
284284
return spec.Name == tpl
285285
})
286286
if index < 0 {
287287
return nil, makeConfigSpecNotExistErr(rctx.Cluster.Name, rctx.CompName, tpl)
288288
}
289289
var cm = &corev1.ConfigMap{}
290290
tplMeta := rctx.Cmpd.Spec.Configs[index]
291-
key := client.ObjectKey{Namespace: tplMeta.Namespace, Name: tplMeta.TemplateRef}
291+
key := client.ObjectKey{Namespace: tplMeta.Namespace, Name: tplMeta.Template}
292292
if err := util.GetResourceObjectFromGVR(types.ConfigmapGVR(), key, dynamic, cm); err != nil {
293293
return nil, err
294294
}

pkg/cmd/trace/update.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (o *UpdateOptions) buildPatch() error {
7171
if err != nil {
7272
return err
7373
}
74-
o.Patch = string(bytes)
74+
o.PatchOptions.Patch = string(bytes)
7575
return nil
7676
}
7777

@@ -86,9 +86,9 @@ func newUpdateCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.
8686
Aliases: []string{"u"},
8787
ValidArgsFunction: util.ResourceNameCompletionFunc(f, types.TraceGVR()),
8888
Run: func(cmd *cobra.Command, args []string) {
89-
o.Names = args
89+
o.PatchOptions.Names = args
9090
util.CheckErr(o.CmdComplete(cmd))
91-
util.CheckErr(o.Run())
91+
util.CheckErr(o.PatchOptions.Run())
9292
},
9393
}
9494

pkg/testing/fake.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,12 @@ func FakeCompDef() *kbappsv1.ComponentDefinition {
356356
Reconfigure: &defaultAction,
357357
AccountProvision: &defaultAction,
358358
},
359-
Configs: []kbappsv1.ComponentTemplateSpec{
359+
Configs: []kbappsv1.ComponentFileTemplate{
360360
{
361-
Name: fakeConfigTemplateName,
362-
TemplateRef: FakeMysqlTemplateName,
363-
Namespace: "default",
364-
VolumeName: "for_test",
361+
Name: fakeConfigTemplateName,
362+
Template: FakeMysqlTemplateName,
363+
Namespace: "default",
364+
VolumeName: "for_test",
365365
},
366366
},
367367
}

0 commit comments

Comments
 (0)