Skip to content

Commit

Permalink
fix remaining codeql issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Racer159 committed Feb 21, 2024
1 parent 7518206 commit 8ea6fe4
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/cmd/tools/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
var toolsCmd = &cobra.Command{
Use: "tools",
Aliases: []string{"t"},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
config.SkipLogFile = true

// Skip for vendor-only commands
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/tools/crane.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func init() {
Use: "registry",
Aliases: []string{"r", "crane"},
Short: lang.CmdToolsRegistryShort,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
PersistentPreRun: func(cmd *cobra.Command, _ []string) {

exec.ExitOnInterrupt()

Expand Down
4 changes: 2 additions & 2 deletions src/cmd/tools/helm/repo_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ func newRepoIndexCmd(out io.Writer) *cobra.Command {
Short: "generate an index file given a directory containing packaged charts",
Long: repoIndexDesc,
Args: require.ExactArgs(1),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {

Check warning on line 61 in src/cmd/tools/helm/repo_index.go

View workflow job for this annotation

GitHub Actions / validate

parameter 'toComplete' seems to be unused, consider removing or renaming it as _
if len(args) == 0 {
// Allow file completion when completing the argument for the directory
return nil, cobra.ShellCompDirectiveDefault
}
// No more completions, so disable file completion
return nil, cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
o.dir = args[0]
return o.run(out)
},
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/tools/helm/repo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func newRepoListCmd(out io.Writer) *cobra.Command {
Aliases: []string{"ls"},
Short: "list chart repositories",
Args: require.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
f, _ := repo.LoadFile(settings.RepositoryConfig)
if len(f.Repositories) == 0 && !(outfmt == output.JSON || outfmt == output.YAML) {
return errors.New("no repositories to show")
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/tools/helm/repo_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ func newRepoUpdateCmd(out io.Writer) *cobra.Command {
Short: "update information of available charts locally from chart repositories",
Long: updateDesc,
Args: require.MinimumNArgs(0),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return compListRepos(toComplete, args), cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
o.repoFile = settings.RepositoryConfig
o.repoCache = settings.RepositoryCache
o.names = args
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/tools/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func init() {
// Kubectl stub command.
kubectlCmd := &cobra.Command{
Short: lang.CmdToolsKubectlDocs,
Run: func(cmd *cobra.Command, args []string) {},
Run: func(_ *cobra.Command, _ []string) {},
}

// Only load this command if it is being called directly.
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/tools/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var waitForCmd = &cobra.Command{
Long: lang.CmdToolsWaitForLong,
Example: lang.CmdToolsWaitForExample,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
// Parse the timeout string
timeout, err := time.ParseDuration(waitTimeout)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions src/cmd/tools/zarf.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var deprecatedGetGitCredsCmd = &cobra.Command{
Hidden: true,
Short: lang.CmdToolsGetGitPasswdShort,
Long: lang.CmdToolsGetGitPasswdLong,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
message.Warn(lang.CmdToolsGetGitPasswdDeprecation)
getCredsCmd.Run(getCredsCmd, []string{"git"})
},
Expand All @@ -48,7 +48,7 @@ var getCredsCmd = &cobra.Command{
Example: lang.CmdToolsGetCredsExample,
Aliases: []string{"gc"},
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
state, err := cluster.NewClusterOrDie().LoadZarfState()
if err != nil || state.Distro == "" {
// If no distro the zarf secret did not load properly
Expand Down Expand Up @@ -168,7 +168,7 @@ var clearCacheCmd = &cobra.Command{
Use: "clear-cache",
Aliases: []string{"c"},
Short: lang.CmdToolsClearCacheShort,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
message.Notef(lang.CmdToolsClearCacheDir, config.GetAbsCachePath())
if err := os.RemoveAll(config.GetAbsCachePath()); err != nil {
message.Fatalf(err, lang.CmdToolsClearCacheErr, config.GetAbsCachePath())
Expand All @@ -180,7 +180,7 @@ var clearCacheCmd = &cobra.Command{
var downloadInitCmd = &cobra.Command{
Use: "download-init",
Short: lang.CmdToolsDownloadInitShort,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
url := oci.GetInitPackageURL(config.CLIVersion)

remote, err := oci.NewOrasRemote(url, oci.PlatformForArch(config.GetArch()))
Expand All @@ -202,7 +202,7 @@ var generatePKICmd = &cobra.Command{
Aliases: []string{"pki"},
Short: lang.CmdToolsGenPkiShort,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
pki := pki.GeneratePKI(args[0], subAltNames...)
if err := os.WriteFile("tls.ca", pki.CA, 0644); err != nil {
message.Fatalf(err, lang.ErrWritingFile, "tls.ca", err.Error())
Expand All @@ -221,7 +221,7 @@ var generateKeyCmd = &cobra.Command{
Use: "gen-key",
Aliases: []string{"key"},
Short: lang.CmdToolsGenKeyShort,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
// Utility function to prompt the user for the password to the private key
passwordFunc := func(bool) ([]byte, error) {
// perform the first prompt
Expand Down
2 changes: 1 addition & 1 deletion src/internal/agent/http/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func ProxyHandler() http.HandlerFunc {
return
}

proxy := &httputil.ReverseProxy{Director: func(r *http.Request) {}, ModifyResponse: proxyResponseTransform}
proxy := &httputil.ReverseProxy{Director: func(_ *http.Request) {}, ModifyResponse: proxyResponseTransform}
proxy.ServeHTTP(w, r)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/internal/agent/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewProxyServer(port string) *http.Server {
}

func healthz() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("ok"))
}
Expand Down

0 comments on commit 8ea6fe4

Please sign in to comment.