Skip to content

Commit c97b772

Browse files
committed
fix(workflow-cli): lint error
1 parent a97022a commit c97b772

12 files changed

Lines changed: 63 additions & 66 deletions

File tree

internal/commands/autoscale.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (d *DryccCmd) AutoscaleList(appID string) error {
3939
}
4040

4141
// AutoscaleSet sets autoscale options for the app.
42-
func (d *DryccCmd) AutoscaleSet(appID string, ptype string, min int, max int, CPUPercent int) error {
42+
func (d *DryccCmd) AutoscaleSet(appID string, ptype string, minCPU int, maxCPU int, CPUPercent int) error {
4343
appID, s, err := utils.LoadAppSettings(d.ConfigFile, appID)
4444

4545
if err != nil {
@@ -51,8 +51,8 @@ func (d *DryccCmd) AutoscaleSet(appID string, ptype string, min int, max int, CP
5151
quit := progress(d.WOut)
5252
data := map[string]*api.Autoscale{
5353
ptype: {
54-
Min: min,
55-
Max: max,
54+
Min: minCPU,
55+
Max: maxCPU,
5656
CPUPercent: CPUPercent,
5757
},
5858
}

internal/completion/completion.go

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ func (c *CertDomainTachCompletion) CompletionFunc(cmd *cobra.Command, args []str
8383
if len(args) == 0 {
8484
certCompletion := CertCompletion{AppID: c.AppID, ConfigFile: c.ConfigFile}
8585
return certCompletion.CompletionFunc(cmd, args, toComplete)
86-
} else {
87-
domainCompletion := DomainCompletion{AppID: c.AppID, ArgsLen: 1, ConfigFile: c.ConfigFile}
88-
return domainCompletion.CompletionFunc(cmd, args, toComplete)
8986
}
87+
domainCompletion := DomainCompletion{AppID: c.AppID, ArgsLen: 1, ConfigFile: c.ConfigFile}
88+
return domainCompletion.CompletionFunc(cmd, args, toComplete)
9089
}
9190

9291
type ConfigPtsGroupArgsCompletion struct {
@@ -98,20 +97,19 @@ func (c *ConfigPtsGroupArgsCompletion) CompletionFunc(cmd *cobra.Command, args [
9897
if len(args) == 0 {
9998
ptsCompletion := PtsCompletion{AppID: c.AppID, ConfigFile: c.ConfigFile}
10099
return ptsCompletion.CompletionFunc(cmd, args, toComplete)
101-
} else {
102-
groups := args[1:]
103-
if appID, s, err := utils.LoadAppSettings(*c.ConfigFile, *c.AppID); err == nil {
104-
if config, err := config.List(s.Client, appID, -1); err == nil {
105-
var results []string
106-
for _, value := range config.Values {
107-
if value.Group != "" && strings.HasPrefix(value.Group, toComplete) {
108-
if !slices.Contains(groups, value.Group) && !slices.Contains(results, value.Group) {
109-
results = append(results, value.Group)
110-
}
100+
}
101+
groups := args[1:]
102+
if appID, s, err := utils.LoadAppSettings(*c.ConfigFile, *c.AppID); err == nil {
103+
if config, err := config.List(s.Client, appID, -1); err == nil {
104+
var results []string
105+
for _, value := range config.Values {
106+
if value.Group != "" && strings.HasPrefix(value.Group, toComplete) {
107+
if !slices.Contains(groups, value.Group) && !slices.Contains(results, value.Group) {
108+
results = append(results, value.Group)
111109
}
112110
}
113-
return results, cobra.ShellCompDirectiveNoFileComp
114111
}
112+
return results, cobra.ShellCompDirectiveNoFileComp
115113
}
116114
}
117115
return nil, cobra.ShellCompDirectiveNoFileComp
@@ -123,7 +121,7 @@ type ConfigGroupCompletion struct {
123121
ArgsLen int
124122
}
125123

126-
func (c *ConfigGroupCompletion) CompletionFunc(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
124+
func (c *ConfigGroupCompletion) CompletionFunc(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
127125

128126
if appID, s, err := utils.LoadAppSettings(*c.ConfigFile, *c.AppID); err == nil && (c.ArgsLen < 0 || len(args) == c.ArgsLen) {
129127
if config, err := config.List(s.Client, appID, -1); err == nil {
@@ -253,10 +251,9 @@ func (c *HealthChecksCompletion) CompletionFunc(cmd *cobra.Command, args []strin
253251
if len(args) == 0 {
254252
healthTypeCompletion := HealthTypeCompletion{ArgsLen: 0, ConfigFile: c.ConfigFile}
255253
return healthTypeCompletion.CompletionFunc(cmd, args, toComplete)
256-
} else {
257-
probeTypeCompletion := ProbeTypeCompletion{ArgsLen: 1, ConfigFile: c.ConfigFile}
258-
return probeTypeCompletion.CompletionFunc(cmd, args, toComplete)
259254
}
255+
probeTypeCompletion := ProbeTypeCompletion{ArgsLen: 1, ConfigFile: c.ConfigFile}
256+
return probeTypeCompletion.CompletionFunc(cmd, args, toComplete)
260257
}
261258

262259
type ServiceProtocolCompletion struct {
@@ -361,12 +358,12 @@ func (c *LimitSetPlanCompletion) CompletionFunc(cmd *cobra.Command, args []strin
361358
}
362359
}
363360
return results, cobra.ShellCompDirectiveNoFileComp
364-
} else {
365-
ptsSetArgsCompletion := PtsSetArgsCompletion{
366-
PtsCompletion: &PtsCompletion{AppID: c.AppID, ArgsLen: -1, ConfigFile: c.ConfigFile},
367-
}
368-
return ptsSetArgsCompletion.CompletionFunc(cmd, args, toComplete)
369361
}
362+
ptsSetArgsCompletion := PtsSetArgsCompletion{
363+
PtsCompletion: &PtsCompletion{AppID: c.AppID, ArgsLen: -1, ConfigFile: c.ConfigFile},
364+
}
365+
return ptsSetArgsCompletion.CompletionFunc(cmd, args, toComplete)
366+
370367
}
371368

372369
type UserPermsCompletion struct {
@@ -439,12 +436,11 @@ func (c *PermUpdateCompletion) CompletionFunc(cmd *cobra.Command, args []string,
439436
if len(args) == 0 {
440437
permUsernameCompletion := PermUsernameCompletion{AppID: c.AppID, ArgsLen: 0, ConfigFile: c.ConfigFile}
441438
return permUsernameCompletion.CompletionFunc(cmd, args, toComplete)
442-
} else {
443-
userPermsArgsCompletion := UserPermsArgsCompletion{
444-
UserPermsCompletion: &UserPermsCompletion{ConfigFile: c.ConfigFile},
445-
}
446-
return userPermsArgsCompletion.CompletionFunc(cmd, args, toComplete)
447439
}
440+
userPermsArgsCompletion := UserPermsArgsCompletion{
441+
UserPermsCompletion: &UserPermsCompletion{ConfigFile: c.ConfigFile},
442+
}
443+
return userPermsArgsCompletion.CompletionFunc(cmd, args, toComplete)
448444
}
449445

450446
type PsCompletion struct {
@@ -555,7 +551,7 @@ type ResourcePlanCompletion struct {
555551
ConfigFile *string
556552
}
557553

558-
func (c *ResourcePlanCompletion) CompletionFunc(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
554+
func (c *ResourcePlanCompletion) CompletionFunc(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
559555
if s, err := settings.Load(*c.ConfigFile); err == nil && (c.ArgsLen < 0 || len(args) == c.ArgsLen) {
560556
var results []string
561557
if services, _, err := resources.Plans(s.Client, c.Service, -1); err == nil {
@@ -735,12 +731,12 @@ func (c *TagCompletion) CompletionFunc(_ *cobra.Command, args []string, toComple
735731
return nil, cobra.ShellCompDirectiveNoFileComp
736732
}
737733

738-
type TlsActionCompletion struct {
734+
type TLSActionCompletion struct {
739735
ArgsLen int
740736
ConfigFile *string
741737
}
742738

743-
func (c *TlsActionCompletion) CompletionFunc(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
739+
func (c *TLSActionCompletion) CompletionFunc(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
744740
actions := []string{"enable", "disable"}
745741
if c.ArgsLen < 0 || len(args) == c.ArgsLen {
746742

@@ -828,12 +824,11 @@ func (c *VolumesMountCompletion) CompletionFunc(cmd *cobra.Command, args []strin
828824
if len(args) == 0 {
829825
volumeCompletion := VolumeCompletion{AppID: c.AppID, ArgsLen: 0, ConfigFile: c.ConfigFile}
830826
return volumeCompletion.CompletionFunc(cmd, args, toComplete)
831-
} else {
832-
ptsSetArgsCompletion := PtsSetArgsCompletion{
833-
PtsCompletion: &PtsCompletion{AppID: c.AppID, ArgsLen: -1, ConfigFile: c.ConfigFile},
834-
}
835-
return ptsSetArgsCompletion.CompletionFunc(cmd, args, toComplete)
836827
}
828+
ptsSetArgsCompletion := PtsSetArgsCompletion{
829+
PtsCompletion: &PtsCompletion{AppID: c.AppID, ArgsLen: -1, ConfigFile: c.ConfigFile},
830+
}
831+
return ptsSetArgsCompletion.CompletionFunc(cmd, args, toComplete)
837832
}
838833

839834
type VolumesUnmountCompletion struct {

internal/parser/autorollback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func NewAutorollbackCommand(cmdr *commands.DryccCmd) *cobra.Command {
1212
cmd := &cobra.Command{
1313
Use: "autorollback",
1414
Short: i18n.T("Manage autorollback if or not for application"),
15-
RunE: func(cmd *cobra.Command, args []string) error {
15+
RunE: func(_ *cobra.Command, args []string) error {
1616
return cmdr.AutorollbackInfo(app)
1717
},
1818
}

internal/parser/autoscale.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ func autoscaleSetCommand(cmdr *commands.DryccCmd) *cobra.Command {
7474
cmd.Flags().IntVarP(&flags.cpuPercent, "cpu-percent", "", 0, i18n.T("Target CPU utilization percentage"))
7575
cmd.Flags().SortFlags = false
7676

77-
must_flags := []string{"min", "max", "cpu-percent"}
78-
for _, must_flag := range must_flags {
77+
mustFlags := []string{"min", "max", "cpu-percent"}
78+
for _, must_flag := range mustFlags {
7979
cmd.MarkFlagRequired(must_flag)
8080
}
8181

internal/parser/gateways.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func NewGatewaysCommand(cmdr *commands.DryccCmd) *cobra.Command {
1212
cmd := &cobra.Command{
1313
Use: "gateways",
1414
Short: i18n.T("Manage gateways for your applications"),
15-
RunE: func(cmd *cobra.Command, args []string) error {
15+
RunE: func(_ *cobra.Command, _ []string) error {
1616
results, _ := commands.ResponseLimit(limit)
1717
return cmdr.GatewaysList(app, results)
1818
},
@@ -67,8 +67,8 @@ func gatewaysAdd(cmdr *commands.DryccCmd) *cobra.Command {
6767
cmd.Flags().IntVar(&flags.port, "port", 0, i18n.T("Port is the network port, the listener expects to receive"))
6868
cmd.Flags().StringVarP(&flags.protocol, "protocol", "", "", i18n.T("Protocol specifies the network protocol this listener expects to receive. Supports TCP, UDP, TLS, HTTP, and HTTPS"))
6969

70-
must_flags := []string{"port", "protocol"}
71-
for _, must_flag := range must_flags {
70+
mustFlags := []string{"port", "protocol"}
71+
for _, must_flag := range mustFlags {
7272
cmd.MarkFlagRequired(must_flag)
7373
}
7474

@@ -100,8 +100,8 @@ func gatewaysRemove(cmdr *commands.DryccCmd) *cobra.Command {
100100
cmd.Flags().IntVar(&flags.port, "port", 0, i18n.T("Port is the network port, the listener received"))
101101
cmd.Flags().StringVarP(&flags.protocol, "protocol", "", "", i18n.T("Protocol specifies the network protocol this listener received"))
102102

103-
must_flags := []string{"port", "protocol"}
104-
for _, must_flag := range must_flags {
103+
mustFlags := []string{"port", "protocol"}
104+
for _, must_flag := range mustFlags {
105105
cmd.MarkFlagRequired(must_flag)
106106
}
107107

internal/parser/routes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ func routesAttachCommand(cmdr *commands.DryccCmd) *cobra.Command {
187187
cmd.Flags().StringVar(&flags.gateway, "gateway", "", i18n.T("The unique name of the gaetway"))
188188
cmd.Flags().IntVarP(&flags.port, "port", "", 0, i18n.T("Port is the network port, the gateway listener expects to receive"))
189189

190-
must_flags := []string{"gateway", "port"}
191-
for _, must_flag := range must_flags {
190+
mustFlags := []string{"gateway", "port"}
191+
for _, must_flag := range mustFlags {
192192
cmd.MarkFlagRequired(must_flag)
193193
}
194194

@@ -223,8 +223,8 @@ func routesDetachCommand(cmdr *commands.DryccCmd) *cobra.Command {
223223
cmd.Flags().StringVar(&flags.gateway, "gateway", "", i18n.T("The unique name of the gaetway"))
224224
cmd.Flags().IntVarP(&flags.port, "port", "", 0, i18n.T("Port is the network port, the gateway listener expects to receive"))
225225

226-
must_flags := []string{"port", "protocol"}
227-
for _, must_flag := range must_flags {
226+
mustFlags := []string{"port", "protocol"}
227+
for _, must_flag := range mustFlags {
228228
cmd.MarkFlagRequired(must_flag)
229229
}
230230

internal/parser/tags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func NewTagsCommand(cmdr *commands.DryccCmd) *cobra.Command {
1717
cmd := &cobra.Command{
1818
Use: "tags",
1919
Short: i18n.T("Manage tags for application containers"),
20-
RunE: func(cmd *cobra.Command, args []string) error {
20+
RunE: func(_ *cobra.Command, args []string) error {
2121
return cmdr.TagsList(app, flags.ptype, version)
2222
},
2323
}

internal/parser/timeouts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func NewTimeoutsCommand(cmdr *commands.DryccCmd) *cobra.Command {
1313
cmd := &cobra.Command{
1414
Use: "timeouts",
1515
Short: i18n.T("Manage pods termination grace period"),
16-
RunE: func(cmd *cobra.Command, args []string) error {
16+
RunE: func(_ *cobra.Command, _ []string) error {
1717
return cmdr.TimeoutsList(app, version)
1818
},
1919
}

internal/parser/tls.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func NewTLSCommand(cmdr *commands.DryccCmd) *cobra.Command {
1515
cmd := &cobra.Command{
1616
Use: "tls",
1717
Short: i18n.T("Manage TLS/SSL settings for applications"),
18-
RunE: func(cmd *cobra.Command, args []string) error {
18+
RunE: func(_ *cobra.Command, args []string) error {
1919
return cmdr.TLSInfo(app)
2020
},
2121
}
@@ -46,7 +46,7 @@ func tlsInfoCommand(cmdr *commands.DryccCmd) *cobra.Command {
4646
}
4747

4848
func tlsForceCommand(cmdr *commands.DryccCmd) *cobra.Command {
49-
tlsActionCompletion := completion.TlsActionCompletion{ArgsLen: -1, ConfigFile: &cmdr.ConfigFile}
49+
TLSActionCompletion := completion.TLSActionCompletion{ArgsLen: -1, ConfigFile: &cmdr.ConfigFile}
5050
cmd := &cobra.Command{
5151
Use: "force <action>",
5252
Example: template.CustomExample(
@@ -58,7 +58,7 @@ func tlsForceCommand(cmdr *commands.DryccCmd) *cobra.Command {
5858
Args: cobra.ExactArgs(1),
5959
ValidArgs: []string{"enable", "disable"},
6060
Short: i18n.T("Force TLS settings to HTTPS-only redirection"),
61-
ValidArgsFunction: tlsActionCompletion.CompletionFunc,
61+
ValidArgsFunction: TLSActionCompletion.CompletionFunc,
6262
RunE: func(cmd *cobra.Command, args []string) error {
6363
action := args[0]
6464
if action == "enable" {
@@ -74,7 +74,7 @@ func tlsForceCommand(cmdr *commands.DryccCmd) *cobra.Command {
7474
}
7575

7676
func tlsAutoCommand(cmdr *commands.DryccCmd) *cobra.Command {
77-
tlsActionCompletion := completion.TlsActionCompletion{ArgsLen: -1, ConfigFile: &cmdr.ConfigFile}
77+
TLSActionCompletion := completion.TLSActionCompletion{ArgsLen: -1, ConfigFile: &cmdr.ConfigFile}
7878
cmd := &cobra.Command{
7979
Use: "auto <action>",
8080
Example: template.CustomExample(
@@ -86,7 +86,7 @@ func tlsAutoCommand(cmdr *commands.DryccCmd) *cobra.Command {
8686
Args: cobra.ExactArgs(1),
8787
ValidArgs: []string{"enable", "disable"},
8888
Short: i18n.T("Automatic certificate management"),
89-
ValidArgsFunction: tlsActionCompletion.CompletionFunc,
89+
ValidArgsFunction: TLSActionCompletion.CompletionFunc,
9090
RunE: func(cmd *cobra.Command, args []string) error {
9191
action := args[0]
9292
if action == "enable" {
@@ -123,8 +123,8 @@ func tlsIssuerCommand(cmdr *commands.DryccCmd) *cobra.Command {
123123
cmd.Flags().StringVar(&flags.keyID, "key-id", "", i18n.T("CA key ID"))
124124
cmd.Flags().StringVar(&flags.keySecret, "key-secret", "", i18n.T("CA key secret"))
125125

126-
must_flags := []string{"email", "server", "key-id", "key-secret"}
127-
for _, must_flag := range must_flags {
126+
mustFlags := []string{"email", "server", "key-id", "key-secret"}
127+
for _, must_flag := range mustFlags {
128128
cmd.MarkFlagRequired(must_flag)
129129
}
130130

internal/parser/tokens.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ func tokensAddCommand(cmdr *commands.DryccCmd) *cobra.Command {
6767
cmd.Flags().StringVarP(&flags.username, "username", "u", "", i18n.T("Provide a username for the account"))
6868
cmd.Flags().StringVarP(&flags.password, "password", "p", "", i18n.T("Provide a password for the account"))
6969

70-
must_flags := []string{"username", "password"}
71-
for _, must_flag := range must_flags {
70+
mustFlags := []string{"username", "password"}
71+
for _, must_flag := range mustFlags {
7272
cmd.MarkFlagRequired(must_flag)
7373
}
7474

0 commit comments

Comments
 (0)