Skip to content

Commit

Permalink
Enable unconvert linter
Browse files Browse the repository at this point in the history
... and fix lints on the way.

Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Nov 13, 2024
1 parent d0915d1 commit a902f45
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/sysinfo/probes/memory_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})

Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/autopilot/v1beta2/updateconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -227,15 +227,15 @@ 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,
}
}
if cmd.AirgapUpdate != nil {
planCmd.AirgapUpdate = &PlanCommandAirgapUpdate{
Version: string(nextVersion.Version),
Version: nextVersion.Version,
Platforms: airgapPlatforms,
Workers: cmd.AirgapUpdate.Workers,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/autopilot/controller/updates/periodicupdater.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/controller/extensions_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/controller/updateprober.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a902f45

Please sign in to comment.