mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-08-18 03:46:38 +00:00
golangci-lint-action@v3 pins `latest` to v1.64.8, which is built with go1.24 and refuses to run now that go.mod targets 1.25.0: can't load config: the Go language version (go1.24) used to build golangci-lint is lower than the targeted Go version (1.25.0) Move the job to golangci-lint-action@v7 + v2.8.0 and add a .golangci.yml mirroring the hub repo's v2 config: govet, staticcheck, ineffassign and unused, plus gofmt/goimports as formatters. Fixes for the issues that surfaced: - ST1005: lowercase error strings, drop trailing '!' in connect/hub.go - SA4011: kubernetes/watch.go had a `break` inside a `select` default that broke the select rather than the loop, i.e. a no-op; removed - QF1008: drop the embedded ChartPathOptions selector in helm.go - QF1003: tagged switch on r.URL.Path in mcp_test.go - QF1004: strings.Replace(..., -1) -> strings.ReplaceAll - gofmt -s and goimports with a local prefix across the tree errcheck is not in the enabled set, matching hub.
45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/creasty/defaults"
|
|
"github.com/rs/zerolog/log"
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/kubeshark/kubeshark/config"
|
|
"github.com/kubeshark/kubeshark/misc"
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "kubeshark",
|
|
Short: fmt.Sprintf("%s: %s", misc.Software, misc.Description),
|
|
Long: fmt.Sprintf(`%s: %s
|
|
An extensible Kubernetes-aware network sniffer and kernel tracer.
|
|
For more info: %s`, misc.Software, misc.Description, misc.Website),
|
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
|
if err := config.InitConfig(cmd); err != nil {
|
|
log.Fatal().Err(err).Send()
|
|
}
|
|
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
defaultConfig := config.CreateDefaultConfig()
|
|
if err := defaults.Set(&defaultConfig); err != nil {
|
|
log.Debug().Err(err).Send()
|
|
}
|
|
|
|
rootCmd.PersistentFlags().StringSlice(config.SetCommandName, []string{}, fmt.Sprintf("Override values using --%s", config.SetCommandName))
|
|
rootCmd.PersistentFlags().BoolP(config.DebugFlag, "d", false, "Enable debug mode")
|
|
rootCmd.PersistentFlags().String(config.ConfigPathFlag, "", fmt.Sprintf("Set the config path, default: %s", config.GetConfigFilePath(nil)))
|
|
}
|
|
|
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
|
// This is called by main.main(). It only needs to happen once to the tapCmd.
|
|
func Execute() {
|
|
cobra.CheckErr(rootCmd.Execute())
|
|
}
|