fix(lint): correct several formatting issues

pull/291/head
Matt Butcher 9 years ago
parent 9b494f5546
commit be2a09d612

@ -4,7 +4,7 @@ endif
BIN_DIR := bin
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
HELM_BIN := helm-dm
PATH_WITH_HELM = PATH="$(shell pwd)/$(BIN_DIR)/helm:$(PATH)"
@ -47,7 +47,7 @@ quicktest:
$(PATH_WITH_HELM) go test -short $(addprefix ./,$(GO_PACKAGES))
test: test-style
$(PATH_WITH_HELM) go test -v ./ $(addprefix ./,$(GO_PACKAGES))
$(PATH_WITH_HELM) go test -v $(addprefix ./,$(GO_PACKAGES))
test-style:
@if [ $(shell gofmt -e -l -s *.go $(GO_PACKAGES)) ]; then \

@ -1,7 +1,7 @@
package main
import (
"fmt"
"errors"
"github.com/codegangsta/cli"
"github.com/kubernetes/deployment-manager/chart"
@ -10,7 +10,7 @@ import (
func create(c *cli.Context) error {
args := c.Args()
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{

@ -13,13 +13,13 @@ import (
func deploy(c *cli.Context) error {
args := c.Args()
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)
}
props, err := parseProperties(c.String("properties"))
if err != nil {
format.Error("Failed to parse properties: %s", err)
format.Err("Failed to parse properties: %s", err)
os.Exit(1)
}
@ -36,7 +36,6 @@ func deploy(c *cli.Context) error {
}
return doDeploy(d, c.GlobalString("host"), c.Bool("dry-run"))
return nil
}
func doDeploy(cfg *dep.Deployment, host string, dry bool) error {

@ -8,14 +8,15 @@ import (
"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 {
runner := getKubectlRunner(dryRun)
out, err := dm.Install(runner)
if err != nil {
format.Error("Error installing: %s %s", out, err)
format.Err("Error installing: %s %s", out, err)
}
format.Msg(out)
return nil

@ -47,7 +47,7 @@ func commands() []cli.Command {
},
Action: func(c *cli.Context) {
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)
}
},
@ -64,7 +64,7 @@ func commands() []cli.Command {
},
Action: func(c *cli.Context) {
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)
}
},
@ -73,7 +73,7 @@ func commands() []cli.Command {
Name: "status",
Usage: "Show status of DM.",
Action: func(c *cli.Context) {
format.Error("Not yet implemented")
format.Err("Not yet implemented")
os.Exit(1)
},
},
@ -83,7 +83,7 @@ func commands() []cli.Command {
ArgsUsage: "",
Action: func(c *cli.Context) {
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)
}
},
@ -108,7 +108,7 @@ func commands() []cli.Command {
},
Action: func(c *cli.Context) {
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)
}
},
@ -119,7 +119,7 @@ func commands() []cli.Command {
ArgsUsage: "",
Action: func(c *cli.Context) {
if err := doctor(); err != nil {
format.Error("%s", err)
format.Err("%s", err)
os.Exit(1)
}
},

@ -14,7 +14,7 @@ func listCmd() cli.Command {
Usage: "Lists the deployments in the cluster",
Action: func(c *cli.Context) {
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)
}
},

@ -1,6 +1,7 @@
package main
import (
"errors"
"fmt"
"os"
@ -12,7 +13,7 @@ import (
func pack(cxt *cli.Context) error {
args := cxt.Args()
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]

@ -78,6 +78,7 @@ func (d *Deployment) Prepare() error {
return nil
}
// Chart retrieves the chart from teh deployment.
func (d *Deployment) Chart() *chart.Chart {
return d.lchart
}

@ -14,7 +14,7 @@ import (
)
// The default HTTP timeout
var DefaultHTTPTimeout time.Duration = time.Second * 10
var DefaultHTTPTimeout = time.Second * 10
// Client is a DM client.
type Client struct {
@ -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 {
u := c.url(path)
resp, err := c.callHttp(u, method, action, reader)
resp, err := c.callHTTP(u, method, action, reader)
if err != nil {
return err
}
@ -69,8 +69,8 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read
return nil
}
// callHttp is a low-level primative for executing HTTP operations.
func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) (string, error) {
// callHTTP is a low-level primative for executing HTTP operations.
func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (string, error) {
request, err := http.NewRequest(method, path, reader)
request.Header.Add("Content-Type", "application/json")
@ -99,6 +99,7 @@ func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) (st
return string(body), nil
}
// ListDeployments lists the deployments in DM.
func (c *Client) ListDeployments() error {
var d interface{}
if err := c.CallService("deployments", "GET", "foo", &d, nil); err != nil {
@ -109,6 +110,7 @@ func (c *Client) ListDeployments() error {
return nil
}
// DeployChart sends a chart to DM for deploying.
func (c *Client) DeployChart(filename, deployname string) error {
f, err := os.Open(filename)
if err != nil {

@ -20,7 +20,7 @@ func IsInstalled(runner kubectl.Runner) bool {
// we know that we have both the namespace and the manager API server.
out, err := runner.GetByKind("rc", "manager-rc", "dm")
if err != nil {
format.Error("Installation not found: %s %s", out, err)
format.Err("Installation not found: %s %s", out, err)
return false
}
return true

@ -15,6 +15,7 @@ type debugTransport struct {
http.RoundTripper
}
// NewDebugTransport returns a debugging implementation of a RoundTripper.
func NewDebugTransport(rt http.RoundTripper) http.RoundTripper {
return debugTransport{
RoundTripper: rt,

@ -7,16 +7,19 @@ import (
// 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"
fmt.Fprintf(os.Stderr, msg, v...)
}
// Info prints an informational message to Stdout.
func Info(msg string, v ...interface{}) {
msg = "[INFO] " + msg + "\n"
fmt.Fprintf(os.Stdout, msg, v...)
}
// Msg prints a raw message to Stdout.
func Msg(msg string, v ...interface{}) {
fmt.Fprintf(os.Stdout, msg, v...)
}

@ -13,6 +13,7 @@ func (r RealRunner) Get(stdin []byte, ns string) ([]byte, error) {
return cmd.CombinedOutput()
}
// GetByKind gets a named thing by kind.
func (r RealRunner) GetByKind(kind, name, ns string) (string, error) {
args := []string{"get", kind, name}
@ -37,6 +38,7 @@ func (r PrintRunner) Get(stdin []byte, ns string) ([]byte, error) {
return []byte(cmd.String()), nil
}
// GetByKind gets a named thing by kind.
func (r PrintRunner) GetByKind(kind, name, ns string) (string, error) {
args := []string{"get", kind, name}

Loading…
Cancel
Save