Skip to content

Commit 636fdd8

Browse files
committed
nolint for the checkpointer file
1 parent 36b57c7 commit 636fdd8

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

internal/checkpointer/checkpointer.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// There are some commands in here that are susceptible to injection. However, cog
2+
// is a vehicle to let people run their own code... so why go through the hassle of
3+
// injection? Cog is not run with any more permissions than the user code.
4+
//
5+
//nolint:gosec
16
package checkpointer
27

38
import (
@@ -113,7 +118,7 @@ func (c *checkpointer) Checkpoint(ctx context.Context, cogletCmd *exec.Cmd) erro
113118
return errNoCheckpointDir
114119
}
115120

116-
err := os.MkdirAll(filepath.Join(c.checkpointDir, checkpointSubdirName), 0o666) //nolint:gosec // coglet needs to write here
121+
err := os.MkdirAll(filepath.Join(c.checkpointDir, checkpointSubdirName), 0o666)
117122
if err != nil {
118123
return err
119124
}
@@ -137,7 +142,7 @@ func (c *checkpointer) Checkpoint(ctx context.Context, cogletCmd *exec.Cmd) erro
137142
cudaCmd := strings.TrimSpace(string(data))
138143

139144
// Write said command to a file for later
140-
err = os.WriteFile(filepath.Join(c.checkpointDir, cudaCmdFileName), []byte(cudaCmd), 0o644) //nolint:gosec
145+
err = os.WriteFile(filepath.Join(c.checkpointDir, cudaCmdFileName), []byte(cudaCmd), 0o644)
141146
if err != nil {
142147
return err
143148
}
@@ -200,7 +205,7 @@ func (c *checkpointer) Restore(ctx context.Context) (*exec.Cmd, func(context.Con
200205
if err != nil {
201206
// If this command failed, we want to best effort try to kill the started process,
202207
// since we'll start a new one
203-
restoreCmd.Process.Kill() //nolint:errcheck
208+
restoreCmd.Process.Kill() //nolint:errcheck // This is just best effort
204209

205210
return err
206211
}
@@ -210,7 +215,7 @@ func (c *checkpointer) Restore(ctx context.Context) (*exec.Cmd, func(context.Con
210215
if err := cmd.Run(); err != nil {
211216
// If this command failed, we want to best effort try to kill the started process,
212217
// since we'll start a new one
213-
restoreCmd.Process.Kill() //nolint:errcheck
218+
restoreCmd.Process.Kill() //nolint:errcheck // This is just best effort
214219

215220
return err
216221
}
@@ -219,7 +224,7 @@ func (c *checkpointer) Restore(ctx context.Context) (*exec.Cmd, func(context.Con
219224
if err != nil {
220225
// If this command failed, we want to best effort try to kill the started process,
221226
// since we'll start a new one
222-
restoreCmd.Process.Kill() //nolint:errcheck
227+
restoreCmd.Process.Kill() //nolint:errcheck // This is just best effort
223228

224229
return err
225230
}

internal/checkpointer/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func downloadFile(url, path string) error {
4747
if err != nil {
4848
return fmt.Errorf("failed to touch file: %w", err)
4949
}
50-
defer file.Close() //nolint: errcheck
50+
defer file.Close() //nolint:errcheck // nothing to do with this error
5151

5252
_, err = io.Copy(file, resp.Body)
5353
if err != nil {
@@ -124,7 +124,7 @@ func isDirEmpty(name string) (bool, error) {
124124
if err != nil {
125125
return false, err
126126
}
127-
defer f.Close() //nolint:errcheck
127+
defer f.Close() //nolint:errcheck // nothing to do with this error
128128

129129
_, err = f.Readdirnames(1)
130130
if errors.Is(err, io.EOF) {

0 commit comments

Comments
 (0)