Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/4179 : Update golang-lintci and fixes the issues raise by it #4208

Merged
merged 4 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion cmd/crc-embedder/cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var downloadCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
Use: "download [destination directory]",
Short: "Download data files to embed in the crc executable",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
return runDownload(args)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc-embedder/cmd/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var embedCmd = &cobra.Command{
Use: "embed [path to the (non-embedded) crc executable]",
Short: "Embed data files in crc executable",
Long: `Embed the OpenShift bundle and the binaries needed at runtime in the crc executable`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
runEmbed(args)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc-embedder/cmd/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var extractCmd = &cobra.Command{
Use: "extract [crc executable] [key identifying the embedded data] [destination filename]",
Short: "Extract data file embedded in the crc executable",
Long: `Extract a data file which is embedded in the crc executable`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
runExtract(args)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc-embedder/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var listCmd = &cobra.Command{
Use: "list [path to crc executable]",
Short: "List data files embedded in the crc executable",
Long: `List all the data files which were embedded in the crc executable`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
runList(args)
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/crc-embedder/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ var rootCmd = &cobra.Command{
Short: "Build helper for crc for binary embedding",
Long: `crc-embedder is a command line utility for listing or appending binary data
when building the crc executable for release`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
PersistentPreRun: func(_ *cobra.Command, _ []string) {
runPrerun()
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
PersistentPostRun: func(_ *cobra.Command, _ []string) {
runPostrun()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func GetBundleCmd(config *config.Config) *cobra.Command {
Use: "bundle SUBCOMMAND [flags]",
Short: "Manage CRC bundles",
Long: "Manage CRC bundles",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
_ = cmd.Help()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/bundle/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func getGenerateCmd(config *config.Config) *cobra.Command {
Use: "generate",
Short: "Generate a custom bundle from the running OpenShift cluster",
Long: "Generate a custom bundle from the running OpenShift cluster",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return runGenerate(config, forceStop)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var cleanupCmd = &cobra.Command{
Use: "cleanup",
Short: "Undo config changes",
Long: "Undo all the configuration changes done by 'crc setup' command",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return runCleanup()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func GetConfigCmd(config *config.Config) *cobra.Command {
Short: "Modify crc configuration",
Long: `Modifies crc configuration properties.
Properties: ` + "\n\n" + configurableFields(config),
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
_ = cmd.Help()
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/config/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func configViewCmd(config config.Storage) *cobra.Command {
Use: "view",
Short: "Display all assigned crc configuration properties",
Long: `Displays all assigned crc configuration properties and their values.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
tmpl, err := determineTemplate(configViewFormat)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var consoleCmd = &cobra.Command{
Aliases: []string{"dashboard"},
Short: "Open the OpenShift Web Console in the default browser",
Long: `Open the OpenShift Web Console in the default browser or print its URL or credentials`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return runConsole(os.Stdout, daemonclient.New(), consolePrintURL, consolePrintCredentials, outputFormat)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var daemonCmd = &cobra.Command{
Short: "Run the crc daemon",
Long: "Run the crc daemon",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if running, _ := checkIfDaemonIsRunning(); running {
return errors.New("daemon is already running")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var deleteCmd = &cobra.Command{
Use: "delete",
Short: "Delete the instance",
Long: "Delete the instance",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return runDelete(os.Stdout, newMachine(), clearCache, constants.MachineCacheDir, outputFormat != jsonFormat, globalForce, outputFormat)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var ipCmd = &cobra.Command{
Use: "ip",
Short: "Get IP address of the running OpenShift cluster",
Long: "Get IP address of the running OpenShift cluster",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
return runIP(args)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/oc_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var ocEnvCmd = &cobra.Command{
Use: "oc-env",
Short: "Add the 'oc' executable to PATH",
Long: `Add the OpenShift client executable 'oc' to PATH`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
return runOcEnv(args)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/podman_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var podmanEnvCmd = &cobra.Command{
Use: "podman-env",
Short: "Setup podman environment",
Long: `Setup environment for 'podman' executable to access podman on CRC VM`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return runPodmanEnv()
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/crc/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ var rootCmd = &cobra.Command{
Use: commandName,
Short: descriptionShort,
Long: descriptionLong,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
return runPrerun(cmd)
},
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
runRoot()
_ = cmd.Help()
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var startCmd = &cobra.Command{
Use: "start",
Short: "Start the instance",
Long: "Start the instance",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
if err := viper.BindFlagSet(cmd.Flags()); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var statusCmd = &cobra.Command{
Use: "status",
Short: "Display status of the OpenShift cluster",
Long: "Show details about the OpenShift cluster",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return runStatus(os.Stdout, daemonclient.New(), constants.MachineCacheDir, outputFormat, watch)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var stopCmd = &cobra.Command{
Use: "stop",
Short: "Stop the instance",
Long: "Stop the instance",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return runStop(os.Stdout, newMachine(), outputFormat != jsonFormat, globalForce, outputFormat)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var versionCmd = &cobra.Command{
Use: "version",
Short: "Print version information",
Long: "Print version information",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return runPrintVersion(os.Stdout, defaultVersion(), outputFormat)
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/adminhelper/hosts_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func instance() helper {
func Client() *client.Client {
return client.New(&http.Client{
Transport: &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
return winio.DialPipeContext(ctx, `\\.\pipe\crc-admin-helper`)
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/crc/cluster/clusteroperator.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@ func kubernetesClientConfiguration(ip string, kubeconfigFilePath string) (*restc
return nil, err
}
// override dial to directly use the IP of the VM
config.Dial = func(ctx context.Context, network, address string) (net.Conn, error) {
config.Dial = func(ctx context.Context, _, _ string) (net.Conn, error) {
var d net.Dialer
return d.DialContext(ctx, "tcp", fmt.Sprintf("%s:6443", ip))
}
// discard any proxy configuration of the host
config.Proxy = func(request *http.Request) (*url.URL, error) {
config.Proxy = func(_ *http.Request) (*url.URL, error) {
return nil, nil
}
config.Timeout = 5 * time.Second
Expand Down
3 changes: 2 additions & 1 deletion pkg/crc/cluster/pullsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ func loadFromKeyring() (string, error) {
}
var b bytes.Buffer
// #nosec G110
if _, err := io.Copy(&b, decompressor); err != nil {
_, err = io.Copy(&b, decompressor)
if err != nil {
return "", err
}
if err := decompressor.Close(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/daemonclient/transport_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func transport() *http.Transport {
return &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
return net.Dial("unix", constants.DaemonHTTPSocketPath)
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/daemonclient/transport_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func transport() *http.Transport {
return &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
return winio.DialPipeContext(ctx, constants.DaemonHTTPNamedPipe)
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/input/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func PromptUserForYesOrNo(message string, force bool) bool {
}
var response string
fmt.Printf(message + "? [y/N]: ")
fmt.Scanf("%s", &response)
_, _ = fmt.Scanf("%s", &response)

return strings.ToLower(response) == "y"
}
2 changes: 1 addition & 1 deletion pkg/crc/machine/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func getTokenForUser(username, password, ip string, ca []byte, clusterConfig *ty
RootCAs: roots,
MinVersion: tls.VersionTLS12,
},
DialContext: func(ctx gocontext.Context, network, address string) (net.Conn, error) {
DialContext: func(_ gocontext.Context, network, address string) (net.Conn, error) {
logging.Debugf("Using address: %s", address)
hostname, port, err := net.SplitHostPort(address)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/preflight/preflight_ubuntu_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestCleanupAppArmor(t *testing.T) {
}

func writerVerifier(expected string) func(reason string, content string, filepath string, mode os.FileMode) error {
return func(reason, content, filepath string, mode os.FileMode) error {
return func(_, content, _ string, _ os.FileMode) error {
if content == expected {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/segment/segment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type segmentResponse struct {
func mockServer() (chan []byte, *httptest.Server) {
done := make(chan []byte, 1)

server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
bin, err := io.ReadAll(r.Body)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/os/windows/powershell/powershell_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func ExecuteAsAdmin(reason, cmd string) (string, string, error) {
filename := filepath.Join(tempDir, "runAsAdmin.ps1")

// #nosec G306
if err := os.WriteFile(filename, append([]byte{0xef, 0xbb, 0xbf}, []byte(scriptContent)...), 0666); err != nil {
if err := os.WriteFile(filename, append([]byte{0xef, 0xbb, 0xbf}, []byte(scriptContent)...), 0600); err != nil {
return "", "", err
}

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func InitializeScenario(s *godog.ScenarioContext) {
return ctx, nil
})

s.After(func(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) {
s.After(func(ctx context.Context, sc *godog.Scenario, _ error) (context.Context, error) {

for _, tag := range sc.Tags {

Expand Down Expand Up @@ -523,7 +523,7 @@ func InitializeScenario(s *godog.ScenarioContext) {
s.Step(`^ensuring microshift cluster is fully operational$`,
EnsureMicroshiftClusterIsOperational)

s.After(func(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) {
s.After(func(ctx context.Context, _ *godog.Scenario, err error) (context.Context, error) {

if usingPreexistingCluster() {
// collecting diagnostics data is quite slow, and they
Expand Down
Loading
Loading