Skip to content

Commit

Permalink
*: fix errcheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sohankunkerkar committed Dec 11, 2020
1 parent 7395895 commit 8734677
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion internal/exec/stages/disks/luks.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ func (s *stage) createLuks(config types.Config) error {
var ignitionCreatedKeyFile bool
// create keyfile inside of tmpfs, it will be copied to the
// sysroot by the files stage
os.MkdirAll(distro.LuksInitramfsKeyFilePath(), 0700)
if err := os.MkdirAll(distro.LuksInitramfsKeyFilePath(), 0700); err != nil {
return fmt.Errorf("creating directory for keyfile: %v", err)
}
keyFilePath := filepath.Join(distro.LuksInitramfsKeyFilePath(), luks.Name)
devAlias := execUtil.DeviceAlias(*luks.Device)
if util.NilOrEmpty(luks.KeyFile.Source) {
Expand Down
4 changes: 3 additions & 1 deletion internal/exec/stages/disks/partitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error {
op := sgdisk.Begin(s.Logger, devAlias)
s.Logger.Info("wiping partition table requested on %q", devAlias)
op.WipeTable(true)
op.Commit()
if err := op.Commit(); err != nil {
return err
}
}

// Ensure all partitions with number 0 are last
Expand Down
2 changes: 1 addition & 1 deletion internal/exec/util/passwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (u Util) AuthorizeSSHKeys(c types.PasswdUser) error {
if err != nil {
return fmt.Errorf("failed to set SSH key: %v", err)
}
journal.Send(fmt.Sprintf("wrote ssh authorized keys file for user: %s", c.Name), journal.PriInfo, map[string]string{
_ = journal.Send(fmt.Sprintf("wrote ssh authorized keys file for user: %s", c.Name), journal.PriInfo, map[string]string{
"IGNITION_USER_NAME": c.Name,
"IGNITION_PATH": path,
"MESSAGE_ID": ignitionSSHAuthorizedkeysMessageID,
Expand Down
5 changes: 4 additions & 1 deletion internal/exec/util/user_group_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ func TestUserLookup(t *testing.T) {

// perform a user lookup to ensure libnss_files.so is loaded
// note this assumes /etc/nsswitch.conf invokes files.
user.Lookup("root")
_, err := user.Lookup("root")
if err != nil {
t.Fatalf("user lookup failed: %v", err)
}

td, err := tempBase()
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion tests/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,9 @@ func createFilesFromSlice(basedir string, files []types.File) error {
}
writer.Flush()
}
os.Chown(filepath.Join(basedir, file.Directory, file.Name), file.User, file.Group)
if err := os.Chown(filepath.Join(basedir, file.Directory, file.Name), file.User, file.Group); err != nil {
return err
}
}
return nil
}
Expand Down

0 comments on commit 8734677

Please sign in to comment.