Skip to content

Commit 69a5ec4

Browse files
committed
Enable wsl and nlreturn linters
The linters come with a new auto-fix function, means we can enable them without any manual effort. Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
1 parent 3a73c5c commit 69a5ec4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+672
-2
lines changed

.golangci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ linters:
6464
- nestif
6565
- nilerr
6666
- nilnesserr
67+
- nlreturn
6768
- noctx
6869
- nolintlint
6970
- nosprintfhostport
@@ -97,6 +98,7 @@ linters:
9798
- usetesting
9899
- wastedassign
99100
- whitespace
101+
- wsl
100102
- zerologlint
101103
# - depguard
102104
# - err113
@@ -110,12 +112,10 @@ linters:
110112
# - lll
111113
# - mnd
112114
# - nilnil
113-
# - nlreturn
114115
# - nonamedreturns
115116
# - testpackage
116117
# - varnamelen
117118
# - wrapcheck
118-
# - wsl
119119
linters-settings:
120120
stylecheck:
121121
checks:

cmd/crictl/attach.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ var runtimeAttachCommand = &cli.Command{
102102
if err = Attach(ctx, runtimeClient, opts); err != nil {
103103
return fmt.Errorf("attaching running container failed: %w", err)
104104
}
105+
105106
return nil
106107
},
107108
}
@@ -111,6 +112,7 @@ func Attach(ctx context.Context, client internalapi.RuntimeService, opts attachO
111112
if opts.id == "" {
112113
return errors.New("ID cannot be empty")
113114
}
115+
114116
request := &pb.AttachRequest{
115117
ContainerId: opts.id,
116118
Tty: opts.tty,
@@ -119,13 +121,16 @@ func Attach(ctx context.Context, client internalapi.RuntimeService, opts attachO
119121
Stderr: !opts.tty,
120122
}
121123
logrus.Debugf("AttachRequest: %v", request)
124+
122125
r, err := InterruptableRPC(ctx, func(ctx context.Context) (*pb.AttachResponse, error) {
123126
return client.Attach(ctx, request)
124127
})
125128
logrus.Debugf("AttachResponse: %v", r)
129+
126130
if err != nil {
127131
return err
128132
}
133+
129134
attachURL := r.Url
130135

131136
URL, err := url.Parse(attachURL)
@@ -136,10 +141,12 @@ func Attach(ctx context.Context, client internalapi.RuntimeService, opts attachO
136141
if URL.Host == "" {
137142
URL.Host = kubeletURLHost
138143
}
144+
139145
if URL.Scheme == "" {
140146
URL.Scheme = kubeletURLSchema
141147
}
142148

143149
logrus.Debugf("Attach URL: %v", URL)
150+
144151
return stream(ctx, opts.stdin, opts.tty, opts.transport, URL, opts.tlsConfig)
145152
}

cmd/crictl/completion.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ complete -F _crictl crictl`
3737

3838
func bashCompletion(c *cli.Context) error {
3939
subcommands := []string{}
40+
4041
for _, command := range c.App.Commands {
4142
if command.Hidden {
4243
continue
4344
}
45+
4446
subcommands = append(subcommands, command.Names()...)
4547
}
4648

@@ -50,6 +52,7 @@ func bashCompletion(c *cli.Context) error {
5052
}
5153

5254
fmt.Fprintln(c.App.Writer, fmt.Sprintf(bashCompletionTemplate, strings.Join(subcommands, "\n")))
55+
5356
return nil
5457
}
5558

@@ -71,10 +74,12 @@ compdef _crictl crictl`
7174

7275
func zshCompletion(c *cli.Context) error {
7376
subcommands := []string{}
77+
7478
for _, command := range c.App.Commands {
7579
if command.Hidden {
7680
continue
7781
}
82+
7883
for _, name := range command.Names() {
7984
subcommands = append(subcommands, name+":"+command.Usage)
8085
}
@@ -87,6 +92,7 @@ func zshCompletion(c *cli.Context) error {
8792
}
8893

8994
fmt.Fprintln(c.App.Writer, fmt.Sprintf(zshCompletionTemplate, strings.Join(subcommands, "' '"), strings.Join(opts, "' '")))
95+
9096
return nil
9197
}
9298

@@ -95,7 +101,9 @@ func fishCompletion(c *cli.Context) error {
95101
if err != nil {
96102
return err
97103
}
104+
98105
fmt.Fprintln(c.App.Writer, completion)
106+
99107
return nil
100108
}
101109

cmd/crictl/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ CRICTL OPTIONS:
9898
default:
9999
return fmt.Errorf("no configuration option named %s", get)
100100
}
101+
101102
return nil
102103
} else if c.IsSet("set") {
103104
settings := c.StringSlice("set")
@@ -115,6 +116,7 @@ CRICTL OPTIONS:
115116
}
116117
}
117118
}
119+
118120
return common.WriteConfig(config, configFile)
119121
} else if c.Bool("list") {
120122
display := newDefaultTableDisplay()
@@ -141,6 +143,7 @@ CRICTL OPTIONS:
141143
if err := setValue(key, value, config); err != nil {
142144
return fmt.Errorf("set %q to %q: %w", key, value, err)
143145
}
146+
144147
return common.WriteConfig(config, configFile)
145148
},
146149
}
@@ -156,27 +159,32 @@ func setValue(key, value string, config *common.Config) error {
156159
if err != nil {
157160
return fmt.Errorf("parse timeout value '%s': %w", value, err)
158161
}
162+
159163
config.Timeout = n
160164
case common.Debug:
161165
debug, err := strconv.ParseBool(value)
162166
if err != nil {
163167
return fmt.Errorf("parse debug value '%s': %w", value, err)
164168
}
169+
165170
config.Debug = debug
166171
case common.PullImageOnCreate:
167172
pi, err := strconv.ParseBool(value)
168173
if err != nil {
169174
return fmt.Errorf("parse pull-image-on-create value '%s': %w", value, err)
170175
}
176+
171177
config.PullImageOnCreate = pi
172178
case common.DisablePullOnRun:
173179
pi, err := strconv.ParseBool(value)
174180
if err != nil {
175181
return fmt.Errorf("parse disable-pull-on-run value '%s': %w", value, err)
176182
}
183+
177184
config.DisablePullOnRun = pi
178185
default:
179186
return fmt.Errorf("no configuration option named %s", key)
180187
}
188+
181189
return nil
182190
}

0 commit comments

Comments
 (0)