diff --git a/.golangci.yml b/.golangci.yml index 4986165..0f5329f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -126,6 +126,10 @@ linters-settings: - prometheus.LinearBuckets - cobra.MinimumNArgs + gomoddirectives: + replace-allow-list: + - k8s.io/kube-openapi + gomodguard: blocked: # List of blocked modules. @@ -335,3 +339,26 @@ issues: - gosec - noctx - wrapcheck + - linters: [ staticcheck ] + text: "options.AndFrom is deprecated" + - linters: [ staticcheck ] + text: "The component config package has been deprecated and will be removed in a future release." + - path: "cmd/" + linters: + - gochecknoinits + - gochecknoglobals + # Exclude `lll` issues for long lines with `go:generate`. + - linters: + - lll + source: '^//\s*\+kubebuilder:' + - linters: + - godot + source: '^//\s*\+optional' + - path: "api/v1/" + linters: + - gochecknoinits + # Allow dot imports for ginkgo and gomega + - source: ginkgo|gomega + linters: + - revive + text: "should not use dot imports" diff --git a/cmd/rsc/host.go b/cmd/rsc/host.go index 5dff7fe..1d6fb44 100644 --- a/cmd/rsc/host.go +++ b/cmd/rsc/host.go @@ -13,14 +13,12 @@ import ( "github.com/spf13/cobra" ) -//nolint:gochecknoglobals // cobra uses globals in main var cmdHost = &cobra.Command{ Use: "host", Aliases: []string{"h"}, Short: "Host Commands", } -//nolint:gochecknoinits // init is used in main for cobra func init() { rootCmd.AddCommand(cmdHost) } diff --git a/cmd/rsc/host_info.go b/cmd/rsc/host_info.go index 21ab541..bd6a4c8 100644 --- a/cmd/rsc/host_info.go +++ b/cmd/rsc/host_info.go @@ -3,7 +3,6 @@ package main import ( "context" "errors" - "fmt" "io" "strings" "text/template" @@ -15,7 +14,6 @@ import ( "go.uber.org/zap" ) -//nolint:gochecknoglobals // cobra uses globals in main var cmdHostInfo = &cobra.Command{ Use: "info [id|name]", Short: "Host Info", @@ -23,7 +21,6 @@ var cmdHostInfo = &cobra.Command{ Args: cobra.MinimumNArgs(1), } -//nolint:gochecknoinits // init is used in main for cobra func init() { cmdHostInfo.PersistentFlags().StringP("format", "f", "{{.Name}}\t{{time .LastSeen}}\t{{.LastSeenAgo}}\t{{.Tag}}\t{{.Capability}}\t{{time .SystemStart}}"+ @@ -63,7 +60,7 @@ func hostInfoCommand(_ *cobra.Command, args []string) { } if !strings.HasSuffix(viper.GetString("host.info.format"), "\n") { - viper.Set("host.info.format", fmt.Sprintf("%s\n", viper.GetString("host.info.format"))) + viper.Set("host.info.format", viper.GetString("host.info.format")+"\n") } tmpl, err := template.New("").Funcs(basicFunctions()).Parse(viper.GetString("host.info.format")) diff --git a/cmd/rsc/host_ls.go b/cmd/rsc/host_ls.go index 01694cf..fd6c11d 100644 --- a/cmd/rsc/host_ls.go +++ b/cmd/rsc/host_ls.go @@ -3,7 +3,6 @@ package main import ( "context" "errors" - "fmt" "io" "strings" "text/template" @@ -15,7 +14,6 @@ import ( "go.uber.org/zap" ) -//nolint:gochecknoglobals // cobra uses globals in main var cmdHostList = &cobra.Command{ Use: "ls", Short: "List Hosts", @@ -23,7 +21,6 @@ var cmdHostList = &cobra.Command{ Args: cobra.NoArgs, } -//nolint:gochecknoinits // init is used in main for cobra func init() { cmdHostList.PersistentFlags().StringP("format", "f", "{{.Name}}\t{{.Active}}\t{{time .LastSeen}}\t{{age .LastSeen}}\t{{.Tag}}\t{{.Capability}}\t{{age .SystemStart}}"+ @@ -59,7 +56,7 @@ func hostListCommand(_ *cobra.Command, _ []string) { } if !strings.HasSuffix(viper.GetString("host.list.format"), "\n") { - viper.Set("host.list.format", fmt.Sprintf("%s\n", viper.GetString("host.list.format"))) + viper.Set("host.list.format", viper.GetString("host.list.format")+"\n") } tmpl, err := template.New("").Funcs(basicFunctions()).Parse(viper.GetString("host.list.format")) diff --git a/cmd/rsc/host_rm.go b/cmd/rsc/host_rm.go index 208fa5f..e5c9ff2 100644 --- a/cmd/rsc/host_rm.go +++ b/cmd/rsc/host_rm.go @@ -11,7 +11,6 @@ import ( "go.uber.org/zap" ) -//nolint:gochecknoglobals // cobra uses globals in main var cmdHostRemove = &cobra.Command{ Use: "rm [hostname0]...[hostnameN]", Short: "Remove Host(s)", @@ -19,7 +18,6 @@ var cmdHostRemove = &cobra.Command{ Args: cobra.MinimumNArgs(1), } -//nolint:gochecknoinits // init is used in main for cobra func init() { cmdHost.AddCommand(cmdHostRemove) } diff --git a/cmd/rsc/main.go b/cmd/rsc/main.go index 8f1cf2a..e55f575 100644 --- a/cmd/rsc/main.go +++ b/cmd/rsc/main.go @@ -15,12 +15,10 @@ import ( "google.golang.org/grpc" ) -//nolint:gochecknoglobals // cobra uses globals in main var rootCmd = &cobra.Command{ Use: "rsc", } -//nolint:gochecknoinits // init is used in main for cobra func init() { cobra.OnInitialize(mainconfig.ConfigInit) @@ -36,7 +34,7 @@ func main() { func grpcServer(server string) string { host, port, err := net.SplitHostPort(server) if err != nil { - return fmt.Sprintf("%s:5888", server) + return server + ":5888" } if port == "" { diff --git a/cmd/rsc/trigger.go b/cmd/rsc/trigger.go index 454f9c9..c5c74ad 100644 --- a/cmd/rsc/trigger.go +++ b/cmd/rsc/trigger.go @@ -4,14 +4,12 @@ import ( "github.com/spf13/cobra" ) -//nolint:gochecknoglobals // cobra uses globals in main var cmdTrigger = &cobra.Command{ Use: "trigger", Aliases: []string{"t"}, Short: "Trigger Commands", } -//nolint:gochecknoinits // init is used in main for cobra func init() { rootCmd.AddCommand(cmdTrigger) } diff --git a/cmd/rsc/trigger_all.go b/cmd/rsc/trigger_all.go index df2709c..b31af66 100644 --- a/cmd/rsc/trigger_all.go +++ b/cmd/rsc/trigger_all.go @@ -12,7 +12,6 @@ import ( "go.uber.org/zap" ) -//nolint:gochecknoglobals // cobra uses globals in main var cmdTriggerAll = &cobra.Command{ Use: "all [options ...] [host...] [hostN]", Aliases: []string{"a"}, @@ -21,7 +20,6 @@ var cmdTriggerAll = &cobra.Command{ Args: cobra.MinimumNArgs(0), } -//nolint:gochecknoinits // init is used in main for cobra func init() { cmdTrigger.AddCommand(cmdTriggerAll) cmdTriggerAll.PersistentFlags().BoolP("info", "i", false, diff --git a/cmd/rsc/version.go b/cmd/rsc/version.go index 65fcd33..32f2188 100644 --- a/cmd/rsc/version.go +++ b/cmd/rsc/version.go @@ -4,7 +4,6 @@ import ( "fmt" ) -//nolint:gochecknoglobals // these have to be variables for the linker to change the values var ( version = "dev" date = "notset" @@ -12,7 +11,6 @@ var ( builtBy = "" ) -//nolint:gochecknoinits // init is used in main for cobra func init() { rootCmd.Version = fmt.Sprintf("%s [%s] (%s) <%s>", version, commit, date, builtBy) } diff --git a/cmd/rsca/main.go b/cmd/rsca/main.go index bd7ef42..db8b342 100644 --- a/cmd/rsca/main.go +++ b/cmd/rsca/main.go @@ -24,13 +24,11 @@ import ( "google.golang.org/grpc" ) -//nolint:gochecknoglobals // cobra uses globals in main var rootCmd = &cobra.Command{ Use: "rsca", Run: mainCommand, } -//nolint:gochecknoinits // init is used in main for cobra func init() { cobra.OnInitialize(mainconfig.ConfigInit) @@ -165,7 +163,7 @@ func checkErrFatal(err error, logger *zap.Logger, msg string) { func grpcServer(server string) string { host, port, err := net.SplitHostPort(server) if err != nil { - return fmt.Sprintf("%s:5888", server) + return server + ":5888" } if port == "" { diff --git a/cmd/rsca/version.go b/cmd/rsca/version.go index 65fcd33..32f2188 100644 --- a/cmd/rsca/version.go +++ b/cmd/rsca/version.go @@ -4,7 +4,6 @@ import ( "fmt" ) -//nolint:gochecknoglobals // these have to be variables for the linker to change the values var ( version = "dev" date = "notset" @@ -12,7 +11,6 @@ var ( builtBy = "" ) -//nolint:gochecknoinits // init is used in main for cobra func init() { rootCmd.Version = fmt.Sprintf("%s [%s] (%s) <%s>", version, commit, date, builtBy) } diff --git a/cmd/rscad/main.go b/cmd/rscad/main.go index cdc1f83..afd2702 100644 --- a/cmd/rscad/main.go +++ b/cmd/rscad/main.go @@ -23,13 +23,11 @@ import ( "google.golang.org/grpc" ) -//nolint:gochecknoglobals // cobra uses globals in main var rootCmd = &cobra.Command{ Use: "rscad", Run: mainCommand, } -//nolint:gochecknoinits // init is used in main for cobra func init() { cobra.OnInitialize(mainconfig.ConfigInit) diff --git a/cmd/rscad/version.go b/cmd/rscad/version.go index 65fcd33..32f2188 100644 --- a/cmd/rscad/version.go +++ b/cmd/rscad/version.go @@ -4,7 +4,6 @@ import ( "fmt" ) -//nolint:gochecknoglobals // these have to be variables for the linker to change the values var ( version = "dev" date = "notset" @@ -12,7 +11,6 @@ var ( builtBy = "" ) -//nolint:gochecknoinits // init is used in main for cobra func init() { rootCmd.Version = fmt.Sprintf("%s [%s] (%s) <%s>", version, commit, date, builtBy) } diff --git a/internal/register/msg.go b/internal/register/msg.go index 6af0b95..d9b82d1 100644 --- a/internal/register/msg.go +++ b/internal/register/msg.go @@ -2,7 +2,6 @@ package register import ( "context" - "fmt" "sync" "time" @@ -38,7 +37,7 @@ func New( mb := &api.Member{ Id: uuid.New().String(), Name: hostName, - Capability: []string{"client", fmt.Sprintf("rsca-%s", version)}, + Capability: []string{"client", "rsca-" + version}, Service: checkNames, Tag: cfg.GetStringSlice("general.tags"), Version: version,