Skip to content

Commit

Permalink
fixed linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
na4ma4 committed Feb 13, 2024
1 parent a1f5aba commit fccfcf9
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 32 deletions.
27 changes: 27 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ linters-settings:
- prometheus.LinearBuckets
- cobra.MinimumNArgs

gomoddirectives:
replace-allow-list:
- k8s.io/kube-openapi

gomodguard:
blocked:
# List of blocked modules.
Expand Down Expand Up @@ -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"
2 changes: 0 additions & 2 deletions cmd/rsc/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 1 addition & 4 deletions cmd/rsc/host_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"errors"
"fmt"
"io"
"strings"
"text/template"
Expand All @@ -15,15 +14,13 @@ import (
"go.uber.org/zap"
)

//nolint:gochecknoglobals // cobra uses globals in main
var cmdHostInfo = &cobra.Command{
Use: "info <id|name> [id|name]",
Short: "Host Info",
Run: hostInfoCommand,
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}}"+
Expand Down Expand Up @@ -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"))
Expand Down
5 changes: 1 addition & 4 deletions cmd/rsc/host_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"errors"
"fmt"
"io"
"strings"
"text/template"
Expand All @@ -15,15 +14,13 @@ import (
"go.uber.org/zap"
)

//nolint:gochecknoglobals // cobra uses globals in main
var cmdHostList = &cobra.Command{
Use: "ls",
Short: "List Hosts",
Run: hostListCommand,
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}}"+
Expand Down Expand Up @@ -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"))
Expand Down
2 changes: 0 additions & 2 deletions cmd/rsc/host_rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ import (
"go.uber.org/zap"
)

//nolint:gochecknoglobals // cobra uses globals in main
var cmdHostRemove = &cobra.Command{
Use: "rm <hostname> [hostname0]...[hostnameN]",
Short: "Remove Host(s)",
Run: hostRemoveCommand,
Args: cobra.MinimumNArgs(1),
}

//nolint:gochecknoinits // init is used in main for cobra
func init() {
cmdHost.AddCommand(cmdHostRemove)
}
Expand Down
4 changes: 1 addition & 3 deletions cmd/rsc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 == "" {
Expand Down
2 changes: 0 additions & 2 deletions cmd/rsc/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 0 additions & 2 deletions cmd/rsc/trigger_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions cmd/rsc/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import (
"fmt"
)

//nolint:gochecknoglobals // these have to be variables for the linker to change the values
var (
version = "dev"
date = "notset"
commit = ""
builtBy = ""
)

//nolint:gochecknoinits // init is used in main for cobra
func init() {
rootCmd.Version = fmt.Sprintf("%s [%s] (%s) <%s>", version, commit, date, builtBy)
}
4 changes: 1 addition & 3 deletions cmd/rsca/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 == "" {
Expand Down
2 changes: 0 additions & 2 deletions cmd/rsca/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import (
"fmt"
)

//nolint:gochecknoglobals // these have to be variables for the linker to change the values
var (
version = "dev"
date = "notset"
commit = ""
builtBy = ""
)

//nolint:gochecknoinits // init is used in main for cobra
func init() {
rootCmd.Version = fmt.Sprintf("%s [%s] (%s) <%s>", version, commit, date, builtBy)
}
2 changes: 0 additions & 2 deletions cmd/rscad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 0 additions & 2 deletions cmd/rscad/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import (
"fmt"
)

//nolint:gochecknoglobals // these have to be variables for the linker to change the values
var (
version = "dev"
date = "notset"
commit = ""
builtBy = ""
)

//nolint:gochecknoinits // init is used in main for cobra
func init() {
rootCmd.Version = fmt.Sprintf("%s [%s] (%s) <%s>", version, commit, date, builtBy)
}
3 changes: 1 addition & 2 deletions internal/register/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package register

import (
"context"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit fccfcf9

Please sign in to comment.