diff --git a/Makefile b/Makefile index e6efdd2a0..9ad60a13e 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ deps: go get -t -v ./... test: + @test -z "$(shell find . -name '*.go' | xargs gofmt -l)" || (echo "Need to run 'go fmt ./...'"; exit 1) go vet ./... go test -cover -short ./... diff --git a/cli/restart.go b/cli/restart.go index 727af2545..cf6b51ecb 100644 --- a/cli/restart.go +++ b/cli/restart.go @@ -30,7 +30,7 @@ func restartCommandFunc(c *cli.Context, client *client.Client) error { case 2: branch = "master" sha = args[1] - case 3,4,5: + case 3, 4, 5: branch = args[1] sha = args[2] } diff --git a/plugin/deploy/deis/deis.go b/plugin/deploy/deis/deis.go index acc5a7439..b98721ec8 100644 --- a/plugin/deploy/deis/deis.go +++ b/plugin/deploy/deis/deis.go @@ -22,20 +22,20 @@ const ( // deisurl: deis.myurl.tdl:2222/ type Deis struct { - App string `yaml:"app,omitempty"` - Force bool `yaml:"force,omitempty"` - Deisurl string `yaml:"deisurl,omitempty"` - Condition *condition.Condition `yaml:"when,omitempty"` + App string `yaml:"app,omitempty"` + Force bool `yaml:"force,omitempty"` + Deisurl string `yaml:"deisurl,omitempty"` + Condition *condition.Condition `yaml:"when,omitempty"` } func (h *Deis) Write(f *buildfile.Buildfile) { f.WriteCmdSilent(CmdRevParse) f.WriteCmdSilent(CmdGlobalUser) f.WriteCmdSilent(CmdGlobalEmail) - + // git@deis.yourdomain.com:2222/drone.git - - f.WriteCmd(fmt.Sprintf("git remote add deis ssh://git@%s%s.git", h.Deisurl , h.App)) + + f.WriteCmd(fmt.Sprintf("git remote add deis ssh://git@%s%s.git", h.Deisurl, h.App)) switch h.Force { case true: diff --git a/plugin/deploy/deis/deis_test.go b/plugin/deploy/deis/deis_test.go index 42b053f4d..b9621aa9e 100644 --- a/plugin/deploy/deis/deis_test.go +++ b/plugin/deploy/deis/deis_test.go @@ -16,8 +16,8 @@ func Test_Deis(t *testing.T) { g.It("Should set git.config", func() { b := new(buildfile.Buildfile) h := Deis{ - App: "drone", - Deisurl: "deis.yourdomain.com:2222", + App: "drone", + Deisurl: "deis.yourdomain.com:2222", } h.Write(b) @@ -30,8 +30,8 @@ func Test_Deis(t *testing.T) { g.It("Should add remote", func() { b := new(buildfile.Buildfile) h := Deis{ - App: "drone", - Deisurl: "deis.yourdomain.com:2222/", + App: "drone", + Deisurl: "deis.yourdomain.com:2222/", } h.Write(b) @@ -54,7 +54,7 @@ func Test_Deis(t *testing.T) { b := new(buildfile.Buildfile) h := Deis{ Force: true, - App: "drone", + App: "drone", } h.Write(b) diff --git a/plugin/deploy/deployment.go b/plugin/deploy/deployment.go index 3e059ac1e..198c71a27 100644 --- a/plugin/deploy/deployment.go +++ b/plugin/deploy/deployment.go @@ -5,9 +5,9 @@ import ( "github.com/drone/drone/shared/build/buildfile" "github.com/drone/drone/shared/build/repo" + "github.com/drone/drone/plugin/deploy/deis" "github.com/drone/drone/plugin/deploy/git" "github.com/drone/drone/plugin/deploy/heroku" - "github.com/drone/drone/plugin/deploy/deis" "github.com/drone/drone/plugin/deploy/modulus" "github.com/drone/drone/plugin/deploy/nodejitsu" "github.com/drone/drone/plugin/deploy/tsuru" @@ -20,7 +20,7 @@ type Deploy struct { CloudFoundry *CloudFoundry `yaml:"cloudfoundry,omitempty"` Git *git.Git `yaml:"git,omitempty"` Heroku *heroku.Heroku `yaml:"heroku,omitempty"` - Deis *deis.Deis `yaml:"deis,omitempty"` + Deis *deis.Deis `yaml:"deis,omitempty"` Modulus *modulus.Modulus `yaml:"modulus,omitempty"` Nodejitsu *nodejitsu.Nodejitsu `yaml:"nodejitsu,omitempty"` SSH *SSH `yaml:"ssh,omitempty"` diff --git a/plugin/deploy/heroku/heroku.go b/plugin/deploy/heroku/heroku.go index 7a551fbb0..75135f640 100644 --- a/plugin/deploy/heroku/heroku.go +++ b/plugin/deploy/heroku/heroku.go @@ -17,7 +17,7 @@ const ( // Command to write the API token to ~/.netrc // use "_" since heroku git authentication ignores username - CmdLogin = "echo 'machine git.heroku.com login _ password %s' >> ~/.netrc" + CmdLogin = "echo 'machine git.heroku.com login _ password %s' >> ~/.netrc" ) type Heroku struct { diff --git a/plugin/deploy/heroku/heroku_test.go b/plugin/deploy/heroku/heroku_test.go index e5a8eeef9..71e3d160c 100644 --- a/plugin/deploy/heroku/heroku_test.go +++ b/plugin/deploy/heroku/heroku_test.go @@ -29,14 +29,14 @@ func Test_Heroku(t *testing.T) { g.It("Should write token", func() { b := new(buildfile.Buildfile) h := Heroku{ - App: "drone", + App: "drone", Token: "mock-token", } h.Write(b) out := b.String() g.Assert(strings.Contains(out, "\necho 'machine git.heroku.com login _ password mock-token' >> ~/.netrc\n")).Equal(true) - }) + }) g.It("Should add remote", func() { b := new(buildfile.Buildfile) diff --git a/shared/build/script/docker.go b/shared/build/script/docker.go index dfceeeba3..185c293e0 100644 --- a/shared/build/script/docker.go +++ b/shared/build/script/docker.go @@ -1,19 +1,19 @@ package script const ( - DefaultDockerNetworkMode = "bridge" + DefaultDockerNetworkMode = "bridge" ) // Docker stores the configuration details for // configuring docker container. type Docker struct { - // NetworkMode (also known as `--net` option) - // Could be set only if Docker is running in privileged mode - NetworkMode *string `yaml:"net,omitempty"` + // NetworkMode (also known as `--net` option) + // Could be set only if Docker is running in privileged mode + NetworkMode *string `yaml:"net,omitempty"` - // Hostname (also known as `--hostname` option) - // Could be set only if Docker is running in privileged mode - Hostname *string `yaml:"hostname,omitempty"` + // Hostname (also known as `--hostname` option) + // Could be set only if Docker is running in privileged mode + Hostname *string `yaml:"hostname,omitempty"` } // DockerNetworkMode returns DefaultNetworkMode @@ -21,10 +21,10 @@ type Docker struct { // DockerNetworkMode returns Docker.NetworkMode // when it is not empty. func DockerNetworkMode(d *Docker) string { - if d == nil || d.NetworkMode == nil { - return DefaultDockerNetworkMode - } - return *d.NetworkMode + if d == nil || d.NetworkMode == nil { + return DefaultDockerNetworkMode + } + return *d.NetworkMode } // DockerNetworkMode returns empty string @@ -32,8 +32,8 @@ func DockerNetworkMode(d *Docker) string { // DockerNetworkMode returns Docker.NetworkMode // when it is not empty. func DockerHostname(d *Docker) string { - if d == nil || d.Hostname == nil { - return "" - } - return *d.Hostname + if d == nil || d.Hostname == nil { + return "" + } + return *d.Hostname } diff --git a/shared/build/script/docker_test.go b/shared/build/script/docker_test.go index e089d9ea4..a145d3a3f 100644 --- a/shared/build/script/docker_test.go +++ b/shared/build/script/docker_test.go @@ -1,69 +1,69 @@ package script import ( - "testing" + "testing" ) func TestDockerNetworkMode(t *testing.T) { - var d *Docker - var expected string + var d *Docker + var expected string - expected = DefaultDockerNetworkMode - d = nil - if actual := DockerNetworkMode(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = DefaultDockerNetworkMode + d = nil + if actual := DockerNetworkMode(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = DefaultDockerNetworkMode - d = &Docker{} - if actual := DockerNetworkMode(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = DefaultDockerNetworkMode + d = &Docker{} + if actual := DockerNetworkMode(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = DefaultDockerNetworkMode - d = &Docker{NetworkMode: nil} - if actual := DockerNetworkMode(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = DefaultDockerNetworkMode + d = &Docker{NetworkMode: nil} + if actual := DockerNetworkMode(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = "bridge" - d = &Docker{NetworkMode: &expected} - if actual := DockerNetworkMode(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "bridge" + d = &Docker{NetworkMode: &expected} + if actual := DockerNetworkMode(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = "host" - d = &Docker{NetworkMode: &expected} - if actual := DockerNetworkMode(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "host" + d = &Docker{NetworkMode: &expected} + if actual := DockerNetworkMode(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } } func TestDockerHostname(t *testing.T) { - var d *Docker - var expected string + var d *Docker + var expected string - expected = "" - d = nil - if actual := DockerHostname(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "" + d = nil + if actual := DockerHostname(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = "" - d = &Docker{} - if actual := DockerHostname(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "" + d = &Docker{} + if actual := DockerHostname(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = "" - d = &Docker{Hostname: nil} - if actual := DockerHostname(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "" + d = &Docker{Hostname: nil} + if actual := DockerHostname(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } - expected = "host" - d = &Docker{Hostname: &expected} - if actual := DockerHostname(d); actual != expected { - t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) - } + expected = "host" + d = &Docker{Hostname: &expected} + if actual := DockerHostname(d); actual != expected { + t.Errorf("The result is invalid. [expected: %s][actual: %s]", expected, actual) + } }