diff --git a/internal/exec/engine.go b/internal/exec/engine.go index bdd4e78e8f..df609312fe 100644 --- a/internal/exec/engine.go +++ b/internal/exec/engine.go @@ -91,7 +91,7 @@ func (e Engine) Run(stageName string) error { systemBaseConfig, r, err := system.FetchBaseConfig(e.Logger, e.PlatformConfig.Name()) e.logReport(r) if err != nil && err != providers.ErrNoProvider { - e.Logger.Crit("failed to acquire system base config: %v", err) + _ = e.Logger.Crit("failed to acquire system base config: %v", err) return err } else if err == nil { e.fetchedConfigs = append(e.fetchedConfigs, fetchedConfig{ @@ -111,13 +111,13 @@ func (e Engine) Run(stageName string) error { if err == resource.ErrNeedNet && stageName == "fetch-offline" { err = SignalNeedNet() if err != nil { - e.Logger.Crit("failed to signal neednet: %v", err) + _ = e.Logger.Crit("failed to signal neednet: %v", err) } return err } else if err == errors.ErrEmpty { - e.Logger.Info("%v: ignoring user-provided config", err) + _ = e.Logger.Info("%v: ignoring user-provided config", err) } else if err != nil { - e.Logger.Crit("failed to acquire config: %v", err) + _ = e.Logger.Crit("failed to acquire config: %v", err) return err } @@ -145,7 +145,7 @@ func (e Engine) Run(stageName string) error { } return err } - e.Logger.Info("%s passed", stageName) + _ = e.Logger.Info("%s passed", stageName) return nil } @@ -182,7 +182,7 @@ func (e *Engine) acquireConfig(stageName string) (cfg types.Config, err error) { if err == nil { for _, cfgInfo := range e.fetchedConfigs { if logerr := logStructuredJournalEntry(cfgInfo); logerr != nil { - e.Logger.Info("failed to log systemd journal entry: %v", logerr) + _ = e.Logger.Info("failed to log systemd journal entry: %v", logerr) } } } @@ -201,14 +201,14 @@ func (e *Engine) acquireCachedConfig() (cfg types.Config, err error) { return } if err = json.Unmarshal(b, &cfg); err != nil { - e.Logger.Crit("failed to parse cached config: %v", err) + _ = e.Logger.Crit("failed to parse cached config: %v", err) return } // Create an http client and fetcher with the timeouts from the cached // config err = e.Fetcher.UpdateHttpTimeoutsAndCAs(cfg.Ignition.Timeouts, cfg.Ignition.Security.TLS.CertificateAuthorities, cfg.Ignition.Proxy) if err != nil { - e.Logger.Crit("failed to update timeouts and CAs for fetcher: %v", err) + _ = e.Logger.Crit("failed to update timeouts and CAs for fetcher: %v", err) return } return @@ -223,7 +223,7 @@ func (e *Engine) acquireProviderConfig() (cfg types.Config, err error) { emptyProxy := types.Proxy{} err = e.Fetcher.UpdateHttpTimeoutsAndCAs(types.Timeouts{HTTPTotal: &timeout}, nil, emptyProxy) if err != nil { - e.Logger.Crit("failed to update timeouts and CAs for fetcher: %v", err) + _ = e.Logger.Crit("failed to update timeouts and CAs for fetcher: %v", err) return } @@ -233,9 +233,9 @@ func (e *Engine) acquireProviderConfig() (cfg types.Config, err error) { // Continue if the provider config was empty as we want to write an empty // cache config for use by other stages. cfg = emptyConfig - e.Logger.Info("%v: provider config was empty, continuing with empty cache config", err) + _ = e.Logger.Info("%v: provider config was empty, continuing with empty cache config", err) } else if err != nil { - e.Logger.Warning("failed to fetch config: %s", err) + _ = e.Logger.Warning("failed to fetch config: %s", err) return } @@ -243,13 +243,13 @@ func (e *Engine) acquireProviderConfig() (cfg types.Config, err error) { // config err = e.Fetcher.UpdateHttpTimeoutsAndCAs(cfg.Ignition.Timeouts, cfg.Ignition.Security.TLS.CertificateAuthorities, cfg.Ignition.Proxy) if err != nil { - e.Logger.Crit("failed to update timeouts and CAs for fetcher: %v", err) + _ = e.Logger.Crit("failed to update timeouts and CAs for fetcher: %v", err) return } err = e.Fetcher.RewriteCAsWithDataUrls(cfg.Ignition.Security.TLS.CertificateAuthorities) if err != nil { - e.Logger.Crit("error handling CAs: %v", err) + _ = e.Logger.Crit("error handling CAs: %v", err) return } @@ -257,18 +257,18 @@ func (e *Engine) acquireProviderConfig() (cfg types.Config, err error) { e.logReport(rpt) if rpt.IsFatal() { err = errors.ErrInvalid - e.Logger.Crit("merging configs resulted in an invalid config") + _ = e.Logger.Crit("merging configs resulted in an invalid config") return } // Populate the config cache. b, err := json.Marshal(cfg) if err != nil { - e.Logger.Crit("failed to marshal cached config: %v", err) + _ = e.Logger.Crit("failed to marshal cached config: %v", err) return } if err = renameio.WriteFile(e.ConfigCache, b, 0640); err != nil { - e.Logger.Crit("failed to write cached config: %v", err) + _ = e.Logger.Crit("failed to write cached config: %v", err) return } @@ -382,7 +382,7 @@ func (e *Engine) renderConfig(cfg types.Config) (types.Config, error) { func (e *Engine) fetchReferencedConfig(cfgRef types.Resource) (types.Config, error) { // this is also already checked at validation time if cfgRef.Source == nil { - e.Logger.Crit("invalid referenced config: %v", errors.ErrSourceRequired) + _ = e.Logger.Crit("invalid referenced config: %v", errors.ErrSourceRequired) return types.Config{}, errors.ErrSourceRequired } u, err := url.Parse(*cfgRef.Source) @@ -410,10 +410,10 @@ func (e *Engine) fetchReferencedConfig(cfgRef types.Resource) (types.Config, err hash := sha512.Sum512(rawCfg) if u.Scheme != "data" { - e.Logger.Debug("fetched referenced config at %s with SHA512: %s", *cfgRef.Source, hex.EncodeToString(hash[:])) + _ = e.Logger.Debug("fetched referenced config at %s with SHA512: %s", *cfgRef.Source, hex.EncodeToString(hash[:])) } else { // data url's might contain secrets - e.Logger.Debug("fetched referenced config from data url with SHA512: %s", hex.EncodeToString(hash[:])) + _ = e.Logger.Debug("fetched referenced config from data url with SHA512: %s", hex.EncodeToString(hash[:])) } e.fetchedConfigs = append(e.fetchedConfigs, fetchedConfig{ @@ -451,11 +451,11 @@ func (e Engine) logReport(r report.Report) { for _, entry := range r.Entries { switch entry.Kind { case report.Error: - e.Logger.Crit("%v", entry) + _ = e.Logger.Crit("%v", entry) case report.Warn: - e.Logger.Warning("%v", entry) + _ = e.Logger.Warning("%v", entry) case report.Info: - e.Logger.Info("%v", entry) + _ = e.Logger.Info("%v", entry) } } } diff --git a/internal/exec/stages/disks/disks.go b/internal/exec/stages/disks/disks.go index d3703aa987..7f7460d3ee 100644 --- a/internal/exec/stages/disks/disks.go +++ b/internal/exec/stages/disks/disks.go @@ -144,7 +144,7 @@ func (s stage) createDeviceAliases(devs []string) error { if err != nil { return fmt.Errorf("failed to create device alias for %q: %v", dev, err) } - s.Logger.Info("created device alias for %q: %q -> %q", dev, util.DeviceAlias(dev), target) + _ = s.Logger.Info("created device alias for %q: %q -> %q", dev, util.DeviceAlias(dev), target) } return nil diff --git a/internal/exec/stages/disks/filesystems.go b/internal/exec/stages/disks/filesystems.go index eccfa8fcad..e0b076aa98 100644 --- a/internal/exec/stages/disks/filesystems.go +++ b/internal/exec/stages/disks/filesystems.go @@ -105,7 +105,7 @@ func (s stage) createFilesystem(fs types.Filesystem) error { var err2 error info, err2 = util.GetFilesystemInfo(devAlias, true) if err2 == nil { - s.Logger.Warning("%v", err) + _ = s.Logger.Warning("%v", err) } err = err2 } @@ -116,7 +116,7 @@ func (s stage) createFilesystem(fs types.Filesystem) error { if err != nil { return err } - s.Logger.Info("found %s filesystem at %q with uuid %q and label %q", info.Type, fs.Device, info.UUID, info.Label) + _ = s.Logger.Info("found %s filesystem at %q with uuid %q and label %q", info.Type, fs.Device, info.UUID, info.Label) if fs.WipeFilesystem == nil || !*fs.WipeFilesystem { // If the filesystem isn't forcefully being created, then we need @@ -124,10 +124,10 @@ func (s stage) createFilesystem(fs types.Filesystem) error { if info.Type == *fs.Format && (fs.Label == nil || info.Label == *fs.Label) && (fs.UUID == nil || canonicalizeFilesystemUUID(info.Type, info.UUID) == canonicalizeFilesystemUUID(*fs.Format, *fs.UUID)) { - s.Logger.Info("filesystem at %q is already correctly formatted. Skipping mkfs...", fs.Device) + _ = s.Logger.Info("filesystem at %q is already correctly formatted. Skipping mkfs...", fs.Device) return nil } else if info.Type != "" { - s.Logger.Err("filesystem at %q is not of the correct type, label, or UUID (found %s, %q, %s) and a filesystem wipe was not requested", fs.Device, info.Type, info.Label, info.UUID) + _ = s.Logger.Err("filesystem at %q is not of the correct type, label, or UUID (found %s, %q, %s) and a filesystem wipe was not requested", fs.Device, info.Type, info.Label, info.UUID) return ErrBadFilesystem } } diff --git a/internal/exec/stages/disks/luks.go b/internal/exec/stages/disks/luks.go index dbd30d3874..0c3f7abc29 100644 --- a/internal/exec/stages/disks/luks.go +++ b/internal/exec/stages/disks/luks.go @@ -176,7 +176,7 @@ func (s *stage) createLuks(config types.Config) error { var err2 error info, err2 = execUtil.GetFilesystemInfo(devAlias, true) if err2 == nil { - s.Logger.Warning("%v", err) + _ = s.Logger.Warning("%v", err) } err = err2 } @@ -187,15 +187,15 @@ func (s *stage) createLuks(config types.Config) error { if err != nil { return err } - s.Logger.Info("found %s at %q with uuid %q and label %q", info.Type, *luks.Device, info.UUID, info.Label) + _ = s.Logger.Info("found %s at %q with uuid %q and label %q", info.Type, *luks.Device, info.UUID, info.Label) if exists { // Re-used devices cannot have Ignition generated key-files or be clevis devices so we cannot // leak any key files when exiting the loop early - s.Logger.Info("volume at %q is already correctly formatted. Skipping...", *luks.Device) + _ = s.Logger.Info("volume at %q is already correctly formatted. Skipping...", *luks.Device) continue } else if info.Type != "" { - s.Logger.Err("volume at %q is not of the correct type, label, or UUID (found %s, %q, %s) and a volume wipe was not requested", *luks.Device, info.Type, info.Label, info.UUID) + _ = s.Logger.Err("volume at %q is not of the correct type, label, or UUID (found %s, %q, %s) and a volume wipe was not requested", *luks.Device, info.Type, info.Label, info.UUID) return ErrBadVolume } } else { diff --git a/internal/exec/stages/disks/partitions.go b/internal/exec/stages/disks/partitions.go index 330ca2789b..ff5ec6372d 100644 --- a/internal/exec/stages/disks/partitions.go +++ b/internal/exec/stages/disks/partitions.go @@ -320,7 +320,7 @@ func (p PartitionList) Swap(i, j int) { func (s stage) partitionDisk(dev types.Disk, devAlias string) error { if dev.WipeTable != nil && *dev.WipeTable { op := sgdisk.Begin(s.Logger, devAlias) - s.Logger.Info("wiping partition table requested on %q", devAlias) + _ = s.Logger.Info("wiping partition table requested on %q", devAlias) op.WipeTable(true) op.Commit() } @@ -356,7 +356,7 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error { // This is a translation of the matrix in the operator notes. switch { case !exists && !shouldExist: - s.Logger.Info("partition %d specified as nonexistant and no partition was found. Success.", part.Number) + _ = s.Logger.Info("partition %d specified as nonexistant and no partition was found. Success.", part.Number) case !exists && shouldExist: op.CreatePartition(part) case exists && !shouldExist && !wipeEntry: @@ -364,10 +364,10 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error { case exists && !shouldExist && wipeEntry: op.DeletePartition(part.Number) case exists && shouldExist && matches: - s.Logger.Info("partition %d found with correct specifications", part.Number) + _ = s.Logger.Info("partition %d found with correct specifications", part.Number) case exists && shouldExist && !wipeEntry && !matches: if partitionMatchesResize(info, part) { - s.Logger.Info("resizing partition %d", part.Number) + _ = s.Logger.Info("resizing partition %d", part.Number) op.DeletePartition(part.Number) part.Number = info.Number part.GUID = &info.GUID @@ -379,7 +379,7 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error { return fmt.Errorf("Partition %d didn't match: %v", part.Number, matchErr) } case exists && shouldExist && wipeEntry && !matches: - s.Logger.Info("partition %d did not meet specifications, wiping partition entry and recreating", part.Number) + _ = s.Logger.Info("partition %d did not meet specifications, wiping partition entry and recreating", part.Number) op.DeletePartition(part.Number) op.CreatePartition(part) default: diff --git a/internal/exec/stages/fetch/fetch.go b/internal/exec/stages/fetch/fetch.go index f453ec6373..e2cb0d9c4a 100644 --- a/internal/exec/stages/fetch/fetch.go +++ b/internal/exec/stages/fetch/fetch.go @@ -59,6 +59,6 @@ func (stage) Name() string { func (s stage) Run(_ types.Config) error { // Nothing - all we do is fetch and allow anything else in the initramfs to run - s.Logger.Info("fetch complete") + _ = s.Logger.Info("fetch complete") return nil } diff --git a/internal/exec/stages/files/files.go b/internal/exec/stages/files/files.go index 4d165e0a79..69ae874672 100644 --- a/internal/exec/stages/files/files.go +++ b/internal/exec/stages/files/files.go @@ -96,7 +96,7 @@ func (s stage) Run(config types.Config) error { // we only collect filenames if we need to. func (s *stage) checkRelabeling() error { if !distro.SelinuxRelabel() { - s.Logger.Debug("compiled without relabeling support, skipping") + _ = s.Logger.Debug("compiled without relabeling support, skipping") return nil } diff --git a/internal/exec/stages/files/filesystemEntries.go b/internal/exec/stages/files/filesystemEntries.go index 471c93968d..5ab17ef108 100644 --- a/internal/exec/stages/files/filesystemEntries.go +++ b/internal/exec/stages/files/filesystemEntries.go @@ -270,7 +270,7 @@ func (tmp linkEntry) create(l *log.Logger, u util.Util) error { if !os.SameFile(st, targetst) { return fmt.Errorf("error creating hard link %s: a file already exists at that path but is not the target and overwrite is false", s.Path) } - l.Info("Hardlink %s to %s already exists, doing nothing", s.Path, s.Target) + _ = l.Info("Hardlink %s to %s already exists, doing nothing", s.Path, s.Target) return nil case !hard: // if the existing file is a symlink, check that its target is correct @@ -280,7 +280,7 @@ func (tmp linkEntry) create(l *log.Logger, u util.Util) error { } else if filepath.Clean(target) != filepath.Clean(s.Target) { return fmt.Errorf("error creating symlink %s: a symlink exists at that path but points to %s, not %s and overwrite is false", s.Path, target, s.Target) } else { - l.Info("Symlink %s to %s already exists, doing nothing", s.Path, s.Target) + _ = l.Info("Symlink %s to %s already exists, doing nothing", s.Path, s.Target) return nil } } diff --git a/internal/exec/stages/files/units.go b/internal/exec/stages/files/units.go index 29de4e7c92..ea1fc57e40 100644 --- a/internal/exec/stages/files/units.go +++ b/internal/exec/stages/files/units.go @@ -208,7 +208,7 @@ func (s *stage) writeSystemdUnit(unit types.Unit, runtime bool) error { } f, err := u.FileFromSystemdUnitDropin(unit, dropin, runtime) if err != nil { - s.Logger.Crit("error converting systemd dropin: %v", err) + _ = s.Logger.Crit("error converting systemd dropin: %v", err) return err } relabelPath := f.Node.Path @@ -237,7 +237,7 @@ func (s *stage) writeSystemdUnit(unit types.Unit, runtime bool) error { f, err := u.FileFromSystemdUnit(unit, runtime) if err != nil { - s.Logger.Crit("error converting unit: %v", err) + _ = s.Logger.Crit("error converting unit: %v", err) return err } relabelPath := f.Node.Path diff --git a/internal/exec/util/file.go b/internal/exec/util/file.go index 2c71e5071d..562557bc25 100644 --- a/internal/exec/util/file.go +++ b/internal/exec/util/file.go @@ -57,7 +57,7 @@ func newFetchOp(l *log.Logger, node types.Node, contents types.Resource) (FetchO hasher, err := util.GetHasher(contents.Verification) if err != nil { - l.Crit("Error verifying file %q: %v", node.Path, err) + _ = l.Crit("Error verifying file %q: %v", node.Path, err) return FetchOp{}, err } @@ -67,7 +67,7 @@ func newFetchOp(l *log.Logger, node types.Node, contents types.Resource) (FetchO _, expectedSumString, _ := util.HashParts(contents.Verification) expectedSum, err = hex.DecodeString(expectedSumString) if err != nil { - l.Crit("Error parsing verification string %q: %v", expectedSumString, err) + _ = l.Crit("Error parsing verification string %q: %v", expectedSumString, err) return FetchOp{}, err } } @@ -195,7 +195,7 @@ func (u Util) PerformFetch(f FetchOp) error { err = u.Fetcher.Fetch(f.Url, tmp, f.FetchOptions) if err != nil { - u.Crit("Error fetching file %q: %v", path, err) + _ = u.Crit("Error fetching file %q: %v", path, err) return err } diff --git a/internal/log/log.go b/internal/log/log.go index aabc6f4d29..17a423ee61 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -51,7 +51,7 @@ func New(logToStdout bool) Logger { logger.ops, err = syslog.New(syslog.LOG_DEBUG, "ignition") if err != nil { logger.ops = Stdout{} - logger.Err("unable to open syslog: %v", err) + _ = logger.Err("unable to open syslog: %v", err) } return logger } @@ -114,7 +114,7 @@ func (l *Logger) PushPrefix(format string, a ...interface{}) { // The prefix stack is concatenated in FIFO order and prefixed to the start of every message logged via Logger. func (l *Logger) PopPrefix() { if len(l.prefixStack) == 0 { - l.Debug("popped from empty stack") + _ = l.Debug("popped from empty stack") return } l.prefixStack = l.prefixStack[:len(l.prefixStack)-1] @@ -140,7 +140,7 @@ func (l *Logger) LogCmd(cmd *exec.Cmd, format string, a ...interface{}) (int, er code := -1 f := func() error { cmdLine := QuotedCmd(cmd) - l.Debug("executing: %s", cmdLine) + _ = l.Debug("executing: %s", cmdLine) stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} @@ -175,17 +175,17 @@ func (l *Logger) LogOp(op func() error, format string, a ...interface{}) error { // logStart logs the start of a multi-step/substantial/time-consuming operation. func (l Logger) logStart(format string, a ...interface{}) { - l.Info(fmt.Sprintf("[started] %s", format), a...) + _ = l.Info(fmt.Sprintf("[started] %s", format), a...) } // logFail logs the failure of a multi-step/substantial/time-consuming operation. func (l Logger) logFail(format string, a ...interface{}) { - l.Crit(fmt.Sprintf("[failed] %s", format), a...) + _ = l.Crit(fmt.Sprintf("[failed] %s", format), a...) } // logFinish logs the completion of a multi-step/substantial/time-consuming operation. func (l Logger) logFinish(format string, a ...interface{}) { - l.Info(fmt.Sprintf("[finished] %s", format), a...) + _ = l.Info(fmt.Sprintf("[finished] %s", format), a...) } // log logs a formatted message using the supplied logFunc. diff --git a/internal/main.go b/internal/main.go index 173afc7bd7..374376f4fa 100644 --- a/internal/main.go +++ b/internal/main.go @@ -73,20 +73,19 @@ func main() { logger := log.New(flags.logToStdout) defer logger.Close() - - logger.Info(version.String) - logger.Info("Stage: %v", flags.stage) + _ = logger.Info(version.String) + _ = logger.Info("Stage: %v", flags.stage) if flags.clearCache { if err := os.Remove(flags.configCache); err != nil { - logger.Err("unable to clear cache: %v", err) + _ = logger.Err("unable to clear cache: %v", err) } } platformConfig := platform.MustGet(flags.platform.String()) fetcher, err := platformConfig.NewFetcherFunc()(&logger) if err != nil { - logger.Crit("failed to generate fetcher: %s", err) + _ = logger.Crit("failed to generate fetcher: %s", err) os.Exit(3) } engine := exec.Engine{ @@ -100,11 +99,11 @@ func main() { err = engine.Run(flags.stage.String()) if statusErr := engine.PlatformConfig.Status(flags.stage.String(), *engine.Fetcher, err); statusErr != nil { - logger.Err("POST Status error: %v", statusErr.Error()) + _ = logger.Err("POST Status error: %v", statusErr.Error()) } if err != nil { - logger.Crit("Ignition failed: %v", err.Error()) + _ = logger.Crit("Ignition failed: %v", err.Error()) os.Exit(1) } - logger.Info("Ignition finished successfully") + _ = logger.Info("Ignition finished successfully") } diff --git a/internal/providers/azure/azure.go b/internal/providers/azure/azure.go index ac9144b4c7..1783a0e816 100644 --- a/internal/providers/azure/azure.go +++ b/internal/providers/azure/azure.go @@ -69,7 +69,7 @@ func FetchFromOvfDevice(f *resource.Fetcher, ovfFsTypes []string) (types.Config, devicePath := filepath.Join(distro.DiskByIDDir(), configDeviceID) logger := f.Logger - logger.Debug("waiting for config DVD...") + _ = logger.Debug("waiting for config DVD...") waitForCdrom(logger, devicePath) fsType, err := checkOvfFsType(logger, devicePath, ovfFsTypes) @@ -82,20 +82,19 @@ func FetchFromOvfDevice(f *resource.Fetcher, ovfFsTypes []string) (types.Config, return types.Config{}, report.Report{}, fmt.Errorf("failed to create temp directory: %v", err) } defer os.Remove(mnt) - - logger.Debug("mounting config device") + _ = logger.Debug("mounting config device") if err := logger.LogOp( func() error { return unix.Mount(devicePath, mnt, fsType, unix.MS_RDONLY, "") }, "mounting %q at %q", devicePath, mnt, ); err != nil { return types.Config{}, report.Report{}, fmt.Errorf("failed to mount device %q at %q: %v", devicePath, mnt, err) } + //nolint:errcheck defer logger.LogOp( func() error { return unix.Unmount(mnt, 0) }, "unmounting %q at %q", devicePath, mnt, ) - - logger.Debug("reading config") + _ = logger.Debug("reading config") rawConfig, err := ioutil.ReadFile(filepath.Join(mnt, configPath)) if err != nil && !os.IsNotExist(err) { return types.Config{}, report.Report{}, fmt.Errorf("failed to read config: %v", err) @@ -111,15 +110,14 @@ func waitForCdrom(logger *log.Logger, devicePath string) { } func isCdromPresent(logger *log.Logger, devicePath string) bool { - logger.Debug("opening config device") + _ = logger.Debug("opening config device") device, err := os.Open(devicePath) if err != nil { - logger.Info("failed to open config device: %v", err) + _ = logger.Info("failed to open config device: %v", err) return false } defer device.Close() - - logger.Debug("getting drive status") + _ = logger.Debug("getting drive status") status, _, errno := unix.Syscall( unix.SYS_IOCTL, uintptr(device.Fd()), @@ -129,17 +127,17 @@ func isCdromPresent(logger *log.Logger, devicePath string) bool { switch status { case CDS_NO_INFO: - logger.Info("drive status: no info") + _ = logger.Info("drive status: no info") case CDS_NO_DISC: - logger.Info("drive status: no disc") + _ = logger.Info("drive status: no disc") case CDS_TRAY_OPEN: - logger.Info("drive status: open") + _ = logger.Info("drive status: open") case CDS_DRIVE_NOT_READY: - logger.Info("drive status: not ready") + _ = logger.Info("drive status: not ready") case CDS_DISC_OK: - logger.Info("drive status: OK") + _ = logger.Info("drive status: OK") default: - logger.Err("failed to get drive status: %s", errno.Error()) + _ = logger.Err("failed to get drive status: %s", errno.Error()) } return (status == CDS_DISC_OK) diff --git a/internal/providers/cloudstack/cloudstack.go b/internal/providers/cloudstack/cloudstack.go index 9f4e148a84..a7dc3647a4 100644 --- a/internal/providers/cloudstack/cloudstack.go +++ b/internal/providers/cloudstack/cloudstack.go @@ -67,9 +67,9 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { switch err { case context.Canceled: case context.DeadlineExceeded: - f.Logger.Err("timed out while fetching config from %s", name) + _ = f.Logger.Err("timed out while fetching config from %s", name) default: - f.Logger.Err("failed to fetch config from %s: %v", name, err) + _ = f.Logger.Err("failed to fetch config from %s: %v", name, err) } errChan <- err return @@ -97,13 +97,13 @@ Loop: select { case <-ctx.Done(): if ctx.Err() == context.DeadlineExceeded { - f.Logger.Info("neither config drive nor metadata service were available in time. Continuing without a config...") + _ = f.Logger.Info("neither config drive nor metadata service were available in time. Continuing without a config...") } break Loop case <-errChan: dispatchCount-- if dispatchCount == 0 { - f.Logger.Info("couldn't fetch config") + _ = f.Logger.Info("couldn't fetch config") break Loop } } @@ -181,7 +181,7 @@ func getDHCPServerAddress() (string, error) { func fetchConfigFromDevice(logger *log.Logger, ctx context.Context, label string) ([]byte, error) { for !labelExists(label) { - logger.Debug("config drive (%q) not found. Waiting...", label) + _ = logger.Debug("config drive (%q) not found. Waiting...", label) select { case <-time.After(time.Second): case <-ctx.Done(): @@ -193,8 +193,7 @@ func fetchConfigFromDevice(logger *log.Logger, ctx context.Context, label string if err != nil { return nil, err } - - logger.Debug("creating temporary mount point") + _ = logger.Debug("creating temporary mount point") mnt, err := ioutil.TempDir("", "ignition-configdrive") if err != nil { return nil, fmt.Errorf("failed to create temp directory: %v", err) @@ -205,10 +204,13 @@ func fetchConfigFromDevice(logger *log.Logger, ctx context.Context, label string if _, err := logger.LogCmd(cmd, "mounting config drive"); err != nil { return nil, err } - defer logger.LogOp( - func() error { return unix.Unmount(mnt, 0) }, - "unmounting %q at %q", path, mnt, - ) + + defer func() { + _ = logger.LogOp( + func() error { return unix.Unmount(mnt, 0) }, + "unmounting %q at %q", path, mnt, + ) + }() if !fileExists(filepath.Join(mnt, configDriveUserdataPath)) { return nil, nil diff --git a/internal/providers/cmdline/cmdline.go b/internal/providers/cmdline/cmdline.go index 6d158c135b..e4116a6509 100644 --- a/internal/providers/cmdline/cmdline.go +++ b/internal/providers/cmdline/cmdline.go @@ -57,20 +57,20 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { func readCmdline(logger *log.Logger) (*url.URL, error) { args, err := ioutil.ReadFile(distro.KernelCmdlinePath()) if err != nil { - logger.Err("couldn't read cmdline: %v", err) + _ = logger.Err("couldn't read cmdline: %v", err) return nil, err } rawUrl := parseCmdline(args) - logger.Debug("parsed url from cmdline: %q", rawUrl) + _ = logger.Debug("parsed url from cmdline: %q", rawUrl) if rawUrl == "" { - logger.Info("no config URL provided") + _ = logger.Info("no config URL provided") return nil, nil } url, err := url.Parse(rawUrl) if err != nil { - logger.Err("failed to parse url: %v", err) + _ = logger.Err("failed to parse url: %v", err) return nil, err } diff --git a/internal/providers/file/file.go b/internal/providers/file/file.go index 6631802d72..9c6753c3e2 100644 --- a/internal/providers/file/file.go +++ b/internal/providers/file/file.go @@ -34,13 +34,13 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { filename := os.Getenv(cfgFilenameEnvVar) if filename == "" { filename = defaultFilename - f.Logger.Info("using default filename") + _ = f.Logger.Info("using default filename") } - f.Logger.Info("using config file at %q", filename) + _ = f.Logger.Info("using config file at %q", filename) rawConfig, err := ioutil.ReadFile(filename) if err != nil { - f.Logger.Err("couldn't read config %q: %v", filename, err) + _ = f.Logger.Err("couldn't read config %q: %v", filename, err) return types.Config{}, report.Report{}, err } return util.ParseConfig(f.Logger, rawConfig) diff --git a/internal/providers/ibmcloud/ibmcloud.go b/internal/providers/ibmcloud/ibmcloud.go index f463e2b1e0..382c76ca3a 100644 --- a/internal/providers/ibmcloud/ibmcloud.go +++ b/internal/providers/ibmcloud/ibmcloud.go @@ -53,9 +53,9 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { switch err { case context.Canceled: case context.DeadlineExceeded: - f.Logger.Err("timed out while fetching config from %s", name) + _ = f.Logger.Err("timed out while fetching config from %s", name) default: - f.Logger.Err("failed to fetch config from %s: %v", name, err) + _ = f.Logger.Err("failed to fetch config from %s: %v", name, err) } return } @@ -70,7 +70,7 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { <-ctx.Done() if ctx.Err() == context.DeadlineExceeded { - f.Logger.Info("cidata drive was not available in time. Continuing without a config...") + _ = f.Logger.Info("cidata drive was not available in time. Continuing without a config...") } return util.ParseConfig(f.Logger, data) @@ -83,15 +83,14 @@ func fileExists(path string) bool { func fetchConfigFromDevice(logger *log.Logger, ctx context.Context, path string) ([]byte, error) { for !fileExists(path) { - logger.Debug("config drive (%q) not found. Waiting...", path) + _ = logger.Debug("config drive (%q) not found. Waiting...", path) select { case <-time.After(time.Second): case <-ctx.Done(): return nil, ctx.Err() } } - - logger.Debug("creating temporary mount point") + _ = logger.Debug("creating temporary mount point") mnt, err := ioutil.TempDir("", "ignition-configdrive") if err != nil { return nil, fmt.Errorf("failed to create temp directory: %v", err) @@ -102,10 +101,13 @@ func fetchConfigFromDevice(logger *log.Logger, ctx context.Context, path string) if _, err := logger.LogCmd(cmd, "mounting config drive"); err != nil { return nil, err } - defer logger.LogOp( - func() error { return syscall.Unmount(mnt, 0) }, - "unmounting %q at %q", path, mnt, - ) + + defer func() { + _ = logger.LogOp( + func() error { return syscall.Unmount(mnt, 0) }, + "unmounting %q at %q", path, mnt, + ) + }() if !fileExists(filepath.Join(mnt, cidataPath)) { return nil, nil diff --git a/internal/providers/noop/noop.go b/internal/providers/noop/noop.go index afce542a8b..dc82ad0b28 100644 --- a/internal/providers/noop/noop.go +++ b/internal/providers/noop/noop.go @@ -25,6 +25,6 @@ import ( ) func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { - f.Logger.Debug("noop provider fetching empty config") + _ = f.Logger.Debug("noop provider fetching empty config") return types.Config{}, report.Report{}, errors.ErrEmpty } diff --git a/internal/providers/openstack/openstack.go b/internal/providers/openstack/openstack.go index 8866180601..5f50d29842 100644 --- a/internal/providers/openstack/openstack.go +++ b/internal/providers/openstack/openstack.go @@ -72,9 +72,9 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { switch err { case context.Canceled: case context.DeadlineExceeded: - f.Logger.Err("timed out while fetching config from %s", name) + _ = f.Logger.Err("timed out while fetching config from %s", name) default: - f.Logger.Err("failed to fetch config from %s: %v", name, err) + _ = f.Logger.Err("failed to fetch config from %s: %v", name, err) } errChan <- err return @@ -102,13 +102,13 @@ Loop: select { case <-ctx.Done(): if ctx.Err() == context.DeadlineExceeded { - f.Logger.Info("neither config drive nor metadata service were available in time. Continuing without a config...") + _ = f.Logger.Info("neither config drive nor metadata service were available in time. Continuing without a config...") } break Loop case <-errChan: dispatchCount-- if dispatchCount == 0 { - f.Logger.Info("couldn't fetch config") + _ = f.Logger.Info("couldn't fetch config") break Loop } } @@ -124,15 +124,14 @@ func fileExists(path string) bool { func fetchConfigFromDevice(logger *log.Logger, ctx context.Context, path string) ([]byte, error) { for !fileExists(path) { - logger.Debug("config drive (%q) not found. Waiting...", path) + _ = logger.Debug("config drive (%q) not found. Waiting...", path) select { case <-time.After(time.Second): case <-ctx.Done(): return nil, ctx.Err() } } - - logger.Debug("creating temporary mount point") + _ = logger.Debug("creating temporary mount point") mnt, err := ioutil.TempDir("", "ignition-configdrive") if err != nil { return nil, fmt.Errorf("failed to create temp directory: %v", err) @@ -143,10 +142,13 @@ func fetchConfigFromDevice(logger *log.Logger, ctx context.Context, path string) if _, err := logger.LogCmd(cmd, "mounting config drive"); err != nil { return nil, err } - defer logger.LogOp( - func() error { return unix.Unmount(mnt, 0) }, - "unmounting %q at %q", path, mnt, - ) + + defer func() { + _ = logger.LogOp( + func() error { return unix.Unmount(mnt, 0) }, + "unmounting %q at %q", path, mnt, + ) + }() if !fileExists(filepath.Join(mnt, configDriveUserdataPath)) { return nil, nil diff --git a/internal/providers/packet/packet.go b/internal/providers/packet/packet.go index 592d95ad16..dc962251cc 100644 --- a/internal/providers/packet/packet.go +++ b/internal/providers/packet/packet.go @@ -69,7 +69,7 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { // PostStatus posts a message that will show on the Packet Instance Timeline func PostStatus(stageName string, f resource.Fetcher, errMsg error) error { - f.Logger.Info("POST message to Packet Timeline") + _ = f.Logger.Info("POST message to Packet Timeline") // fetch JSON from https://metadata.packet.net/metadata headers := make(http.Header) headers.Set("Accept", "*/*") diff --git a/internal/providers/qemu/qemu_fwcfg.go b/internal/providers/qemu/qemu_fwcfg.go index 696cfc5281..f0e693546b 100644 --- a/internal/providers/qemu/qemu_fwcfg.go +++ b/internal/providers/qemu/qemu_fwcfg.go @@ -44,9 +44,9 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { data, err := ioutil.ReadFile(firmwareConfigPath) if os.IsNotExist(err) { - f.Logger.Info("QEMU firmware config was not found. Ignoring...") + _ = f.Logger.Info("QEMU firmware config was not found. Ignoring...") } else if err != nil { - f.Logger.Err("couldn't read QEMU firmware config: %v", err) + _ = f.Logger.Err("couldn't read QEMU firmware config: %v", err) return types.Config{}, report.Report{}, err } diff --git a/internal/providers/system/system.go b/internal/providers/system/system.go index d1cda4485e..94526a4d1b 100644 --- a/internal/providers/system/system.go +++ b/internal/providers/system/system.go @@ -45,7 +45,7 @@ func FetchBaseConfig(logger *log.Logger, platformName string) (types.Config, rep platformDir := filepath.Join("base.platform.d", platformName) basePlatformDConfig, basePlatformDReport, err := fetchBaseDirectoryConfig(logger, platformDir) if err != nil { - logger.Info("no config at %q: %v", platformDir, err) + _ = logger.Info("no config at %q: %v", platformDir, err) } fullBaseConfig = latest.Merge(fullBaseConfig, basePlatformDConfig) fullReport.Merge(basePlatformDReport) @@ -58,14 +58,14 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { func fetchConfig(logger *log.Logger, filename string) (types.Config, report.Report, error) { path := filepath.Join(distro.SystemConfigDir(), filename) - logger.Info("reading system config file %q", path) + _ = logger.Info("reading system config file %q", path) rawConfig, err := ioutil.ReadFile(path) if os.IsNotExist(err) { - logger.Info("no config at %q", path) + _ = logger.Info("no config at %q", path) return types.Config{}, report.Report{}, providers.ErrNoProvider } else if err != nil { - logger.Err("couldn't read config %q: %v", path, err) + _ = logger.Err("couldn't read config %q: %v", path, err) return types.Config{}, report.Report{}, err } return util.ParseConfig(logger, rawConfig) @@ -78,14 +78,14 @@ func fetchBaseDirectoryConfig(logger *log.Logger, dir string) (types.Config, rep path := filepath.Join(distro.SystemConfigDir(), dir) configs, err := ioutil.ReadDir(path) if os.IsNotExist(err) { - logger.Info("no config dir at %q", path) + _ = logger.Info("no config dir at %q", path) return types.Config{}, report, nil } else if err != nil { - logger.Err("couldn't read config dir %q: %v", path, err) + _ = logger.Err("couldn't read config dir %q: %v", path, err) return types.Config{}, report, err } if len(configs) == 0 { - logger.Info("no configs at %q", path) + _ = logger.Info("no configs at %q", path) return types.Config{}, report, nil } for _, config := range configs { diff --git a/internal/providers/util/config.go b/internal/providers/util/config.go index b6e3fb19a4..425e5c1208 100644 --- a/internal/providers/util/config.go +++ b/internal/providers/util/config.go @@ -27,7 +27,7 @@ import ( func ParseConfig(logger *log.Logger, rawConfig []byte) (types.Config, report.Report, error) { hash := sha512.Sum512(rawConfig) - logger.Debug("parsing config with SHA512: %s", hex.EncodeToString(hash[:])) + _ = logger.Debug("parsing config with SHA512: %s", hex.EncodeToString(hash[:])) return config.Parse(rawConfig) } diff --git a/internal/providers/virtualbox/virtualbox.go b/internal/providers/virtualbox/virtualbox.go index e8c2dbc484..c844669805 100644 --- a/internal/providers/virtualbox/virtualbox.go +++ b/internal/providers/virtualbox/virtualbox.go @@ -37,13 +37,13 @@ const ( ) func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { - f.Logger.Debug("Attempting to read config drive") + _ = f.Logger.Debug("Attempting to read config drive") rawConfig, err := ioutil.ReadFile(filepath.Join(distro.DiskByPartUUIDDir(), partUUID)) if os.IsNotExist(err) { - f.Logger.Info("Path to ignition config does not exist, assuming no config") + _ = f.Logger.Info("Path to ignition config does not exist, assuming no config") return types.Config{}, report.Report{}, errors.ErrEmpty } else if err != nil { - f.Logger.Err("Error reading ignition config: %v", err) + _ = f.Logger.Err("Error reading ignition config: %v", err) return types.Config{}, report.Report{}, err } trimmedConfig := bytes.TrimRight(rawConfig, "\x00") diff --git a/internal/providers/vmware/vmware_amd64.go b/internal/providers/vmware/vmware_amd64.go index 62b0b61737..a6af894816 100644 --- a/internal/providers/vmware/vmware_amd64.go +++ b/internal/providers/vmware/vmware_amd64.go @@ -26,7 +26,7 @@ import ( "github.com/coreos/vcontext/report" "github.com/vmware/vmw-guestinfo/rpcvmx" "github.com/vmware/vmw-guestinfo/vmcheck" - "github.com/vmware/vmw-ovflib" + ovf "github.com/vmware/vmw-ovflib" ) func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { @@ -43,11 +43,10 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { decodedData, err := decodeConfig(config) if err != nil { - f.Logger.Debug("failed to decode config: %v", err) + _ = f.Logger.Debug("failed to decode config: %v", err) return types.Config{}, report.Report{}, err } - - f.Logger.Debug("config successfully fetched") + _ = f.Logger.Debug("config successfully fetched") return util.ParseConfig(f.Logger, decodedData) } @@ -59,12 +58,12 @@ func fetchRawConfig(f *resource.Fetcher) (config, error) { ovfEnv, err := info.String("ovfenv", "") if err != nil { - f.Logger.Warning("failed to fetch ovfenv: %v. Continuing...", err) + _ = f.Logger.Warning("failed to fetch ovfenv: %v. Continuing...", err) } else if ovfEnv != "" { - f.Logger.Debug("using OVF environment from guestinfo") + _ = f.Logger.Debug("using OVF environment from guestinfo") env, err := ovf.ReadEnvironment([]byte(ovfEnv)) if err != nil { - f.Logger.Warning("failed to parse OVF environment: %v. Continuing...", err) + _ = f.Logger.Warning("failed to parse OVF environment: %v. Continuing...", err) } ovfData = env.Properties["guestinfo.ignition.config.data"] @@ -73,13 +72,13 @@ func fetchRawConfig(f *resource.Fetcher) (config, error) { data, err := info.String("ignition.config.data", ovfData) if err != nil { - f.Logger.Debug("failed to fetch config: %v", err) + _ = f.Logger.Debug("failed to fetch config: %v", err) return config{}, err } encoding, err := info.String("ignition.config.data.encoding", ovfEncoding) if err != nil { - f.Logger.Debug("failed to fetch config encoding: %v", err) + _ = f.Logger.Debug("failed to fetch config encoding: %v", err) return config{}, err } diff --git a/internal/providers/zvm/zvm.go b/internal/providers/zvm/zvm.go index 47e302be17..043803259f 100644 --- a/internal/providers/zvm/zvm.go +++ b/internal/providers/zvm/zvm.go @@ -39,7 +39,7 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { // Fetch config files directly from reader device. _, err := f.Logger.LogCmd(exec.Command(distro.ModprobeCmd(), "vmur"), "Loading zVM control program module") if err != nil { - f.Logger.Err("Couldn't install vmur module: %v", err) + _ = f.Logger.Err("Couldn't install vmur module: %v", err) errors := fmt.Errorf("Couldn't install vmur module: %v", err) return types.Config{}, report.Report{}, errors } @@ -52,7 +52,7 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { // Read files from the z/VM reader queue. readerInfo, err := exec.Command(distro.VmurCmd(), "li").CombinedOutput() if err != nil { - f.Logger.Err("Can not get reader device: %v", err) + _ = f.Logger.Err("Can not get reader device: %v", err) errors := fmt.Errorf("Can not get reader device: %v", err) return types.Config{}, report.Report{}, errors } @@ -74,10 +74,10 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { if err != nil { return types.Config{}, report.Report{}, err } - f.Logger.Info("using config file at %q", file) + _ = f.Logger.Info("using config file at %q", file) rawConfig, err := ioutil.ReadFile(file) if err != nil { - f.Logger.Err("Couldn't read config from configFile %q: %v", file, err) + _ = f.Logger.Err("Couldn't read config from configFile %q: %v", file, err) break } jsonConfig := bytes.Trim(rawConfig, string(byte(0))) @@ -93,13 +93,13 @@ func onlineDevice(logger *log.Logger) error { // If online failed, expose the device firstly. _, err = logger.LogCmd(exec.Command(distro.CioIgnoreCmd(), "-r", readerDevice), "Expose reader device") if err != nil { - logger.Err("Couldn't expose reader device %q: %v", readerDevice, err) + _ = logger.Err("Couldn't expose reader device %q: %v", readerDevice, err) errors := fmt.Errorf("Couldn't expose reader device %q: %v", readerDevice, err) return errors } _, err = logger.LogCmd(exec.Command(distro.ChccwdevCmd(), "-e", readerDevice), "Brings a Linux device online") if err != nil { - logger.Err("Couldn't online reader device") + _ = logger.Err("Couldn't online reader device") errors := fmt.Errorf("Couldn't online reader device") return errors } diff --git a/internal/resource/http.go b/internal/resource/http.go index 0e417a4672..622b607da2 100644 --- a/internal/resource/http.go +++ b/internal/resource/http.go @@ -100,7 +100,7 @@ func (f *Fetcher) UpdateHttpTimeoutsAndCAs(timeouts types.Timeouts, cas []types. pool, err := x509.SystemCertPool() if err != nil { - f.Logger.Err("Unable to read system certificate pool: %s", err) + _ = f.Logger.Err("Unable to read system certificate pool: %s", err) return err } @@ -110,7 +110,7 @@ func (f *Fetcher) UpdateHttpTimeoutsAndCAs(timeouts types.Timeouts, cas []types. return err } if err := f.parseCABundle(cablob, ca, pool); err != nil { - f.Logger.Err("Unable to parse CA bundle: %s", err) + _ = f.Logger.Err("Unable to parse CA bundle: %s", err) return err } } @@ -123,15 +123,15 @@ func (f *Fetcher) parseCABundle(cablob []byte, ca types.Resource, pool *x509.Cer for len(cablob) > 0 { block, rest := pem.Decode(cablob) if block == nil { - f.Logger.Err("Unable to decode CA (%v)", ca.Source) + _ = f.Logger.Err("Unable to decode CA (%v)", ca.Source) return ErrPEMDecodeFailed } cert, err := x509.ParseCertificate(block.Bytes) if err != nil { - f.Logger.Err("Unable to parse CA (%v): %s", ca.Source, err) + _ = f.Logger.Err("Unable to parse CA (%v): %s", ca.Source, err) return err } - f.Logger.Info("Adding %q to list of CAs", cert.Subject.CommonName) + _ = f.Logger.Info("Adding %q to list of CAs", cert.Subject.CommonName) pool.AddCert(cert) cablob = rest } @@ -141,7 +141,7 @@ func (f *Fetcher) parseCABundle(cablob []byte, ca types.Resource, pool *x509.Cer func (f *Fetcher) getCABlob(ca types.Resource) ([]byte, error) { // this is also already checked at validation time if ca.Source == nil { - f.Logger.Crit("invalid CA: %v", ignerrors.ErrSourceRequired) + _ = f.Logger.Crit("invalid CA: %v", ignerrors.ErrSourceRequired) return nil, ignerrors.ErrSourceRequired } if blob, ok := f.client.cas[*ca.Source]; ok { @@ -149,12 +149,12 @@ func (f *Fetcher) getCABlob(ca types.Resource) ([]byte, error) { } u, err := url.Parse(*ca.Source) if err != nil { - f.Logger.Crit("Unable to parse CA URL: %s", err) + _ = f.Logger.Crit("Unable to parse CA URL: %s", err) return nil, err } hasher, err := util.GetHasher(ca.Verification) if err != nil { - f.Logger.Crit("Unable to get hasher: %s", err) + _ = f.Logger.Crit("Unable to get hasher: %s", err) return nil, err } @@ -165,7 +165,7 @@ func (f *Fetcher) getCABlob(ca types.Resource) ([]byte, error) { _, expectedSumString, _ := util.HashParts(ca.Verification) expectedSum, err = hex.DecodeString(expectedSumString) if err != nil { - f.Logger.Crit("Error parsing verification string %q: %v", expectedSumString, err) + _ = f.Logger.Crit("Error parsing verification string %q: %v", expectedSumString, err) return nil, err } } @@ -190,7 +190,7 @@ func (f *Fetcher) getCABlob(ca types.Resource) ([]byte, error) { Compression: compression, }) if err != nil { - f.Logger.Err("Unable to fetch CA (%s): %s", u, err) + _ = f.Logger.Err("Unable to fetch CA (%s): %s", u, err) return nil, err } f.client.cas[*ca.Source] = cablob @@ -290,17 +290,17 @@ func (c HttpClient) getReaderWithHeader(url string, header http.Header) (io.Read duration := initialBackoff for attempt := 1; ; attempt++ { - c.logger.Info("GET %s: attempt #%d", url, attempt) + _ = c.logger.Info("GET %s: attempt #%d", url, attempt) resp, err := c.client.Do(req.WithContext(ctx)) if err == nil { - c.logger.Info("GET result: %s", http.StatusText(resp.StatusCode)) + _ = c.logger.Info("GET result: %s", http.StatusText(resp.StatusCode)) if resp.StatusCode < 500 { return resp.Body, resp.StatusCode, cancelFn, nil } resp.Body.Close() } else { - c.logger.Info("GET error: %v", err) + _ = c.logger.Info("GET error: %v", err) } duration = duration * 2 diff --git a/internal/resource/url.go b/internal/resource/url.go index 9adf7e87b7..564c61bd55 100644 --- a/internal/resource/url.go +++ b/internal/resource/url.go @@ -348,7 +348,7 @@ func (f *Fetcher) fetchFromGCS(u url.URL, dest io.Writer, opts FetchOptions) err } clientOption = option.WithCredentials(creds) } else { - f.Logger.Debug("falling back to unauthenticated GCS access") + _ = f.Logger.Debug("falling back to unauthenticated GCS access") clientOption = option.WithoutAuthentication() } @@ -447,7 +447,7 @@ func (f *Fetcher) fetchFromS3(u url.URL, dest s3target, opts FetchOptions) error Expected: hex.EncodeToString(opts.ExpectedSum), } } - f.Logger.Debug("file matches expected sum of: %s", hex.EncodeToString(opts.ExpectedSum)) + _ = f.Logger.Debug("file matches expected sum of: %s", hex.EncodeToString(opts.ExpectedSum)) } return nil } @@ -512,7 +512,7 @@ func (f *Fetcher) decompressCopyHashAndVerify(dest io.Writer, src io.Reader, opt Expected: hex.EncodeToString(opts.ExpectedSum), } } - f.Logger.Debug("file matches expected sum of: %s", hex.EncodeToString(opts.ExpectedSum)) + _ = f.Logger.Debug("file matches expected sum of: %s", hex.EncodeToString(opts.ExpectedSum)) } return nil } diff --git a/internal/sgdisk/sgdisk.go b/internal/sgdisk/sgdisk.go index ecca192208..cb337bc00e 100644 --- a/internal/sgdisk/sgdisk.go +++ b/internal/sgdisk/sgdisk.go @@ -77,7 +77,7 @@ func (op *Operation) WipeTable(wipe bool) { func (op *Operation) Pretend() (string, error) { opts := []string{"--pretend"} opts = append(opts, op.buildOptions()...) - op.logger.Info("running sgdisk with options: %v", opts) + _ = op.logger.Info("running sgdisk with options: %v", opts) cmd := exec.Command(distro.SgdiskCmd(), opts...) stdout, err := cmd.StdoutPipe() @@ -115,7 +115,7 @@ func (op *Operation) Commit() error { if len(opts) == 0 { return nil } - op.logger.Info("running sgdisk with options: %v", opts) + _ = op.logger.Info("running sgdisk with options: %v", opts) cmd := exec.Command(distro.SgdiskCmd(), opts...) if _, err := op.logger.LogCmd(cmd, "deleting %d partitions and creating %d partitions on %q", len(op.deletions), len(op.parts), op.dev); err != nil { return fmt.Errorf("create partitions failed: %v", err) diff --git a/tests/filesystem.go b/tests/filesystem.go index e1a570fe5d..d6cbad965a 100644 --- a/tests/filesystem.go +++ b/tests/filesystem.go @@ -224,7 +224,7 @@ func setupDisk(ctx context.Context, disk *types.Disk, diskIndex int, imageSize i loopdev := disk.Device defer func() { if err != nil { - destroyDevice(loopdev) + _ = destroyDevice(loopdev) } }() diff --git a/tests/negative/security/tls.go b/tests/negative/security/tls.go index 16f1c2ed38..0df69e7b24 100644 --- a/tests/negative/security/tls.go +++ b/tests/negative/security/tls.go @@ -74,10 +74,10 @@ var ( }`) customCAServer = httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write(customCAServerFile) + _, _ = w.Write(customCAServerFile) })) customCAServer2 = httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write(customCAServerFile2) + _, _ = w.Write(customCAServerFile2) })) ) diff --git a/tests/negative/timeouts/timeouts.go b/tests/negative/timeouts/timeouts.go index 462c3eba80..95a8ef9c7b 100644 --- a/tests/negative/timeouts/timeouts.go +++ b/tests/negative/timeouts/timeouts.go @@ -44,6 +44,7 @@ var ( time.Sleep(time.Second * 2) // Give a config that merges ourselves and sets the timeouts to 1 // second (less than we wait!) + //nolint:errcheck w.Write([]byte(fmt.Sprintf(`{ "ignition": { "version": "$version", @@ -161,7 +162,7 @@ func AppendNoneThenLowerHTTPTimeouts() types.Test { time.Sleep(time.Second * 2) // Give a config that merges ourselves and sets the timeouts to 1 // second (less than we wait!) - w.Write([]byte(`{ + _, _ = w.Write([]byte(`{ "ignition": { "version": "$version" } @@ -171,7 +172,7 @@ func AppendNoneThenLowerHTTPTimeouts() types.Test { configNoDelayServer = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Give a config that merges ourselves and sets the timeouts to 1 // second (less than we wait!) - w.Write([]byte(fmt.Sprintf(`{ + _, _ = w.Write([]byte(fmt.Sprintf(`{ "ignition": "version": "$version", "config": { diff --git a/tests/positive/proxy/http.go b/tests/positive/proxy/http.go index bdf6d20d2c..1863c744e0 100644 --- a/tests/positive/proxy/http.go +++ b/tests/positive/proxy/http.go @@ -25,7 +25,7 @@ import ( var ( proxyServer = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(ignConfig)) + _, _ = w.Write([]byte(ignConfig)) })) mockConfigURL = "http://www.fake.tld" diff --git a/tests/positive/security/tls.go b/tests/positive/security/tls.go index e67fab9b57..0b52d78435 100644 --- a/tests/positive/security/tls.go +++ b/tests/positive/security/tls.go @@ -78,10 +78,10 @@ var ( }`) customCAServer = httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write(customCAServerFile) + _, _ = w.Write(customCAServerFile) })) customCAServer2 = httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write(customCAServerFile2) + _, _ = w.Write(customCAServerFile2) })) ) diff --git a/tests/servers/servers.go b/tests/servers/servers.go index ba32b245ef..d477248d01 100644 --- a/tests/servers/servers.go +++ b/tests/servers/servers.go @@ -61,19 +61,19 @@ fdsa`) // HTTP Server func (server *HTTPServer) Config(w http.ResponseWriter, r *http.Request) { - w.Write(servedConfig) + _, _ = w.Write(servedConfig) } func (server *HTTPServer) Contents(w http.ResponseWriter, r *http.Request) { - w.Write(servedContents) + _, _ = w.Write(servedContents) } func (server *HTTPServer) Certificates(w http.ResponseWriter, r *http.Request) { - w.Write(fixtures.PublicKey) + _, _ = w.Write(fixtures.PublicKey) } func (server *HTTPServer) CABundle(w http.ResponseWriter, r *http.Request) { - w.Write(fixtures.CABundle) + _, _ = w.Write(fixtures.CABundle) } func compress(contents []byte) []byte { @@ -89,20 +89,20 @@ func compress(contents []byte) []byte { } func (server *HTTPServer) ConfigCompressed(w http.ResponseWriter, r *http.Request) { - w.Write(compress(servedConfig)) + _, _ = w.Write(compress(servedConfig)) } func (server *HTTPServer) ContentsCompressed(w http.ResponseWriter, r *http.Request) { - w.Write(compress(servedContents)) + _, _ = w.Write(compress(servedContents)) } func (server *HTTPServer) CertificatesCompressed(w http.ResponseWriter, r *http.Request) { - w.Write(compress(fixtures.PublicKey)) + _, _ = w.Write(compress(fixtures.PublicKey)) } func errorHandler(w http.ResponseWriter, message string) { w.WriteHeader(http.StatusBadRequest) - w.Write([]byte(message)) + _, _ = w.Write([]byte(message)) } // headerCheck validates that all required headers are present @@ -160,20 +160,17 @@ func overwrittenHeaderCheck(w http.ResponseWriter, r *http.Request) { func (server *HTTPServer) ConfigHeaders(w http.ResponseWriter, r *http.Request) { headerCheck(w, r) - - w.Write(servedConfig) + _, _ = w.Write(servedConfig) } func (server *HTTPServer) ContentsHeaders(w http.ResponseWriter, r *http.Request) { headerCheck(w, r) - - w.Write(servedContents) + _, _ = w.Write(servedContents) } func (server *HTTPServer) CertificatesHeaders(w http.ResponseWriter, r *http.Request) { headerCheck(w, r) - - w.Write(fixtures.PublicKey) + _, _ = w.Write(fixtures.PublicKey) } // redirectedHeaderCheck validates that user's headers from the original request are missing @@ -197,8 +194,7 @@ func (server *HTTPServer) ConfigRedirect(w http.ResponseWriter, r *http.Request) // ConfigRedirected validates the request from ConfigRedirect func (server *HTTPServer) ConfigRedirected(w http.ResponseWriter, r *http.Request) { redirectedHeaderCheck(w, r) - - w.Write(servedConfig) + _, _ = w.Write(servedConfig) } // ContentsRedirect redirects the request to ContentsRedirected @@ -209,8 +205,7 @@ func (server *HTTPServer) ContentsRedirect(w http.ResponseWriter, r *http.Reques // ContentsRedirected validates the request from ContentsRedirect func (server *HTTPServer) ContentsRedirected(w http.ResponseWriter, r *http.Request) { redirectedHeaderCheck(w, r) - - w.Write(servedContents) + _, _ = w.Write(servedContents) } // CertificatesRedirect redirects the request to CertificatesRedirected @@ -221,26 +216,22 @@ func (server *HTTPServer) CertificatesRedirect(w http.ResponseWriter, r *http.Re // CertificatesRedirected validates the request from CertificatesRedirect func (server *HTTPServer) CertificatesRedirected(w http.ResponseWriter, r *http.Request) { redirectedHeaderCheck(w, r) - - w.Write(fixtures.PublicKey) + _, _ = w.Write(fixtures.PublicKey) } func (server *HTTPServer) ConfigHeadersOverwrite(w http.ResponseWriter, r *http.Request) { overwrittenHeaderCheck(w, r) - - w.Write(servedConfig) + _, _ = w.Write(servedConfig) } func (server *HTTPServer) ContentsHeadersOverwrite(w http.ResponseWriter, r *http.Request) { overwrittenHeaderCheck(w, r) - - w.Write(servedContents) + _, _ = w.Write(servedContents) } func (server *HTTPServer) CertificatesHeadersOverwrite(w http.ResponseWriter, r *http.Request) { overwrittenHeaderCheck(w, r) - - w.Write(fixtures.PublicKey) + _, _ = w.Write(fixtures.PublicKey) } type HTTPServer struct{} @@ -266,6 +257,7 @@ func (server *HTTPServer) Start() { http.HandleFunc("/config_headers_overwrite", server.ConfigHeadersOverwrite) http.HandleFunc("/caBundle", server.CABundle) s := &http.Server{Addr: ":8080"} + //nolint:errcheck go s.ListenAndServe() } @@ -293,5 +285,6 @@ type TFTPServer struct{} func (server *TFTPServer) Start() { s := tftp.NewServer(server.ReadHandler, nil) s.SetTimeout(5 * time.Second) + //nolint:errcheck go s.ListenAndServe(":69") }