pull/12725/merge
Eddie Zaneski 2 years ago committed by GitHub
commit 0e32b3acf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -17,7 +17,6 @@ limitations under the License.
package main // import "helm.sh/helm/v3/cmd/helm"
import (
"fmt"
"io"
"log"
"os"
@ -31,6 +30,7 @@ import (
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli"
helmcmd "helm.sh/helm/v3/pkg/cmd"
"helm.sh/helm/v3/pkg/kube"
kubefake "helm.sh/helm/v3/pkg/kube/fake"
"helm.sh/helm/v3/pkg/release"
@ -43,18 +43,6 @@ func init() {
log.SetFlags(log.Lshortfile)
}
func debug(format string, v ...interface{}) {
if settings.Debug {
format = fmt.Sprintf("[debug] %s\n", format)
log.Output(2, fmt.Sprintf(format, v...))
}
}
func warning(format string, v ...interface{}) {
format = fmt.Sprintf("WARNING: %s\n", format)
fmt.Fprintf(os.Stderr, format, v...)
}
func main() {
// Setting the name of the app for managedFields in the Kubernetes client.
// It is set here to the full name of "helm" so that renaming of helm to
@ -63,16 +51,16 @@ func main() {
kube.ManagedFieldsManager = "helm"
actionConfig := new(action.Configuration)
cmd, err := newRootCmd(actionConfig, os.Stdout, os.Args[1:])
cmd, err := helmcmd.NewRootCmd(actionConfig, settings, os.Stdout, os.Args[1:])
if err != nil {
warning("%+v", err)
helmcmd.Warning("%+v", err)
os.Exit(1)
}
// run when each command's execute method is called
cobra.OnInitialize(func() {
helmDriver := os.Getenv("HELM_DRIVER")
if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, debug); err != nil {
if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, helmcmd.Debug); err != nil {
log.Fatal(err)
}
if helmDriver == "memory" {
@ -81,10 +69,10 @@ func main() {
})
if err := cmd.Execute(); err != nil {
debug("%+v", err)
helmcmd.Debug("%+v", err)
switch e := err.(type) {
case pluginError:
os.Exit(e.code)
case helmcmd.PluginError:
os.Exit(e.Code)
default:
os.Exit(1)
}

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -23,7 +23,7 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/cmd/require"
)
const completionDesc = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -23,9 +23,9 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/helmpath"
)

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"io"
@ -21,8 +21,8 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
)
const dependencyDesc = `

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -24,8 +24,8 @@ import (
"github.com/spf13/cobra"
"k8s.io/client-go/util/homedir"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/downloader"
"helm.sh/helm/v3/pkg/getter"
)

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"runtime"

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"io"
@ -21,8 +21,8 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/downloader"
"helm.sh/helm/v3/pkg/getter"
)

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -28,7 +28,7 @@ import (
"golang.org/x/text/cases"
"golang.org/x/text/language"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/cmd/require"
)
const docsDesc = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -23,7 +23,7 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/cmd/require"
)
var envHelp = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"flag"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"io"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
)
var getHelp = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"io"
@ -22,9 +22,9 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli/output"
"helm.sh/helm/v3/pkg/cmd/require"
)
var getAllHelp = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -23,8 +23,8 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
)
const getHooksHelp = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -23,8 +23,8 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
)
var getManifestHelp = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -23,9 +23,9 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli/output"
"helm.sh/helm/v3/pkg/cmd/require"
)
type metadataWriter struct {

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -23,8 +23,8 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
)
var getNotesHelp = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -23,9 +23,9 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli/output"
"helm.sh/helm/v3/pkg/cmd/require"
)
var getValuesHelp = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,14 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"bytes"
"io"
"os"
"os/exec"
"runtime"
// "os/exec"
// "runtime"
"strings"
"testing"
@ -97,7 +98,7 @@ func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string)
Log: func(format string, v ...interface{}) {},
}
root, err := newRootCmd(actionConfig, buf, args)
root, err := NewRootCmd(actionConfig, settings, buf, args)
if err != nil {
return nil, "", err
}
@ -165,58 +166,59 @@ func testChdir(t *testing.T, dir string) func() {
return func() { os.Chdir(old) }
}
func TestPluginExitCode(t *testing.T) {
if os.Getenv("RUN_MAIN_FOR_TESTING") == "1" {
os.Args = []string{"helm", "exitwith", "2"}
// We DO call helm's main() here. So this looks like a normal `helm` process.
main()
// As main calls os.Exit, we never reach this line.
// But the test called this block of code catches and verifies the exit code.
return
}
// Currently, plugins assume a Linux subsystem. Skip the execution
// tests until this is fixed
if runtime.GOOS != "windows" {
// Do a second run of this specific test(TestPluginExitCode) with RUN_MAIN_FOR_TESTING=1 set,
// So that the second run is able to run main() and this first run can verify the exit status returned by that.
//
// This technique originates from https://talks.golang.org/2014/testing.slide#23.
cmd := exec.Command(os.Args[0], "-test.run=TestPluginExitCode")
cmd.Env = append(
os.Environ(),
"RUN_MAIN_FOR_TESTING=1",
// See pkg/cli/environment.go for which envvars can be used for configuring these passes
// and also see plugin_test.go for how a plugin env can be set up.
// We just does the same setup as plugin_test.go via envvars
"HELM_PLUGINS=testdata/helmhome/helm/plugins",
"HELM_REPOSITORY_CONFIG=testdata/helmhome/helm/repositories.yaml",
"HELM_REPOSITORY_CACHE=testdata/helmhome/helm/repository",
)
stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{}
cmd.Stdout = stdout
cmd.Stderr = stderr
err := cmd.Run()
exiterr, ok := err.(*exec.ExitError)
if !ok {
t.Fatalf("Unexpected error returned by os.Exit: %T", err)
}
if stdout.String() != "" {
t.Errorf("Expected no write to stdout: Got %q", stdout.String())
}
expectedStderr := "Error: plugin \"exitwith\" exited with error\n"
if stderr.String() != expectedStderr {
t.Errorf("Expected %q written to stderr: Got %q", expectedStderr, stderr.String())
}
if exiterr.ExitCode() != 2 {
t.Errorf("Expected exit code 2: Got %d", exiterr.ExitCode())
}
}
}
// TODO(eddiezane): can't call main like this anymore
// func TestPluginExitCode(t *testing.T) {
// if os.Getenv("RUN_MAIN_FOR_TESTING") == "1" {
// os.Args = []string{"helm", "exitwith", "2"}
//
// // We DO call helm's main() here. So this looks like a normal `helm` process.
// main()
//
// // As main calls os.Exit, we never reach this line.
// // But the test called this block of code catches and verifies the exit code.
// return
// }
//
// // Currently, plugins assume a Linux subsystem. Skip the execution
// // tests until this is fixed
// if runtime.GOOS != "windows" {
// // Do a second run of this specific test(TestPluginExitCode) with RUN_MAIN_FOR_TESTING=1 set,
// // So that the second run is able to run main() and this first run can verify the exit status returned by that.
// //
// // This technique originates from https://talks.golang.org/2014/testing.slide#23.
// cmd := exec.Command(os.Args[0], "-test.run=TestPluginExitCode")
// cmd.Env = append(
// os.Environ(),
// "RUN_MAIN_FOR_TESTING=1",
// // See pkg/cli/environment.go for which envvars can be used for configuring these passes
// // and also see plugin_test.go for how a plugin env can be set up.
// // We just does the same setup as plugin_test.go via envvars
// "HELM_PLUGINS=testdata/helmhome/helm/plugins",
// "HELM_REPOSITORY_CONFIG=testdata/helmhome/helm/repositories.yaml",
// "HELM_REPOSITORY_CACHE=testdata/helmhome/helm/repository",
// )
// stdout := &bytes.Buffer{}
// stderr := &bytes.Buffer{}
// cmd.Stdout = stdout
// cmd.Stderr = stderr
// err := cmd.Run()
// exiterr, ok := err.(*exec.ExitError)
//
// if !ok {
// t.Fatalf("Unexpected error returned by os.Exit: %T", err)
// }
//
// if stdout.String() != "" {
// t.Errorf("Expected no write to stdout: Got %q", stdout.String())
// }
//
// expectedStderr := "Error: plugin \"exitwith\" exited with error\n"
// if stderr.String() != expectedStderr {
// t.Errorf("Expected %q written to stderr: Got %q", expectedStderr, stderr.String())
// }
//
// if exiterr.ExitCode() != 2 {
// t.Errorf("Expected exit code 2: Got %d", exiterr.ExitCode())
// }
// }
// }

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -25,10 +25,10 @@ import (
"github.com/gosuri/uitable"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/cli/output"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/release"
"helm.sh/helm/v3/pkg/releaseutil"
helmtime "helm.sh/helm/v3/pkg/time"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"context"
@ -30,12 +30,12 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/cli/output"
"helm.sh/helm/v3/pkg/cli/values"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/downloader"
"helm.sh/helm/v3/pkg/getter"
"helm.sh/helm/v3/pkg/release"
@ -211,9 +211,9 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal
}
func runInstall(args []string, client *action.Install, valueOpts *values.Options, out io.Writer) (*release.Release, error) {
debug("Original chart version: %q", client.Version)
Debug("Original chart version: %q", client.Version)
if client.Version == "" && client.Devel {
debug("setting version to >0.0.0-0")
Debug("setting version to >0.0.0-0")
client.Version = ">0.0.0-0"
}
@ -228,7 +228,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
return nil, err
}
debug("CHART PATH: %s\n", cp)
Debug("CHART PATH: %s\n", cp)
p := getter.All(settings)
vals, err := valueOpts.MergeValues(p)
@ -247,7 +247,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
}
if chartRequested.Metadata.Deprecated {
warning("This chart is deprecated")
Warning("This chart is deprecated")
}
if req := chartRequested.Metadata.Dependencies; req != nil {

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -25,9 +25,9 @@ import (
"github.com/gosuri/uitable"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli/output"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/release"
)
@ -71,7 +71,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
ValidArgsFunction: noCompletions,
RunE: func(cmd *cobra.Command, args []string) error {
if client.AllNamespaces {
if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug); err != nil {
if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), Debug); err != nil {
return err
}
}

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"bytes"
@ -39,9 +39,9 @@ const (
pluginDynamicCompletionExecutable = "plugin.complete"
)
type pluginError struct {
type PluginError struct {
error
code int
Code int
}
// loadPlugins loads plugins into the command list.
@ -138,9 +138,9 @@ func callPluginExecutable(pluginName string, main string, argv []string, out io.
if eerr, ok := err.(*exec.ExitError); ok {
os.Stderr.Write(eerr.Stderr)
status := eerr.Sys().(syscall.WaitStatus)
return pluginError{
return PluginError{
error: errors.Errorf("plugin %q exited with error", pluginName),
code: status.ExitStatus(),
Code: status.ExitStatus(),
}
}
return err

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"io"
@ -57,7 +57,7 @@ func runHook(p *plugin.Plugin, event string) error {
// I think its ... ¯\_(ツ)_/¯
// prog := exec.Command("cmd", "/C", p.Metadata.Hooks.Install())
debug("running %s hook: %s", event, prog)
Debug("running %s hook: %s", event, prog)
plugin.SetupPluginEnv(settings, p.Metadata.Name, p.Dir)
prog.Stdout, prog.Stderr = os.Stdout, os.Stderr

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -22,7 +22,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/plugin"
"helm.sh/helm/v3/pkg/plugin/installer"
)
@ -79,7 +79,7 @@ func (o *pluginInstallOptions) run(out io.Writer) error {
return err
}
debug("loading plugin from %s", i.Path())
Debug("loading plugin from %s", i.Path())
p, err := plugin.LoadDir(i.Path())
if err != nil {
return errors.Wrap(err, "plugin is installed but unusable")

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -32,7 +32,7 @@ func newPluginListCmd(out io.Writer) *cobra.Command {
Short: "list installed Helm plugins",
ValidArgsFunction: noCompletions,
RunE: func(cmd *cobra.Command, args []string) error {
debug("pluginDirs: %s", settings.PluginsDirectory)
Debug("pluginDirs: %s", settings.PluginsDirectory)
plugins, err := plugin.FindPlugins(settings.PluginsDirectory)
if err != nil {
return err

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"bytes"
@ -143,12 +143,12 @@ func TestLoadPlugins(t *testing.T) {
if runtime.GOOS != "windows" {
if err := pp.RunE(pp, tt.args); err != nil {
if tt.code > 0 {
perr, ok := err.(pluginError)
perr, ok := err.(PluginError)
if !ok {
t.Errorf("Expected %s to return pluginError: got %v(%T)", tt.use, err, err)
}
if perr.code != tt.code {
t.Errorf("Expected %s to return %d: got %d", tt.use, tt.code, perr.code)
if perr.Code != tt.code {
t.Errorf("Expected %s to return %d: got %d", tt.use, tt.code, perr.Code)
}
} else {
t.Errorf("Error running %s: %+v", tt.use, err)
@ -218,12 +218,12 @@ func TestLoadPluginsWithSpace(t *testing.T) {
if runtime.GOOS != "windows" {
if err := pp.RunE(pp, tt.args); err != nil {
if tt.code > 0 {
perr, ok := err.(pluginError)
perr, ok := err.(PluginError)
if !ok {
t.Errorf("Expected %s to return pluginError: got %v(%T)", tt.use, err, err)
}
if perr.code != tt.code {
t.Errorf("Expected %s to return %d: got %d", tt.use, tt.code, perr.code)
if perr.Code != tt.code {
t.Errorf("Expected %s to return %d: got %d", tt.use, tt.code, perr.Code)
}
} else {
t.Errorf("Error running %s: %+v", tt.use, err)

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -60,7 +60,7 @@ func (o *pluginUninstallOptions) complete(args []string) error {
}
func (o *pluginUninstallOptions) run(out io.Writer) error {
debug("loading installed plugins from %s", settings.PluginsDirectory)
Debug("loading installed plugins from %s", settings.PluginsDirectory)
plugins, err := plugin.FindPlugins(settings.PluginsDirectory)
if err != nil {
return err

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -62,7 +62,7 @@ func (o *pluginUpdateOptions) complete(args []string) error {
func (o *pluginUpdateOptions) run(out io.Writer) error {
installer.Debug = settings.Debug
debug("loading installed plugins from %s", settings.PluginsDirectory)
Debug("loading installed plugins from %s", settings.PluginsDirectory)
plugins, err := plugin.FindPlugins(settings.PluginsDirectory)
if err != nil {
return err
@ -104,7 +104,7 @@ func updatePlugin(p *plugin.Plugin) error {
return err
}
debug("loading plugin from %s", i.Path())
Debug("loading plugin from %s", i.Path())
updatedPlugin, err := plugin.LoadDir(i.Path())
if err != nil {
return err

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"io"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -23,8 +23,8 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
)
const pullDesc = `
@ -60,7 +60,7 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
client.Settings = settings
if client.Version == "" && client.Devel {
debug("setting version to >0.0.0-0")
Debug("setting version to >0.0.0-0")
client.Version = ">0.0.0-0"
}

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -22,8 +22,8 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/pusher"
)

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"io"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"bufio"
@ -27,8 +27,8 @@ import (
"github.com/moby/term"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
)
const registryLoginDesc = `
@ -119,7 +119,7 @@ func getUsernamePassword(usernameOpt string, passwordOpt string, passwordFromStd
}
}
} else {
warning("Using --password via the CLI is insecure. Use --password-stdin.")
Warning("Using --password via the CLI is insecure. Use --password-stdin.")
}
return username, password, nil

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"io"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
)
const registryLogoutDesc = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -25,9 +25,9 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli/output"
"helm.sh/helm/v3/pkg/cmd/require"
)
const releaseTestHelp = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"io"
@ -23,7 +23,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/cmd/require"
)
var repoHelm = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"context"
@ -31,7 +31,7 @@ import (
"golang.org/x/term"
"sigs.k8s.io/yaml"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/getter"
"helm.sh/helm/v3/pkg/repo"
)

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"io"
@ -24,7 +24,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/repo"
)

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"bytes"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -24,8 +24,8 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/cli/output"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/repo"
)

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -25,7 +25,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/helmpath"
"helm.sh/helm/v3/pkg/repo"
)

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"bytes"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -24,7 +24,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/getter"
"helm.sh/helm/v3/pkg/repo"
)

@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"bytes"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -24,8 +24,8 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
)
const rollbackDesc = `

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main // import "helm.sh/helm/v3/cmd/helm"
package cmd // import "helm.sh/helm/v3/cmd/helm"
import (
"context"
@ -30,6 +30,7 @@ import (
"k8s.io/client-go/tools/clientcmd"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/registry"
"helm.sh/helm/v3/pkg/repo"
)
@ -87,7 +88,23 @@ By default, the default directories depend on the Operating System. The defaults
| Windows | %TEMP%\helm | %APPDATA%\helm | %APPDATA%\helm |
`
func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) (*cobra.Command, error) {
var settings *cli.EnvSettings
func Debug(format string, v ...interface{}) {
if settings.Debug {
format = fmt.Sprintf("[debug] %s\n", format)
log.Output(2, fmt.Sprintf(format, v...))
}
}
func Warning(format string, v ...interface{}) {
format = fmt.Sprintf("WARNING: %s\n", format)
fmt.Fprintf(os.Stderr, format, v...)
}
func NewRootCmd(actionConfig *action.Configuration, settingsIn *cli.EnvSettings, out io.Writer, args []string) (*cobra.Command, error) {
settings = settingsIn
cmd := &cobra.Command{
Use: "helm",
Short: "The Helm package manager for Kubernetes.",

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"os"

@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"os"
@ -50,9 +50,9 @@ func checkPerms() {
perm := fi.Mode().Perm()
if perm&0040 > 0 {
warning("Kubernetes configuration file is group-readable. This is insecure. Location: %s", kc)
Warning("Kubernetes configuration file is group-readable. This is insecure. Location: %s", kc)
}
if perm&0004 > 0 {
warning("Kubernetes configuration file is world-readable. This is insecure. Location: %s", kc)
Warning("Kubernetes configuration file is world-readable. This is insecure. Location: %s", kc)
}
}

@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"bytes"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
func checkPerms() {
// Not yet implemented on Windows. If you know how to do a comprehensive perms

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"io"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -89,7 +89,7 @@ func (o *searchHubOptions) run(out io.Writer, args []string) error {
q := strings.Join(args, " ")
results, err := c.Search(q)
if err != nil {
debug("%s", err)
Debug("%s", err)
return fmt.Errorf("unable to perform search against %q", o.searchEndpoint)
}

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"bufio"
@ -30,8 +30,8 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/search"
"helm.sh/helm/v3/pkg/cli/output"
"helm.sh/helm/v3/pkg/cmd/search"
"helm.sh/helm/v3/pkg/helmpath"
"helm.sh/helm/v3/pkg/repo"
)
@ -130,17 +130,17 @@ func (o *searchRepoOptions) run(out io.Writer, args []string) error {
}
func (o *searchRepoOptions) setupSearchedVersion() {
debug("Original chart version: %q", o.version)
Debug("Original chart version: %q", o.version)
if o.version != "" {
return
}
if o.devel { // search for releases and prereleases (alpha, beta, and release candidate releases).
debug("setting version to >0.0.0-0")
Debug("setting version to >0.0.0-0")
o.version = ">0.0.0-0"
} else { // search only for stable releases, prerelease versions will be skip
debug("setting version to >0.0.0")
Debug("setting version to >0.0.0")
o.version = ">0.0.0"
}
}
@ -189,8 +189,8 @@ func (o *searchRepoOptions) buildIndex() (*search.Index, error) {
f := filepath.Join(o.repoCacheDir, helmpath.CacheIndexFile(n))
ind, err := repo.LoadIndexFile(f)
if err != nil {
warning("Repo %q is corrupt or missing. Try 'helm repo update'.", n)
warning("%s", err)
Warning("Repo %q is corrupt or missing. Try 'helm repo update'.", n)
Warning("%s", err)
continue
}

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import "testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"
@ -23,8 +23,8 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cmd/require"
)
const showDesc = `
@ -212,9 +212,9 @@ func addShowFlags(subCmd *cobra.Command, client *action.Show) {
}
func runShow(args []string, client *action.Show) (string, error) {
debug("Original chart version: %q", client.Version)
Debug("Original chart version: %q", client.Version)
if client.Version == "" && client.Devel {
debug("setting version to >0.0.0-0")
Debug("setting version to >0.0.0-0")
client.Version = ">0.0.0-0"
}

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"bytes"
@ -28,10 +28,10 @@ import (
"k8s.io/kubectl/pkg/cmd/get"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/cli/output"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/release"
)

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"testing"

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"bytes"
@ -31,10 +31,10 @@ import (
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/cli/values"
"helm.sh/helm/v3/pkg/cmd/require"
"helm.sh/helm/v3/pkg/releaseutil"
)

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package cmd
import (
"fmt"

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save