Skip to content

Commit 6fd1a7e

Browse files
committed
make linter happy
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
1 parent 7055e06 commit 6fd1a7e

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

internal/pkg/agent/application/pipeline/actions/handlers/handler_action_unenroll.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ func (h *Unenroll) Handle(ctx context.Context, a fleetapi.Action, acker store.Fl
7575
} else if h.stateStore != nil {
7676
// backup action for future start to avoid starting fleet gateway loop
7777
h.stateStore.Add(a)
78-
h.stateStore.Save()
78+
if err := h.stateStore.Save(); err != nil {
79+
return err
80+
}
7981
}
8082

8183
// close fleet gateway loop

internal/pkg/core/plugin/process/app.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ func (a *Application) watch(ctx context.Context, p app.Taggable, proc *process.I
228228
a.setState(state.Restarting, msg, nil)
229229

230230
// it was a crash
231-
a.start(ctx, p, cfg, true)
231+
if err := a.start(ctx, p, cfg, true); err != nil {
232+
a.setState(state.Failed, err.Error(), nil)
233+
return
234+
}
232235
}()
233236
}
234237

@@ -274,7 +277,9 @@ func (a *Application) setState(s state.Status, msg string, payload map[string]in
274277
}
275278

276279
func (a *Application) cleanUp() {
277-
a.monitor.Cleanup(a.desc.Spec(), a.pipelineID)
280+
if err := a.monitor.Cleanup(a.desc.Spec(), a.pipelineID); err != nil {
281+
a.setState(state.Failed, fmt.Sprintf("cleanup failed: %s", err.Error()), nil)
282+
}
278283
}
279284

280285
func (a *Application) gracefulKill(proc *process.Info) {

internal/pkg/crypto/io.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ func (w *Writer) Write(b []byte) (int, error) {
180180
}
181181

182182
func (w *Writer) writeBlock(b []byte) error {
183-
184183
// randomly generate the salt and the initialization vector, this information will be saved
185184
// on disk in the file as part of the header
186185
iv, err := w.generator(w.option.IVLength)
@@ -189,13 +188,17 @@ func (w *Writer) writeBlock(b []byte) error {
189188
return w.err
190189
}
191190

192-
w.writer.Write(iv)
191+
if _, err := w.writer.Write(iv); err != nil {
192+
return errors.Wrap(err, "failed to write IV")
193+
}
193194

194195
encodedBytes := w.gcm.Seal(nil, iv, b, nil)
195196

196197
l := make([]byte, 4)
197198
binary.LittleEndian.PutUint32(l, uint32(len(encodedBytes)))
198-
w.writer.Write(l)
199+
if _, err := w.writer.Write(l); err != nil {
200+
return errors.Wrap(err, "failed to write length of encoded bytes")
201+
}
199202

200203
_, err = w.writer.Write(encodedBytes)
201204
if err != nil {
@@ -325,7 +328,7 @@ func (r *Reader) consumeBlock() error {
325328
}
326329

327330
encodedBytes := make([]byte, l)
328-
_, err = io.ReadAtLeast(r.reader, encodedBytes, int(l))
331+
_, err = io.ReadAtLeast(r.reader, encodedBytes, l)
329332
if err != nil {
330333
r.err = errors.Wrapf(err, "fail read the block of %d bytes", l)
331334
}
@@ -364,7 +367,6 @@ func (r *Reader) Close() error {
364367
func randomBytes(length int) ([]byte, error) {
365368
r := make([]byte, length)
366369
_, err := rand.Read(r)
367-
368370
if err != nil {
369371
return nil, err
370372
}

0 commit comments

Comments
 (0)