Commit be2a09d6 authored by Matt Butcher's avatar Matt Butcher

fix(lint): correct several formatting issues

parent 9b494f55
...@@ -4,7 +4,7 @@ endif ...@@ -4,7 +4,7 @@ endif
BIN_DIR := bin BIN_DIR := bin
DIST_DIR := _dist DIST_DIR := _dist
GO_PACKAGES := cmd/helm dm GO_PACKAGES := cmd/helm dm deploy format kubectl
MAIN_GO := github.com/deis/helm-dm/cmd/helm MAIN_GO := github.com/deis/helm-dm/cmd/helm
HELM_BIN := helm-dm HELM_BIN := helm-dm
PATH_WITH_HELM = PATH="$(shell pwd)/$(BIN_DIR)/helm:$(PATH)" PATH_WITH_HELM = PATH="$(shell pwd)/$(BIN_DIR)/helm:$(PATH)"
...@@ -47,7 +47,7 @@ quicktest: ...@@ -47,7 +47,7 @@ quicktest:
$(PATH_WITH_HELM) go test -short $(addprefix ./,$(GO_PACKAGES)) $(PATH_WITH_HELM) go test -short $(addprefix ./,$(GO_PACKAGES))
test: test-style test: test-style
$(PATH_WITH_HELM) go test -v ./ $(addprefix ./,$(GO_PACKAGES)) $(PATH_WITH_HELM) go test -v $(addprefix ./,$(GO_PACKAGES))
test-style: test-style:
@if [ $(shell gofmt -e -l -s *.go $(GO_PACKAGES)) ]; then \ @if [ $(shell gofmt -e -l -s *.go $(GO_PACKAGES)) ]; then \
......
package main package main
import ( import (
"fmt" "errors"
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
"github.com/kubernetes/deployment-manager/chart" "github.com/kubernetes/deployment-manager/chart"
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
func create(c *cli.Context) error { func create(c *cli.Context) error {
args := c.Args() args := c.Args()
if len(args) < 1 { if len(args) < 1 {
return fmt.Errorf("'helm create' requires a chart name as an argument.") return errors.New("'helm create' requires a chart name as an argument")
} }
cf := &chart.Chartfile{ cf := &chart.Chartfile{
......
...@@ -13,13 +13,13 @@ import ( ...@@ -13,13 +13,13 @@ import (
func deploy(c *cli.Context) error { func deploy(c *cli.Context) error {
args := c.Args() args := c.Args()
if len(args) < 1 { if len(args) < 1 {
format.Error("First argument, filename, is required. Try 'helm deploy --help'") format.Err("First argument, filename, is required. Try 'helm deploy --help'")
os.Exit(1) os.Exit(1)
} }
props, err := parseProperties(c.String("properties")) props, err := parseProperties(c.String("properties"))
if err != nil { if err != nil {
format.Error("Failed to parse properties: %s", err) format.Err("Failed to parse properties: %s", err)
os.Exit(1) os.Exit(1)
} }
...@@ -36,7 +36,6 @@ func deploy(c *cli.Context) error { ...@@ -36,7 +36,6 @@ func deploy(c *cli.Context) error {
} }
return doDeploy(d, c.GlobalString("host"), c.Bool("dry-run")) return doDeploy(d, c.GlobalString("host"), c.Bool("dry-run"))
return nil
} }
func doDeploy(cfg *dep.Deployment, host string, dry bool) error { func doDeploy(cfg *dep.Deployment, host string, dry bool) error {
......
...@@ -8,14 +8,15 @@ import ( ...@@ -8,14 +8,15 @@ import (
"github.com/deis/helm-dm/kubectl" "github.com/deis/helm-dm/kubectl"
) )
var ErrAlreadyInstalled error = errors.New("Already Installed") // ErrAlreadyInstalled indicates that DM is already installed.
var ErrAlreadyInstalled = errors.New("Already Installed")
func install(dryRun bool) error { func install(dryRun bool) error {
runner := getKubectlRunner(dryRun) runner := getKubectlRunner(dryRun)
out, err := dm.Install(runner) out, err := dm.Install(runner)
if err != nil { if err != nil {
format.Error("Error installing: %s %s", out, err) format.Err("Error installing: %s %s", out, err)
} }
format.Msg(out) format.Msg(out)
return nil return nil
......
...@@ -47,7 +47,7 @@ func commands() []cli.Command { ...@@ -47,7 +47,7 @@ func commands() []cli.Command {
}, },
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
if err := install(c.Bool("dry-run")); err != nil { if err := install(c.Bool("dry-run")); err != nil {
format.Error("%s (Run 'helm doctor' for more information)", err) format.Err("%s (Run 'helm doctor' for more information)", err)
os.Exit(1) os.Exit(1)
} }
}, },
...@@ -64,7 +64,7 @@ func commands() []cli.Command { ...@@ -64,7 +64,7 @@ func commands() []cli.Command {
}, },
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
if err := uninstall(c.Bool("dry-run")); err != nil { if err := uninstall(c.Bool("dry-run")); err != nil {
format.Error("%s (Run 'helm doctor' for more information)", err) format.Err("%s (Run 'helm doctor' for more information)", err)
os.Exit(1) os.Exit(1)
} }
}, },
...@@ -73,7 +73,7 @@ func commands() []cli.Command { ...@@ -73,7 +73,7 @@ func commands() []cli.Command {
Name: "status", Name: "status",
Usage: "Show status of DM.", Usage: "Show status of DM.",
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
format.Error("Not yet implemented") format.Err("Not yet implemented")
os.Exit(1) os.Exit(1)
}, },
}, },
...@@ -83,7 +83,7 @@ func commands() []cli.Command { ...@@ -83,7 +83,7 @@ func commands() []cli.Command {
ArgsUsage: "", ArgsUsage: "",
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
if err := target(c.Bool("dry-run")); err != nil { if err := target(c.Bool("dry-run")); err != nil {
format.Error("%s (Is the cluster running?)", err) format.Err("%s (Is the cluster running?)", err)
os.Exit(1) os.Exit(1)
} }
}, },
...@@ -108,7 +108,7 @@ func commands() []cli.Command { ...@@ -108,7 +108,7 @@ func commands() []cli.Command {
}, },
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
if err := install(c.Bool("dry-run")); err != nil { if err := install(c.Bool("dry-run")); err != nil {
format.Error("%s (Run 'helm doctor' for more information)", err) format.Err("%s (Run 'helm doctor' for more information)", err)
os.Exit(1) os.Exit(1)
} }
}, },
...@@ -119,7 +119,7 @@ func commands() []cli.Command { ...@@ -119,7 +119,7 @@ func commands() []cli.Command {
ArgsUsage: "", ArgsUsage: "",
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
if err := doctor(); err != nil { if err := doctor(); err != nil {
format.Error("%s", err) format.Err("%s", err)
os.Exit(1) os.Exit(1)
} }
}, },
......
...@@ -14,7 +14,7 @@ func listCmd() cli.Command { ...@@ -14,7 +14,7 @@ func listCmd() cli.Command {
Usage: "Lists the deployments in the cluster", Usage: "Lists the deployments in the cluster",
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
if err := list(c.GlobalString("host")); err != nil { if err := list(c.GlobalString("host")); err != nil {
format.Error("%s (Is the cluster running?)", err) format.Err("%s (Is the cluster running?)", err)
os.Exit(1) os.Exit(1)
} }
}, },
......
package main package main
import ( import (
"errors"
"fmt" "fmt"
"os" "os"
...@@ -12,7 +13,7 @@ import ( ...@@ -12,7 +13,7 @@ import (
func pack(cxt *cli.Context) error { func pack(cxt *cli.Context) error {
args := cxt.Args() args := cxt.Args()
if len(args) < 1 { if len(args) < 1 {
return fmt.Errorf("'helm package' requires a path to a chart directory as an argument.") return errors.New("'helm package' requires a path to a chart directory as an argument")
} }
dir := args[0] dir := args[0]
......
...@@ -78,6 +78,7 @@ func (d *Deployment) Prepare() error { ...@@ -78,6 +78,7 @@ func (d *Deployment) Prepare() error {
return nil return nil
} }
// Chart retrieves the chart from teh deployment.
func (d *Deployment) Chart() *chart.Chart { func (d *Deployment) Chart() *chart.Chart {
return d.lchart return d.lchart
} }
......
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
) )
// The default HTTP timeout // The default HTTP timeout
var DefaultHTTPTimeout time.Duration = time.Second * 10 var DefaultHTTPTimeout = time.Second * 10
// Client is a DM client. // Client is a DM client.
type Client struct { type Client struct {
...@@ -50,7 +50,7 @@ func (c *Client) url(path string) string { ...@@ -50,7 +50,7 @@ func (c *Client) url(path string) string {
func (c *Client) CallService(path, method, action string, dest interface{}, reader io.ReadCloser) error { func (c *Client) CallService(path, method, action string, dest interface{}, reader io.ReadCloser) error {
u := c.url(path) u := c.url(path)
resp, err := c.callHttp(u, method, action, reader) resp, err := c.callHTTP(u, method, action, reader)
if err != nil { if err != nil {
return err return err
} }
...@@ -69,8 +69,8 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read ...@@ -69,8 +69,8 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read
return nil return nil
} }
// callHttp is a low-level primative for executing HTTP operations. // callHTTP is a low-level primative for executing HTTP operations.
func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) (string, error) { func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (string, error) {
request, err := http.NewRequest(method, path, reader) request, err := http.NewRequest(method, path, reader)
request.Header.Add("Content-Type", "application/json") request.Header.Add("Content-Type", "application/json")
...@@ -99,6 +99,7 @@ func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) (st ...@@ -99,6 +99,7 @@ func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) (st
return string(body), nil return string(body), nil
} }
// ListDeployments lists the deployments in DM.
func (c *Client) ListDeployments() error { func (c *Client) ListDeployments() error {
var d interface{} var d interface{}
if err := c.CallService("deployments", "GET", "foo", &d, nil); err != nil { if err := c.CallService("deployments", "GET", "foo", &d, nil); err != nil {
...@@ -109,6 +110,7 @@ func (c *Client) ListDeployments() error { ...@@ -109,6 +110,7 @@ func (c *Client) ListDeployments() error {
return nil return nil
} }
// DeployChart sends a chart to DM for deploying.
func (c *Client) DeployChart(filename, deployname string) error { func (c *Client) DeployChart(filename, deployname string) error {
f, err := os.Open(filename) f, err := os.Open(filename)
if err != nil { if err != nil {
......
...@@ -20,7 +20,7 @@ func IsInstalled(runner kubectl.Runner) bool { ...@@ -20,7 +20,7 @@ func IsInstalled(runner kubectl.Runner) bool {
// we know that we have both the namespace and the manager API server. // we know that we have both the namespace and the manager API server.
out, err := runner.GetByKind("rc", "manager-rc", "dm") out, err := runner.GetByKind("rc", "manager-rc", "dm")
if err != nil { if err != nil {
format.Error("Installation not found: %s %s", out, err) format.Err("Installation not found: %s %s", out, err)
return false return false
} }
return true return true
......
...@@ -15,6 +15,7 @@ type debugTransport struct { ...@@ -15,6 +15,7 @@ type debugTransport struct {
http.RoundTripper http.RoundTripper
} }
// NewDebugTransport returns a debugging implementation of a RoundTripper.
func NewDebugTransport(rt http.RoundTripper) http.RoundTripper { func NewDebugTransport(rt http.RoundTripper) http.RoundTripper {
return debugTransport{ return debugTransport{
RoundTripper: rt, RoundTripper: rt,
......
...@@ -7,16 +7,19 @@ import ( ...@@ -7,16 +7,19 @@ import (
// This is all just placeholder. // This is all just placeholder.
func Error(msg string, v ...interface{}) { // Err prints an error message to Stderr.
func Err(msg string, v ...interface{}) {
msg = "[ERROR] " + msg + "\n" msg = "[ERROR] " + msg + "\n"
fmt.Fprintf(os.Stderr, msg, v...) fmt.Fprintf(os.Stderr, msg, v...)
} }
// Info prints an informational message to Stdout.
func Info(msg string, v ...interface{}) { func Info(msg string, v ...interface{}) {
msg = "[INFO] " + msg + "\n" msg = "[INFO] " + msg + "\n"
fmt.Fprintf(os.Stdout, msg, v...) fmt.Fprintf(os.Stdout, msg, v...)
} }
// Msg prints a raw message to Stdout.
func Msg(msg string, v ...interface{}) { func Msg(msg string, v ...interface{}) {
fmt.Fprintf(os.Stdout, msg, v...) fmt.Fprintf(os.Stdout, msg, v...)
} }
......
...@@ -13,6 +13,7 @@ func (r RealRunner) Get(stdin []byte, ns string) ([]byte, error) { ...@@ -13,6 +13,7 @@ func (r RealRunner) Get(stdin []byte, ns string) ([]byte, error) {
return cmd.CombinedOutput() return cmd.CombinedOutput()
} }
// GetByKind gets a named thing by kind.
func (r RealRunner) GetByKind(kind, name, ns string) (string, error) { func (r RealRunner) GetByKind(kind, name, ns string) (string, error) {
args := []string{"get", kind, name} args := []string{"get", kind, name}
...@@ -37,6 +38,7 @@ func (r PrintRunner) Get(stdin []byte, ns string) ([]byte, error) { ...@@ -37,6 +38,7 @@ func (r PrintRunner) Get(stdin []byte, ns string) ([]byte, error) {
return []byte(cmd.String()), nil return []byte(cmd.String()), nil
} }
// GetByKind gets a named thing by kind.
func (r PrintRunner) GetByKind(kind, name, ns string) (string, error) { func (r PrintRunner) GetByKind(kind, name, ns string) (string, error) {
args := []string{"get", kind, name} args := []string{"get", kind, name}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment