Merge pull request #12866 from robertsirc/Correcting-Linting-Errors
Correcting linting errors
This commit is contained in:
commit
a753ee7f43
|
@ -103,7 +103,7 @@ func newCompletionCmd(out io.Writer) *cobra.Command {
|
|||
Long: bashCompDesc,
|
||||
Args: require.NoArgs,
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
return runCompletionBash(out, cmd)
|
||||
},
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func newCompletionCmd(out io.Writer) *cobra.Command {
|
|||
Long: zshCompDesc,
|
||||
Args: require.NoArgs,
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
return runCompletionZsh(out, cmd)
|
||||
},
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ func newCompletionCmd(out io.Writer) *cobra.Command {
|
|||
Long: fishCompDesc,
|
||||
Args: require.NoArgs,
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
return runCompletionFish(out, cmd)
|
||||
},
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ func newCompletionCmd(out io.Writer) *cobra.Command {
|
|||
Long: powershellCompDesc,
|
||||
Args: require.NoArgs,
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
return runCompletionPowershell(out, cmd)
|
||||
},
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ func newCreateCmd(out io.Writer) *cobra.Command {
|
|||
Short: "create a new chart with the given name",
|
||||
Long: createDesc,
|
||||
Args: require.ExactArgs(1),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 0 {
|
||||
// Allow file completion when completing the argument for the name
|
||||
// which could be a path
|
||||
|
@ -73,7 +73,7 @@ func newCreateCmd(out io.Writer) *cobra.Command {
|
|||
// 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.name = args[0]
|
||||
o.starterDir = helmpath.DataPath("starters")
|
||||
return o.run(out)
|
||||
|
|
|
@ -106,7 +106,7 @@ func newDependencyListCmd(out io.Writer) *cobra.Command {
|
|||
Short: "list the dependencies for the given chart",
|
||||
Long: dependencyListDesc,
|
||||
Args: require.MaximumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
chartpath := "."
|
||||
if len(args) > 0 {
|
||||
chartpath = filepath.Clean(args[0])
|
||||
|
|
|
@ -49,7 +49,7 @@ func newDependencyBuildCmd(cfg *action.Configuration, out io.Writer) *cobra.Comm
|
|||
Short: "rebuild the charts/ directory based on the Chart.lock file",
|
||||
Long: dependencyBuildDesc,
|
||||
Args: require.MaximumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
chartpath := "."
|
||||
if len(args) > 0 {
|
||||
chartpath = filepath.Clean(args[0])
|
||||
|
|
|
@ -52,7 +52,7 @@ func newDependencyUpdateCmd(cfg *action.Configuration, out io.Writer) *cobra.Com
|
|||
Short: "update charts/ based on the contents of Chart.yaml",
|
||||
Long: dependencyUpDesc,
|
||||
Args: require.MaximumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
chartpath := "."
|
||||
if len(args) > 0 {
|
||||
chartpath = filepath.Clean(args[0])
|
||||
|
|
|
@ -59,7 +59,7 @@ func newDocsCmd(out io.Writer) *cobra.Command {
|
|||
Hidden: true,
|
||||
Args: require.NoArgs,
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
o.topCmd = cmd.Root()
|
||||
return o.run(out)
|
||||
},
|
||||
|
@ -70,7 +70,7 @@ func newDocsCmd(out io.Writer) *cobra.Command {
|
|||
f.StringVar(&o.docTypeString, "type", "markdown", "the type of documentation to generate (markdown, man, bash)")
|
||||
f.BoolVar(&o.generateHeaders, "generate-headers", false, "generate standard headers for markdown files")
|
||||
|
||||
cmd.RegisterFlagCompletionFunc("type", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
cmd.RegisterFlagCompletionFunc("type", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
return []string{"bash", "man", "markdown"}, cobra.ShellCompDirectiveNoFileComp
|
||||
})
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ func newEnvCmd(out io.Writer) *cobra.Command {
|
|||
Short: "helm client environment information",
|
||||
Long: envHelp,
|
||||
Args: require.MaximumNArgs(1),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 0 {
|
||||
keys := getSortedEnvVarKeys()
|
||||
return keys, cobra.ShellCompDirectiveNoFileComp
|
||||
|
@ -44,7 +44,7 @@ func newEnvCmd(out io.Writer) *cobra.Command {
|
|||
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, args []string) {
|
||||
envVars := settings.EnvVars()
|
||||
|
||||
if len(args) == 0 {
|
||||
|
|
|
@ -72,7 +72,7 @@ func bindOutputFlag(cmd *cobra.Command, varRef *output.Format) {
|
|||
cmd.Flags().VarP(newOutputValue(output.Table, varRef), outputFlag, "o",
|
||||
fmt.Sprintf("prints the output in the specified format. Allowed values: %s", strings.Join(output.Formats(), ", ")))
|
||||
|
||||
err := cmd.RegisterFlagCompletionFunc(outputFlag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc(outputFlag, func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
var formatNames []string
|
||||
for format, desc := range output.FormatsWithDesc() {
|
||||
formatNames = append(formatNames, fmt.Sprintf("%s\t%s", format, desc))
|
||||
|
|
|
@ -41,13 +41,13 @@ func newGetAllCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "download all information for a named release",
|
||||
Long: getAllHelp,
|
||||
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) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
res, err := client.Run(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -65,7 +65,7 @@ func newGetAllCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
|
||||
f := cmd.Flags()
|
||||
f.IntVar(&client.Version, "revision", 0, "get the named release with revision")
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 1 {
|
||||
return compListRevisions(toComplete, cfg, args[0])
|
||||
}
|
||||
|
|
|
@ -41,13 +41,13 @@ func newGetHooksCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "download all hooks for a named release",
|
||||
Long: getHooksHelp,
|
||||
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) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
res, err := client.Run(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -60,7 +60,7 @@ func newGetHooksCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
}
|
||||
|
||||
cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision")
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 1 {
|
||||
return compListRevisions(toComplete, cfg, args[0])
|
||||
}
|
||||
|
|
|
@ -43,13 +43,13 @@ func newGetManifestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
|
|||
Short: "download the manifest for a named release",
|
||||
Long: getManifestHelp,
|
||||
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) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
res, err := client.Run(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -60,7 +60,7 @@ func newGetManifestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
|
|||
}
|
||||
|
||||
cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision")
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 1 {
|
||||
return compListRevisions(toComplete, cfg, args[0])
|
||||
}
|
||||
|
|
|
@ -40,13 +40,13 @@ func newGetMetadataCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
|
|||
Use: "metadata RELEASE_NAME",
|
||||
Short: "This command fetches metadata for a given release",
|
||||
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) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
releaseMetadata, err := client.Run(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -57,7 +57,7 @@ func newGetMetadataCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
|
|||
|
||||
f := cmd.Flags()
|
||||
f.IntVar(&client.Version, "revision", 0, "specify release revision")
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 1 {
|
||||
return compListRevisions(toComplete, cfg, args[0])
|
||||
}
|
||||
|
|
|
@ -39,13 +39,13 @@ func newGetNotesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "download the notes for a named release",
|
||||
Long: getNotesHelp,
|
||||
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) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
res, err := client.Run(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -59,7 +59,7 @@ func newGetNotesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
|
||||
f := cmd.Flags()
|
||||
f.IntVar(&client.Version, "revision", 0, "get the named release with revision")
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 1 {
|
||||
return compListRevisions(toComplete, cfg, args[0])
|
||||
}
|
||||
|
|
|
@ -46,13 +46,13 @@ func newGetValuesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "download the values file for a named release",
|
||||
Long: getValuesHelp,
|
||||
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) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
vals, err := client.Run(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -63,7 +63,7 @@ func newGetValuesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
|
||||
f := cmd.Flags()
|
||||
f.IntVar(&client.Version, "revision", 0, "get the named release with revision")
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 1 {
|
||||
return compListRevisions(toComplete, cfg, args[0])
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string)
|
|||
Releases: store,
|
||||
KubeClient: &kubefake.PrintingKubeClient{Out: io.Discard},
|
||||
Capabilities: chartutil.DefaultCapabilities,
|
||||
Log: func(format string, v ...interface{}) {},
|
||||
Log: func(_ string, _ ...interface{}) {},
|
||||
}
|
||||
|
||||
root, err := newRootCmd(actionConfig, buf, args)
|
||||
|
|
|
@ -60,13 +60,13 @@ func newHistoryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "fetch release history",
|
||||
Aliases: []string{"hist"},
|
||||
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) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
history, err := getHistory(client, args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -136,7 +136,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "install a chart",
|
||||
Long: installDesc,
|
||||
Args: require.MinimumNArgs(1),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
return compInstall(args, toComplete, client)
|
||||
},
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
|
@ -202,7 +202,7 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal
|
|||
addValueOptionsFlags(f, valueOpts)
|
||||
addChartPathOptionsFlags(f, &client.ChartPathOptions)
|
||||
|
||||
err := cmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc("version", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
requiredArgs := 2
|
||||
if client.GenerateName {
|
||||
requiredArgs = 1
|
||||
|
|
|
@ -33,7 +33,7 @@ func TestInstall(t *testing.T) {
|
|||
}
|
||||
defer srv.Stop()
|
||||
|
||||
srv.WithMiddleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
srv.WithMiddleware(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
|
||||
username, password, ok := r.BasicAuth()
|
||||
if !ok || username != "username" || password != "password" {
|
||||
t.Errorf("Expected request to use basic auth and for username == 'username' and password == 'password', got '%v', '%s', '%s'", ok, username, password)
|
||||
|
|
|
@ -51,7 +51,7 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|||
Use: "lint PATH",
|
||||
Short: "examine a chart for possible issues",
|
||||
Long: longLintHelp,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
paths := []string{"."}
|
||||
if len(args) > 0 {
|
||||
paths = args
|
||||
|
@ -67,7 +67,7 @@ func newLintCmd(out io.Writer) *cobra.Command {
|
|||
|
||||
if client.WithSubcharts {
|
||||
for _, p := range paths {
|
||||
filepath.Walk(filepath.Join(p, "charts"), func(path string, info os.FileInfo, err error) error {
|
||||
filepath.Walk(filepath.Join(p, "charts"), func(path string, info os.FileInfo, _ error) error {
|
||||
if info != nil {
|
||||
if info.Name() == "Chart.yaml" {
|
||||
paths = append(paths, filepath.Dir(path))
|
||||
|
|
|
@ -69,7 +69,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Aliases: []string{"ls"},
|
||||
Args: require.NoArgs,
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
if client.AllNamespaces {
|
||||
if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug); err != nil {
|
||||
return err
|
||||
|
|
|
@ -301,7 +301,7 @@ func addPluginCommands(plugin *plugin.Plugin, baseCmd *cobra.Command, cmds *plug
|
|||
// to the dynamic completion script of the plugin.
|
||||
DisableFlagParsing: true,
|
||||
// A Run is required for it to be a valid command without subcommands
|
||||
Run: func(cmd *cobra.Command, args []string) {},
|
||||
Run: func(_ *cobra.Command, _ []string) {},
|
||||
}
|
||||
baseCmd.AddCommand(subCmd)
|
||||
addPluginCommands(plugin, subCmd, &cmd)
|
||||
|
|
|
@ -55,7 +55,7 @@ func newPackageCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Use: "package [CHART_PATH] [...]",
|
||||
Short: "package a chart directory into a chart archive",
|
||||
Long: packageDesc,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return errors.Errorf("need at least one argument, the path to the chart")
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ func newPluginInstallCmd(out io.Writer) *cobra.Command {
|
|||
Long: pluginInstallDesc,
|
||||
Aliases: []string{"add"},
|
||||
Args: require.ExactArgs(1),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 0 {
|
||||
// We do file completion, in case the plugin is local
|
||||
return nil, cobra.ShellCompDirectiveDefault
|
||||
|
@ -52,10 +52,10 @@ func newPluginInstallCmd(out io.Writer) *cobra.Command {
|
|||
// No more completion once the plugin path has been specified
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
},
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
PreRunE: func(_ *cobra.Command, args []string) error {
|
||||
return o.complete(args)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
return o.run(out)
|
||||
},
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ func newPluginListCmd(out io.Writer) *cobra.Command {
|
|||
Aliases: []string{"ls"},
|
||||
Short: "list installed Helm plugins",
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
debug("pluginDirs: %s", settings.PluginsDirectory)
|
||||
plugins, err := plugin.FindPlugins(settings.PluginsDirectory)
|
||||
if err != nil {
|
||||
|
|
|
@ -38,13 +38,13 @@ func newPluginUninstallCmd(out io.Writer) *cobra.Command {
|
|||
Use: "uninstall <plugin>...",
|
||||
Aliases: []string{"rm", "remove"},
|
||||
Short: "uninstall one or more Helm plugins",
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
return compListPlugins(toComplete, args), cobra.ShellCompDirectiveNoFileComp
|
||||
},
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
PreRunE: func(_ *cobra.Command, args []string) error {
|
||||
return o.complete(args)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
return o.run(out)
|
||||
},
|
||||
}
|
||||
|
|
|
@ -39,13 +39,13 @@ func newPluginUpdateCmd(out io.Writer) *cobra.Command {
|
|||
Use: "update <plugin>...",
|
||||
Aliases: []string{"up"},
|
||||
Short: "update one or more Helm plugins",
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
return compListPlugins(toComplete, args), cobra.ShellCompDirectiveNoFileComp
|
||||
},
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
PreRunE: func(_ *cobra.Command, args []string) error {
|
||||
return o.complete(args)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
return o.run(out)
|
||||
},
|
||||
}
|
||||
|
|
|
@ -51,13 +51,13 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Aliases: []string{"fetch"},
|
||||
Long: pullDesc,
|
||||
Args: require.MinimumNArgs(1),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
return compListCharts(toComplete, false)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
client.Settings = settings
|
||||
if client.Version == "" && client.Devel {
|
||||
debug("setting version to >0.0.0-0")
|
||||
|
@ -90,7 +90,7 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
f.StringVarP(&client.DestDir, "destination", "d", ".", "location to write the chart. If this and untardir are specified, untardir is appended to this")
|
||||
addChartPathOptionsFlags(f, &client.ChartPathOptions)
|
||||
|
||||
err := cmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc("version", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) != 1 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ func TestPullWithCredentialsCmd(t *testing.T) {
|
|||
}
|
||||
defer srv.Stop()
|
||||
|
||||
srv.WithMiddleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
srv.WithMiddleware(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
|
||||
username, password, ok := r.BasicAuth()
|
||||
if !ok || username != "username" || password != "password" {
|
||||
t.Errorf("Expected request to use basic auth and for username == 'username' and password == 'password', got '%v', '%s', '%s'", ok, username, password)
|
||||
|
|
|
@ -50,7 +50,7 @@ func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "push a chart to remote",
|
||||
Long: pushDesc,
|
||||
Args: require.MinimumNArgs(2),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 0 {
|
||||
// Do file completion for the chart file to push
|
||||
return nil, cobra.ShellCompDirectiveDefault
|
||||
|
@ -67,7 +67,7 @@ func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
}
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
registryClient, err := newRegistryClient(o.certFile, o.keyFile, o.caFile, o.insecureSkipTLSverify, o.plainHTTP)
|
||||
if err != nil {
|
||||
return fmt.Errorf("missing registry client: %w", err)
|
||||
|
|
|
@ -54,7 +54,7 @@ func newRegistryLoginCmd(cfg *action.Configuration, out io.Writer) *cobra.Comman
|
|||
Long: registryLoginDesc,
|
||||
Args: require.MinimumNArgs(1),
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
hostname := args[0]
|
||||
|
||||
username, password, err := getUsernamePassword(o.username, o.password, o.passwordFromStdinOpt)
|
||||
|
|
|
@ -36,7 +36,7 @@ func newRegistryLogoutCmd(cfg *action.Configuration, out io.Writer) *cobra.Comma
|
|||
Long: registryLogoutDesc,
|
||||
Args: require.MinimumNArgs(1),
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
hostname := args[0]
|
||||
return action.NewRegistryLogout(cfg).Run(out, hostname)
|
||||
},
|
||||
|
|
|
@ -48,13 +48,13 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
|
|||
Short: "run tests for a release",
|
||||
Long: releaseTestHelp,
|
||||
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) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
client.Namespace = settings.Namespace()
|
||||
notName := regexp.MustCompile(`^!\s?name=`)
|
||||
for _, f := range filter {
|
||||
|
|
|
@ -72,7 +72,7 @@ func newRepoAddCmd(out io.Writer) *cobra.Command {
|
|||
Short: "add a chart repository",
|
||||
Args: require.ExactArgs(2),
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
o.name = args[0]
|
||||
o.url = args[1]
|
||||
o.repoFile = settings.RepositoryConfig
|
||||
|
|
|
@ -54,7 +54,7 @@ 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, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 0 {
|
||||
// Allow file completion when completing the argument for the directory
|
||||
return nil, cobra.ShellCompDirectiveDefault
|
||||
|
@ -62,7 +62,7 @@ func newRepoIndexCmd(out io.Writer) *cobra.Command {
|
|||
// 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)
|
||||
},
|
||||
|
|
|
@ -37,7 +37,7 @@ func newRepoListCmd(out io.Writer) *cobra.Command {
|
|||
Short: "list chart repositories",
|
||||
Args: require.NoArgs,
|
||||
ValidArgsFunction: noCompletions,
|
||||
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")
|
||||
|
|
|
@ -44,10 +44,10 @@ func newRepoRemoveCmd(out io.Writer) *cobra.Command {
|
|||
Aliases: []string{"rm"},
|
||||
Short: "remove one or more chart repositories",
|
||||
Args: require.MinimumNArgs(1),
|
||||
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
|
||||
|
|
|
@ -57,10 +57,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
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestUpdateCmd(t *testing.T) {
|
|||
var out bytes.Buffer
|
||||
// Instead of using the HTTP updater, we provide our own for this test.
|
||||
// The TestUpdateCharts test verifies the HTTP behavior independently.
|
||||
updater := func(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdateFail bool) error {
|
||||
updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error {
|
||||
for _, re := range repos {
|
||||
fmt.Fprintln(out, re.Config.Name)
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ func TestUpdateCmdMultiple(t *testing.T) {
|
|||
var out bytes.Buffer
|
||||
// Instead of using the HTTP updater, we provide our own for this test.
|
||||
// The TestUpdateCharts test verifies the HTTP behavior independently.
|
||||
updater := func(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdateFail bool) error {
|
||||
updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error {
|
||||
for _, re := range repos {
|
||||
fmt.Fprintln(out, re.Config.Name)
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ func TestUpdateCmdInvalid(t *testing.T) {
|
|||
var out bytes.Buffer
|
||||
// Instead of using the HTTP updater, we provide our own for this test.
|
||||
// The TestUpdateCharts test verifies the HTTP behavior independently.
|
||||
updater := func(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdateFail bool) error {
|
||||
updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error {
|
||||
for _, re := range repos {
|
||||
fmt.Fprintln(out, re.Config.Name)
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func newRollbackCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "roll back a release to a previous revision",
|
||||
Long: rollbackDesc,
|
||||
Args: require.MinimumNArgs(1),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 0 {
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ func newRollbackCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if len(args) > 1 {
|
||||
ver, err := strconv.Atoi(args[1])
|
||||
if err != nil {
|
||||
|
|
|
@ -100,7 +100,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string
|
|||
addKlogFlags(flags)
|
||||
|
||||
// Setup shell completion for the namespace flag
|
||||
err := cmd.RegisterFlagCompletionFunc("namespace", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc("namespace", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
if client, err := actionConfig.KubernetesClientSet(); err == nil {
|
||||
// Choose a long enough timeout that the user notices something is not working
|
||||
// but short enough that the user is not made to wait very long
|
||||
|
@ -123,7 +123,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string
|
|||
}
|
||||
|
||||
// Setup shell completion for the kube-context flag
|
||||
err = cmd.RegisterFlagCompletionFunc("kube-context", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err = cmd.RegisterFlagCompletionFunc("kube-context", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
cobra.CompDebugln("About to get the different kube-contexts", settings.Debug)
|
||||
|
||||
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
|
||||
|
|
|
@ -64,7 +64,7 @@ func newSearchHubCmd(out io.Writer) *cobra.Command {
|
|||
Use: "hub [KEYWORD]",
|
||||
Short: "search for charts in the Artifact Hub or your own hub instance",
|
||||
Long: searchHubDesc,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
return o.run(out, args)
|
||||
},
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestSearchHubCmd(t *testing.T) {
|
|||
|
||||
// Setup a mock search service
|
||||
var searchResult = `{"data":[{"id":"stable/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"stable","url":"https://charts.helm.sh/stable"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/stable/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T17:57:31.38Z","digest":"119c499251bffd4b06ff0cd5ac98c2ce32231f84899fb4825be6c2d90971c742","urls":["https://charts.helm.sh/stable/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/stable/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/stable/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/stable/phpmyadmin/versions/3.0.0"}}}},{"id":"bitnami/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"bitnami","url":"https://charts.bitnami.com"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/bitnami/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T18:34:13.341Z","digest":"66d77cf6d8c2b52c488d0a294cd4996bd5bad8dc41d3829c394498fb401c008a","urls":["https://charts.bitnami.com/bitnami/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/bitnami/phpmyadmin/versions/3.0.0"}}}}]}`
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
fmt.Fprintln(w, searchResult)
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
@ -57,7 +57,7 @@ func TestSearchHubListRepoCmd(t *testing.T) {
|
|||
|
||||
// Setup a mock search service
|
||||
var searchResult = `{"data":[{"id":"stable/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"stable","url":"https://charts.helm.sh/stable"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/stable/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T17:57:31.38Z","digest":"119c499251bffd4b06ff0cd5ac98c2ce32231f84899fb4825be6c2d90971c742","urls":["https://charts.helm.sh/stable/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/stable/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/stable/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/stable/phpmyadmin/versions/3.0.0"}}}},{"id":"bitnami/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"bitnami","url":"https://charts.bitnami.com"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/bitnami/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T18:34:13.341Z","digest":"66d77cf6d8c2b52c488d0a294cd4996bd5bad8dc41d3829c394498fb401c008a","urls":["https://charts.bitnami.com/bitnami/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/bitnami/phpmyadmin/versions/3.0.0"}}}}]}`
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
fmt.Fprintln(w, searchResult)
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
@ -155,7 +155,7 @@ func TestSearchHubCmd_FailOnNoResponseTests(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// Setup a mock search service
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
fmt.Fprintln(w, tt.response)
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
|
|
@ -81,7 +81,7 @@ func newSearchRepoCmd(out io.Writer) *cobra.Command {
|
|||
Use: "repo [keyword]",
|
||||
Short: "search repositories for a keyword in charts",
|
||||
Long: searchRepoDesc,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
o.repoFile = settings.RepositoryConfig
|
||||
o.repoCacheDir = settings.RepositoryCache
|
||||
return o.run(out, args)
|
||||
|
|
|
@ -69,7 +69,7 @@ func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
}
|
||||
|
||||
// Function providing dynamic auto-completion
|
||||
validArgsFunc := func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
validArgsFunc := func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Long: showAllDesc,
|
||||
Args: require.ExactArgs(1),
|
||||
ValidArgsFunction: validArgsFunc,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
client.OutputFormat = action.ShowAll
|
||||
err := addRegistryClient(client)
|
||||
if err != nil {
|
||||
|
@ -103,7 +103,7 @@ func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Long: showValuesDesc,
|
||||
Args: require.ExactArgs(1),
|
||||
ValidArgsFunction: validArgsFunc,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
client.OutputFormat = action.ShowValues
|
||||
err := addRegistryClient(client)
|
||||
if err != nil {
|
||||
|
@ -124,7 +124,7 @@ func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Long: showChartDesc,
|
||||
Args: require.ExactArgs(1),
|
||||
ValidArgsFunction: validArgsFunc,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
client.OutputFormat = action.ShowChart
|
||||
err := addRegistryClient(client)
|
||||
if err != nil {
|
||||
|
@ -145,7 +145,7 @@ func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Long: readmeChartDesc,
|
||||
Args: require.ExactArgs(1),
|
||||
ValidArgsFunction: validArgsFunc,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
client.OutputFormat = action.ShowReadme
|
||||
err := addRegistryClient(client)
|
||||
if err != nil {
|
||||
|
@ -166,7 +166,7 @@ func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Long: showCRDsDesc,
|
||||
Args: require.ExactArgs(1),
|
||||
ValidArgsFunction: validArgsFunc,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
client.OutputFormat = action.ShowCRDs
|
||||
err := addRegistryClient(client)
|
||||
if err != nil {
|
||||
|
@ -199,7 +199,7 @@ func addShowFlags(subCmd *cobra.Command, client *action.Show) {
|
|||
}
|
||||
addChartPathOptionsFlags(f, &client.ChartPathOptions)
|
||||
|
||||
err := subCmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := subCmd.RegisterFlagCompletionFunc("version", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) != 1 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
|
|
@ -58,13 +58,13 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "display the status of the named release",
|
||||
Long: statusHelp,
|
||||
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) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
|
||||
// When the output format is a table the resources should be fetched
|
||||
// and displayed as a table. When YAML or JSON the resources will be
|
||||
|
@ -88,7 +88,7 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
|
||||
f.IntVar(&client.Version, "revision", 0, "if set, display the status of the named release with revision")
|
||||
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc("revision", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 1 {
|
||||
return compListRevisions(toComplete, cfg, args[0])
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "locally render templates",
|
||||
Long: templateDesc,
|
||||
Args: require.MinimumNArgs(1),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
return compInstall(args, toComplete, client)
|
||||
},
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
|
|
|
@ -47,10 +47,10 @@ func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "uninstall a release",
|
||||
Long: uninstallDesc,
|
||||
Args: require.MinimumNArgs(1),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
validationErr := validateCascadeFlag(client)
|
||||
if validationErr != nil {
|
||||
return validationErr
|
||||
|
|
|
@ -89,7 +89,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
Short: "upgrade a release",
|
||||
Long: upgradeDesc,
|
||||
Args: require.ExactArgs(2),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 0 {
|
||||
return compListReleases(toComplete, args, cfg)
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
}
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
client.Namespace = settings.Namespace()
|
||||
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CaFile,
|
||||
|
@ -274,7 +274,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
bindOutputFlag(cmd, &outfmt)
|
||||
bindPostRenderFlag(cmd, &client.PostRenderer)
|
||||
|
||||
err := cmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
err := cmd.RegisterFlagCompletionFunc("version", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) != 2 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ func newVerifyCmd(out io.Writer) *cobra.Command {
|
|||
Short: "verify that a chart at the given path has been signed and is valid",
|
||||
Long: verifyDesc,
|
||||
Args: require.ExactArgs(1),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
ValidArgsFunction: func(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 0 {
|
||||
// Allow file completion when completing the argument for the path
|
||||
return nil, cobra.ShellCompDirectiveDefault
|
||||
|
@ -52,7 +52,7 @@ func newVerifyCmd(out io.Writer) *cobra.Command {
|
|||
// 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 {
|
||||
err := client.Run(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -66,7 +66,7 @@ func newVersionCmd(out io.Writer) *cobra.Command {
|
|||
Long: versionDesc,
|
||||
Args: require.NoArgs,
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
return o.run(out)
|
||||
},
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ var searchResult = `{"data":[{"id":"stable/phpmyadmin","type":"chart","attribute
|
|||
|
||||
func TestSearch(t *testing.T) {
|
||||
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
fmt.Fprintln(w, searchResult)
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
|
|
@ -119,7 +119,7 @@ func mark(info os.FileInfo, err error, errors *[]error, clear bool) error {
|
|||
return err
|
||||
}
|
||||
name := info.Name()
|
||||
walkTree(tree, tree.name, func(path string, n *Node) {
|
||||
walkTree(tree, tree.name, func(_ string, n *Node) {
|
||||
if n.name == name {
|
||||
n.marks++
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func TestWalk(t *testing.T) {
|
|||
makeTree(t)
|
||||
errors := make([]error, 0, 10)
|
||||
clear := true
|
||||
markFn := func(path string, info os.FileInfo, err error) error {
|
||||
markFn := func(_ string, info os.FileInfo, err error) error {
|
||||
return mark(info, err, &errors, clear)
|
||||
}
|
||||
// Expect no errors.
|
||||
|
|
|
@ -161,7 +161,7 @@ func passphraseFileFetcher(passphraseFile string, stdin *os.File) (provenance.Pa
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return func(name string) ([]byte, error) {
|
||||
return func(_ string) ([]byte, error) {
|
||||
return passphrase, nil
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ func TestLoadArchiveFiles(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "empty input should return no files",
|
||||
generate: func(w *tar.Writer) {},
|
||||
check: func(t *testing.T, files []*BufferedFile, err error) {
|
||||
generate: func(_ *tar.Writer) {},
|
||||
check: func(t *testing.T, _ []*BufferedFile, err error) {
|
||||
if err.Error() != "no files in chart archive" {
|
||||
t.Fatalf(`expected "no files in chart archive", got [%#v]`, err)
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ func (e Engine) initFunMap(t *template.Template) {
|
|||
// When DNS lookups are not enabled override the sprig function and return
|
||||
// an empty string.
|
||||
if !e.EnableDNS {
|
||||
funcMap["getHostByName"] = func(name string) string {
|
||||
funcMap["getHostByName"] = func(_ string) string {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ func TestDownloadTLS(t *testing.T) {
|
|||
ca, pub, priv := filepath.Join(cd, "rootca.crt"), filepath.Join(cd, "crt.pem"), filepath.Join(cd, "key.pem")
|
||||
insecureSkipTLSverify := false
|
||||
|
||||
tlsSrv := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||
tlsSrv := httptest.NewUnstartedServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}))
|
||||
tlsConf, err := tlsutil.NewClientTLS(pub, priv, ca, insecureSkipTLSverify)
|
||||
if err != nil {
|
||||
t.Fatal(errors.Wrap(err, "can't create TLS config for client"))
|
||||
|
@ -332,7 +332,7 @@ func TestDownloadTLS(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDownloadInsecureSkipTLSVerify(t *testing.T) {
|
||||
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||
ts := httptest.NewTLSServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}))
|
||||
defer ts.Close()
|
||||
|
||||
u, _ := url.ParseRequestURI(ts.URL)
|
||||
|
@ -364,7 +364,7 @@ func TestDownloadInsecureSkipTLSVerify(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHTTPGetterTarDownload(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
f, _ := os.Open("testdata/empty-0.0.1.tgz")
|
||||
defer f.Close()
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ func (r *Rules) parseRule(rule string) error {
|
|||
|
||||
if strings.HasPrefix(rule, "/") {
|
||||
// Require path matches the root path.
|
||||
p.match = func(n string, fi os.FileInfo) bool {
|
||||
p.match = func(n string, _ os.FileInfo) bool {
|
||||
rule = strings.TrimPrefix(rule, "/")
|
||||
ok, err := filepath.Match(rule, n)
|
||||
if err != nil {
|
||||
|
@ -184,7 +184,7 @@ func (r *Rules) parseRule(rule string) error {
|
|||
}
|
||||
} else if strings.Contains(rule, "/") {
|
||||
// require structural match.
|
||||
p.match = func(n string, fi os.FileInfo) bool {
|
||||
p.match = func(n string, _ os.FileInfo) bool {
|
||||
ok, err := filepath.Match(rule, n)
|
||||
if err != nil {
|
||||
log.Printf("Failed to compile %q: %s", rule, err)
|
||||
|
@ -193,7 +193,7 @@ func (r *Rules) parseRule(rule string) error {
|
|||
return ok
|
||||
}
|
||||
} else {
|
||||
p.match = func(n string, fi os.FileInfo) bool {
|
||||
p.match = func(n string, _ os.FileInfo) bool {
|
||||
// When there is no slash in the pattern, we evaluate ONLY the
|
||||
// filename.
|
||||
n = filepath.Base(n)
|
||||
|
|
|
@ -106,7 +106,7 @@ func (w *waiter) waitForDeletedResources(deleted ResourceList) error {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), w.timeout)
|
||||
defer cancel()
|
||||
|
||||
return wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(ctx context.Context) (bool, error) {
|
||||
return wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(_ context.Context) (bool, error) {
|
||||
for _, v := range deleted {
|
||||
err := v.Get()
|
||||
if err == nil || !apierrors.IsNotFound(err) {
|
||||
|
|
|
@ -275,10 +275,10 @@ func validateMetadataNameFunc(obj *K8sYamlStruct) validation.ValidateNameFunc {
|
|||
case "certificatesigningrequest":
|
||||
// No validation.
|
||||
// https://github.com/kubernetes/kubernetes/blob/v1.20.0/pkg/apis/certificates/validation/validation.go#L137-L140
|
||||
return func(name string, prefix bool) []string { return nil }
|
||||
return func(_ string, _ bool) []string { return nil }
|
||||
case "role", "clusterrole", "rolebinding", "clusterrolebinding":
|
||||
// https://github.com/kubernetes/kubernetes/blob/v1.20.0/pkg/apis/rbac/validation/validation.go#L32-L34
|
||||
return func(name string, prefix bool) []string {
|
||||
return func(name string, _ bool) []string {
|
||||
return apipath.IsValidPathSegmentName(name)
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -196,7 +196,7 @@ func TestDecryptKey(t *testing.T) {
|
|||
}
|
||||
|
||||
// We give this a simple callback that returns the password.
|
||||
if err := k.DecryptKey(func(s string) ([]byte, error) {
|
||||
if err := k.DecryptKey(func(_ string) ([]byte, error) {
|
||||
return []byte("secret"), nil
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -208,7 +208,7 @@ func TestDecryptKey(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
// Now we give it a bogus password.
|
||||
if err := k.DecryptKey(func(s string) ([]byte, error) {
|
||||
if err := k.DecryptKey(func(_ string) ([]byte, error) {
|
||||
return []byte("secrets_and_lies"), nil
|
||||
}); err == nil {
|
||||
t.Fatal("Expected an error when giving a bogus passphrase")
|
||||
|
|
|
@ -124,7 +124,7 @@ func NewClient(options ...ClientOption) (*Client, error) {
|
|||
"User-Agent": {version.GetUserAgent()},
|
||||
},
|
||||
Cache: cache,
|
||||
Credential: func(ctx context.Context, reg string) (registryauth.Credential, error) {
|
||||
Credential: func(_ context.Context, reg string) (registryauth.Credential, error) {
|
||||
dockerClient, ok := client.authorizer.(*dockerauth.Client)
|
||||
if !ok {
|
||||
return registryauth.EmptyCredential, errors.New("unable to obtain docker client")
|
||||
|
@ -198,7 +198,7 @@ func ClientOptPlainHTTP() ClientOption {
|
|||
// ClientOptResolver returns a function that sets the resolver setting on a client options set
|
||||
func ClientOptResolver(resolver remotes.Resolver) ClientOption {
|
||||
return func(client *Client) {
|
||||
client.resolver = func(ref registry.Reference) (remotes.Resolver, error) {
|
||||
client.resolver = func(_ registry.Reference) (remotes.Resolver, error) {
|
||||
return resolver, nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ func (r *ChartRepository) Load() error {
|
|||
// FIXME: Why are we recursively walking directories?
|
||||
// FIXME: Why are we not reading the repositories.yaml to figure out
|
||||
// what repos to use?
|
||||
filepath.Walk(r.Config.Name, func(path string, f os.FileInfo, err error) error {
|
||||
filepath.Walk(r.Config.Name, func(path string, f os.FileInfo, _ error) error {
|
||||
if !f.IsDir() {
|
||||
if strings.Contains(f.Name(), "-index.yaml") {
|
||||
i, err := LoadIndexFile(path)
|
||||
|
|
|
@ -132,7 +132,7 @@ func TestIndexCustomSchemeDownload(t *testing.T) {
|
|||
repoName := "gcs-repo"
|
||||
repoURL := "gs://some-gcs-bucket"
|
||||
myCustomGetter := &CustomGetter{}
|
||||
customGetterConstructor := func(options ...getter.Option) (getter.Getter, error) {
|
||||
customGetterConstructor := func(_ ...getter.Option) (getter.Getter, error) {
|
||||
return myCustomGetter, nil
|
||||
}
|
||||
providers := getter.Providers{{
|
||||
|
@ -267,7 +267,7 @@ func startLocalServerForTests(handler http.Handler) (*httptest.Server, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handler = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Write(fileBytes)
|
||||
})
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ func startLocalTLSServerForTests(handler http.Handler) (*httptest.Server, error)
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handler = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Write(fileBytes)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ func NewTempServerWithCleanupAndBasicAuth(t *testing.T, glob string) *Server {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
srv.WithMiddleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
srv.WithMiddleware(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
|
||||
username, password, ok := r.BasicAuth()
|
||||
if !ok || username != "username" || password != "password" {
|
||||
t.Errorf("Expected request to use basic auth and for username == 'username' and password == 'password', got '%v', '%s', '%s'", ok, username, password)
|
||||
|
|
|
@ -262,7 +262,7 @@ func newTestFixtureSQL(t *testing.T, _ ...*rspb.Release) (*SQL, sqlmock.Sqlmock)
|
|||
sqlxDB := sqlx.NewDb(sqlDB, "sqlmock")
|
||||
return &SQL{
|
||||
db: sqlxDB,
|
||||
Log: func(a string, b ...interface{}) {},
|
||||
Log: func(_ string, _ ...interface{}) {},
|
||||
namespace: "default",
|
||||
statementBuilder: sq.StatementBuilder.PlaceholderFormat(sq.Dollar),
|
||||
}, mock
|
||||
|
|
|
@ -98,9 +98,9 @@ func (s *SQL) Name() string {
|
|||
// Check if all migrations al
|
||||
func (s *SQL) checkAlreadyApplied(migrations []*migrate.Migration) bool {
|
||||
// make map (set) of ids for fast search
|
||||
migrationsIds := make(map[string]struct{})
|
||||
migrationsIDs := make(map[string]struct{})
|
||||
for _, migration := range migrations {
|
||||
migrationsIds[migration.Id] = struct{}{}
|
||||
migrationsIDs[migration.Id] = struct{}{}
|
||||
}
|
||||
|
||||
// get list of applied migrations
|
||||
|
@ -113,15 +113,15 @@ func (s *SQL) checkAlreadyApplied(migrations []*migrate.Migration) bool {
|
|||
}
|
||||
|
||||
for _, record := range records {
|
||||
if _, ok := migrationsIds[record.Id]; ok {
|
||||
if _, ok := migrationsIDs[record.Id]; ok {
|
||||
s.Log("checkAlreadyApplied: found previous migration (Id: %v) applied at %v", record.Id, record.AppliedAt)
|
||||
delete(migrationsIds, record.Id)
|
||||
delete(migrationsIDs, record.Id)
|
||||
}
|
||||
}
|
||||
|
||||
// check if all migrations appliyed
|
||||
if len(migrationsIds) != 0 {
|
||||
for id := range migrationsIds {
|
||||
if len(migrationsIDs) != 0 {
|
||||
for id := range migrationsIDs {
|
||||
s.Log("checkAlreadyApplied: find unapplied migration (id: %v)", id)
|
||||
}
|
||||
return false
|
||||
|
|
|
@ -546,31 +546,31 @@ func mockGetReleaseCustomLabels(mock sqlmock.Sqlmock, key string, namespace stri
|
|||
func TestSqlChechkAppliedMigrations(t *testing.T) {
|
||||
cases := []struct {
|
||||
migrationsToApply []*migrate.Migration
|
||||
appliedMigrationsIds []string
|
||||
appliedMigrationsIDs []string
|
||||
expectedResult bool
|
||||
errorExplanation string
|
||||
}{
|
||||
{
|
||||
migrationsToApply: []*migrate.Migration{{Id: "init1"}, {Id: "init2"}, {Id: "init3"}},
|
||||
appliedMigrationsIds: []string{"1", "2", "init1", "3", "init2", "4", "5"},
|
||||
appliedMigrationsIDs: []string{"1", "2", "init1", "3", "init2", "4", "5"},
|
||||
expectedResult: false,
|
||||
errorExplanation: "Has found one migration id \"init3\" as applied, that was not applied",
|
||||
},
|
||||
{
|
||||
migrationsToApply: []*migrate.Migration{{Id: "init1"}, {Id: "init2"}, {Id: "init3"}},
|
||||
appliedMigrationsIds: []string{"1", "2", "init1", "3", "init2", "4", "init3", "5"},
|
||||
appliedMigrationsIDs: []string{"1", "2", "init1", "3", "init2", "4", "init3", "5"},
|
||||
expectedResult: true,
|
||||
errorExplanation: "Has not found one or more migration ids, that was applied",
|
||||
},
|
||||
{
|
||||
migrationsToApply: []*migrate.Migration{{Id: "init"}},
|
||||
appliedMigrationsIds: []string{"1", "2", "3", "inits", "4", "tinit", "5"},
|
||||
appliedMigrationsIDs: []string{"1", "2", "3", "inits", "4", "tinit", "5"},
|
||||
expectedResult: false,
|
||||
errorExplanation: "Has found single \"init\", that was not applied",
|
||||
},
|
||||
{
|
||||
migrationsToApply: []*migrate.Migration{{Id: "init"}},
|
||||
appliedMigrationsIds: []string{"1", "2", "init", "3", "init2", "4", "init3", "5"},
|
||||
appliedMigrationsIDs: []string{"1", "2", "init", "3", "init2", "4", "init3", "5"},
|
||||
expectedResult: true,
|
||||
errorExplanation: "Has not found single migration id \"init\", that was applied",
|
||||
},
|
||||
|
@ -578,7 +578,7 @@ func TestSqlChechkAppliedMigrations(t *testing.T) {
|
|||
for i, c := range cases {
|
||||
sqlDriver, mock := newTestFixtureSQL(t)
|
||||
rows := sqlmock.NewRows([]string{"id", "applied_at"})
|
||||
for _, id := range c.appliedMigrationsIds {
|
||||
for _, id := range c.appliedMigrationsIDs {
|
||||
rows.AddRow(id, time.Time{})
|
||||
}
|
||||
mock.
|
||||
|
|
Loading…
Reference in New Issue