From b5ce6939dff1a94b99744ec0525d7c9db92840e2 Mon Sep 17 00:00:00 2001 From: Matt Butcher <mbutcher@engineyard.com> Date: Wed, 6 Jan 2016 17:14:24 -0800 Subject: [PATCH] feat(*): add target command --- cmd/helm.go | 16 +++++++++++++++- cmd/target.go | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 cmd/target.go diff --git a/cmd/helm.go b/cmd/helm.go index 8821160bf..d69ebd667 100644 --- a/cmd/helm.go +++ b/cmd/helm.go @@ -39,7 +39,21 @@ func commands() []cli.Command { }, }, { - Name: "target", + Name: "target", + Usage: "Displays information about cluster.", + ArgsUsage: "", + Action: func(c *cli.Context) { + if err := target(c.Bool("dry-run")); err != nil { + format.Error(err.Error()) + os.Exit(1) + } + }, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "dry-run", + Usage: "Only display the underlying kubectl commands.", + }, + }, }, { Name: "doctor", diff --git a/cmd/target.go b/cmd/target.go new file mode 100644 index 000000000..cb06c8e77 --- /dev/null +++ b/cmd/target.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + + "github.com/deis/helm-dm/format" + "github.com/deis/helm-dm/kubectl" +) + +func target(dryRun bool) error { + client := kubectl.Client + if dryRun { + client = kubectl.PrintRunner{} + } + out, err := client.ClusterInfo() + if err != nil { + return fmt.Errorf("%s (%s)", out, err) + } + format.Msg(string(out)) + return nil +} -- GitLab