diff --git a/.golangci.yml b/.golangci.yml index 95c75c2aa128..5e18653cfca3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,9 +16,10 @@ linters: - errorlint # Find code that will cause problems with Go's error wrapping scheme - gofmt # Checks whether code was gofmt-ed - goheader # Checks is file headers matche a given pattern - - intrange # checking for loops that could use an integer range + - intrange # Checking for loops that could use an integer range - revive # Stricter drop-in replacement for golint - testifylint # Checks usage of github.com/stretchr/testify + - unconvert # Checks for unnecessary type conversions linters-settings: depguard: diff --git a/internal/pkg/sysinfo/probes/memory_linux.go b/internal/pkg/sysinfo/probes/memory_linux.go index c99a91084500..2a212a168695 100644 --- a/internal/pkg/sysinfo/probes/memory_linux.go +++ b/internal/pkg/sysinfo/probes/memory_linux.go @@ -33,7 +33,8 @@ func newTotalMemoryProber() totalMemoryProber { if err = syscall.Sysinfo(&info); err != nil { err = fmt.Errorf("sysinfo syscall failed: %w", err) } else { - totalMemory = uint64(info.Totalram) * uint64(info.Unit) // explicit cast to support 32-bit systems + //nolint:unconvert // explicit cast to support 32-bit systems + totalMemory = uint64(info.Totalram) * uint64(info.Unit) } }) diff --git a/pkg/apis/autopilot/v1beta2/updateconfig.go b/pkg/apis/autopilot/v1beta2/updateconfig.go index b08d3a34ad6e..857dcda84665 100644 --- a/pkg/apis/autopilot/v1beta2/updateconfig.go +++ b/pkg/apis/autopilot/v1beta2/updateconfig.go @@ -206,7 +206,7 @@ func (uc *UpdateConfig) ToPlan(nextVersion uc.VersionInfo) Plan { if !updateCommandFound { p.Spec.Commands = append(p.Spec.Commands, PlanCommand{ K0sUpdate: &PlanCommandK0sUpdate{ - Version: string(nextVersion.Version), + Version: nextVersion.Version, Platforms: platforms, Targets: PlanCommandTargets{ Controllers: PlanCommandTarget{ @@ -227,7 +227,7 @@ func (uc *UpdateConfig) ToPlan(nextVersion uc.VersionInfo) Plan { planCmd := PlanCommand{} if cmd.K0sUpdate != nil { planCmd.K0sUpdate = &PlanCommandK0sUpdate{ - Version: string(nextVersion.Version), + Version: nextVersion.Version, ForceUpdate: cmd.K0sUpdate.ForceUpdate, Platforms: platforms, Targets: cmd.K0sUpdate.Targets, @@ -235,7 +235,7 @@ func (uc *UpdateConfig) ToPlan(nextVersion uc.VersionInfo) Plan { } if cmd.AirgapUpdate != nil { planCmd.AirgapUpdate = &PlanCommandAirgapUpdate{ - Version: string(nextVersion.Version), + Version: nextVersion.Version, Platforms: airgapPlatforms, Workers: cmd.AirgapUpdate.Workers, } diff --git a/pkg/autopilot/controller/updates/periodicupdater.go b/pkg/autopilot/controller/updates/periodicupdater.go index 2baf26bf5283..1aab0b668b81 100644 --- a/pkg/autopilot/controller/updates/periodicupdater.go +++ b/pkg/autopilot/controller/updates/periodicupdater.go @@ -64,7 +64,7 @@ func (u *periodicUpdater) Config() *apv1beta2.UpdateConfig { func (u *periodicUpdater) Run() error { u.log.Debug("starting periodic updater") - checkDuration := time.Duration(10 * time.Minute) + checkDuration := 10 * time.Minute // ENV var used only for testing purposes if e := os.Getenv("K0S_UPDATE_PERIOD"); e != "" { cd, err := time.ParseDuration(e) diff --git a/pkg/component/controller/extensions_controller.go b/pkg/component/controller/extensions_controller.go index 8331622296eb..6641a53ae18c 100644 --- a/pkg/component/controller/extensions_controller.go +++ b/pkg/component/controller/extensions_controller.go @@ -258,7 +258,7 @@ func removeFinalizer(ctx context.Context, c client.Client, chart *helmv1beta1.Ch return c.Patch(ctx, chart, client.RawPatch(types.JSONPatchType, patch)) } -const defaultTimeout = time.Duration(10 * time.Minute) +const defaultTimeout = 10 * time.Minute func (cr *ChartReconciler) updateOrInstallChart(ctx context.Context, chart helmv1beta1.Chart) error { var err error diff --git a/pkg/component/controller/updateprober.go b/pkg/component/controller/updateprober.go index 152feaf97556..20b27319724f 100644 --- a/pkg/component/controller/updateprober.go +++ b/pkg/component/controller/updateprober.go @@ -60,7 +60,7 @@ func (u *UpdateProber) Start(ctx context.Context) error { u.log.Debug("starting up") // Check for updates in 30min intervals from default update server // ENV var only to be used for testing purposes - updateCheckInterval := time.Duration(30 * time.Minute) + updateCheckInterval := 30 * time.Minute if os.Getenv("K0S_UPDATE_CHECK_INTERVAL") != "" { d, err := time.ParseDuration(os.Getenv("K0S_UPDATE_CHECK_INTERVAL")) if err != nil {