From c05afeacece9a7c4c81ecb9ab146017662ae3c89 Mon Sep 17 00:00:00 2001 From: Russell Centanni Date: Wed, 18 Sep 2024 13:14:56 -0400 Subject: [PATCH] chore: fix linting Signed-off-by: Russell Centanni --- cmd/cleanup/images.go | 3 ++- cmd/list/ports.go | 2 +- cmd/list/sync.go | 3 ++- pkg/devspace/build/builder/custom/custom.go | 7 ++++--- pkg/devspace/deploy/deploy.go | 2 +- pkg/devspace/hook/hook.go | 9 +++++---- pkg/util/log/file_logger.go | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/cmd/cleanup/images.go b/cmd/cleanup/images.go index f91fada105..7625a56369 100644 --- a/cmd/cleanup/images.go +++ b/cmd/cleanup/images.go @@ -2,6 +2,7 @@ package cleanup import ( "context" + "github.com/loft-sh/devspace/pkg/devspace/docker" "github.com/loft-sh/devspace/cmd/flags" @@ -76,7 +77,7 @@ func (cmd *imagesCmd) RunCleanupImages(f factory.Factory, cobraCmd *cobra.Comman } config := configInterface.Config() - if config.Images == nil || len(config.Images) == 0 { + if len(config.Images) == 0 { log.Done("No images found in config to delete") return nil } diff --git a/cmd/list/ports.go b/cmd/list/ports.go index 0d6f9e254e..7b8e884e6a 100644 --- a/cmd/list/ports.go +++ b/cmd/list/ports.go @@ -68,7 +68,7 @@ func (cmd *portsCmd) RunListPort(f factory.Factory, cobraCmd *cobra.Command, arg config := configInterface.Config() portForwards := make([][]string, 0) for _, dev := range config.Dev { - if dev.Ports == nil || len(dev.Ports) == 0 { + if len(dev.Ports) == 0 { continue } selector := "" diff --git a/cmd/list/sync.go b/cmd/list/sync.go index b1d530ffff..713a19cc10 100644 --- a/cmd/list/sync.go +++ b/cmd/list/sync.go @@ -2,6 +2,7 @@ package list import ( "context" + "github.com/loft-sh/devspace/cmd/flags" "github.com/loft-sh/devspace/pkg/util/factory" "github.com/loft-sh/devspace/pkg/util/log" @@ -57,7 +58,7 @@ func (cmd *syncCmd) RunListSync(f factory.Factory, cobraCmd *cobra.Command, args syncPaths := make([][]string, 0) for _, dev := range config.Dev { - if dev.Sync == nil || len(dev.Sync) == 0 { + if len(dev.Sync) == 0 { logger.Info("No sync paths are configured.") return nil } diff --git a/pkg/devspace/build/builder/custom/custom.go b/pkg/devspace/build/builder/custom/custom.go index d95ab5d19f..131ef0fd27 100644 --- a/pkg/devspace/build/builder/custom/custom.go +++ b/pkg/devspace/build/builder/custom/custom.go @@ -2,12 +2,13 @@ package custom import ( "fmt" + "io" + "strings" + "github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/runtime" devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context" "github.com/loft-sh/devspace/pkg/devspace/pipeline/engine" "github.com/sirupsen/logrus" - "io" - "strings" "github.com/bmatcuk/doublestar" "github.com/loft-sh/devspace/pkg/devspace/config/versions/latest" @@ -40,7 +41,7 @@ func NewBuilder(imageConf *latest.Image, imageTags []string) *Builder { // ShouldRebuild implements interface func (b *Builder) ShouldRebuild(ctx devspacecontext.Context, forceRebuild bool) (bool, error) { - if b.imageConf.Custom.OnChange == nil || len(b.imageConf.Custom.OnChange) == 0 { + if len(b.imageConf.Custom.OnChange) == 0 { return true, nil } diff --git a/pkg/devspace/deploy/deploy.go b/pkg/devspace/deploy/deploy.go index 4143a4addf..484cd96651 100644 --- a/pkg/devspace/deploy/deploy.go +++ b/pkg/devspace/deploy/deploy.go @@ -59,7 +59,7 @@ func (c *controller) Deploy(ctx devspacecontext.Context, deployments []string, o return nil } - if config.Deployments != nil && len(config.Deployments) > 0 { + if len(config.Deployments) > 0 { // Execute before deployments deploy hook err := hook.ExecuteHooks(ctx, nil, "before:"+event) if err != nil { diff --git a/pkg/devspace/hook/hook.go b/pkg/devspace/hook/hook.go index 9d54451644..d7a40794e1 100644 --- a/pkg/devspace/hook/hook.go +++ b/pkg/devspace/hook/hook.go @@ -3,6 +3,10 @@ package hook import ( "bytes" "fmt" + "io" + "strings" + "time" + "github.com/loft-sh/devspace/pkg/devspace/config/versions/latest" devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context" "github.com/loft-sh/devspace/pkg/devspace/plugin" @@ -13,10 +17,7 @@ import ( dockerterm "github.com/moby/term" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "io" "k8s.io/apimachinery/pkg/labels" - "strings" - "time" ) var ( @@ -105,7 +106,7 @@ func executeSingle(ctx devspacecontext.Context, extraEnv map[string]string, even } c := config.Config() - if c.Hooks != nil && len(c.Hooks) > 0 { + if len(c.Hooks) > 0 { hooksToExecute := []*latest.HookConfig{} // Gather all hooks we should execute diff --git a/pkg/util/log/file_logger.go b/pkg/util/log/file_logger.go index 62fb89450c..e26c879a08 100644 --- a/pkg/util/log/file_logger.go +++ b/pkg/util/log/file_logger.go @@ -121,7 +121,7 @@ func (f *fileLogger) Debugf(format string, args ...interface{}) { return } - f.logger.Debugf(f.addPrefixes(stripEscapeSequences(fmt.Sprintf(format, args...)))) + f.logger.Debug(f.addPrefixes(stripEscapeSequences(fmt.Sprintf(format, args...)))) } func (f *fileLogger) Info(args ...interface{}) {