Skip to content

Commit

Permalink
make linter happy
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Lehner <[email protected]>
  • Loading branch information
florianl committed Jul 28, 2022
1 parent 7055e06 commit 6fd1a7e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ func (h *Unenroll) Handle(ctx context.Context, a fleetapi.Action, acker store.Fl
} else if h.stateStore != nil {
// backup action for future start to avoid starting fleet gateway loop
h.stateStore.Add(a)
h.stateStore.Save()
if err := h.stateStore.Save(); err != nil {
return err
}
}

// close fleet gateway loop
Expand Down
9 changes: 7 additions & 2 deletions internal/pkg/core/plugin/process/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ func (a *Application) watch(ctx context.Context, p app.Taggable, proc *process.I
a.setState(state.Restarting, msg, nil)

// it was a crash
a.start(ctx, p, cfg, true)
if err := a.start(ctx, p, cfg, true); err != nil {
a.setState(state.Failed, err.Error(), nil)
return
}
}()
}

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

func (a *Application) cleanUp() {
a.monitor.Cleanup(a.desc.Spec(), a.pipelineID)
if err := a.monitor.Cleanup(a.desc.Spec(), a.pipelineID); err != nil {
a.setState(state.Failed, fmt.Sprintf("cleanup failed: %s", err.Error()), nil)
}
}

func (a *Application) gracefulKill(proc *process.Info) {
Expand Down
12 changes: 7 additions & 5 deletions internal/pkg/crypto/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ func (w *Writer) Write(b []byte) (int, error) {
}

func (w *Writer) writeBlock(b []byte) error {

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

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

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

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

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

encodedBytes := make([]byte, l)
_, err = io.ReadAtLeast(r.reader, encodedBytes, int(l))
_, err = io.ReadAtLeast(r.reader, encodedBytes, l)
if err != nil {
r.err = errors.Wrapf(err, "fail read the block of %d bytes", l)
}
Expand Down Expand Up @@ -364,7 +367,6 @@ func (r *Reader) Close() error {
func randomBytes(length int) ([]byte, error) {
r := make([]byte, length)
_, err := rand.Read(r)

if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6fd1a7e

Please sign in to comment.