From 67637d4fc12eef87cd8fbd75c8d28e4e084b43cc Mon Sep 17 00:00:00 2001 From: Andreas Fleig Date: Tue, 15 May 2018 16:43:20 +0200 Subject: [PATCH] go fmt everything --- cfmysql/api_client.go | 4 ++-- cfmysql/api_client_test.go | 4 ++-- cfmysql/cf_service.go | 4 ++-- cfmysql/cf_service_test.go | 12 ++++++------ cfmysql/http_client_factory.go | 6 +++--- cfmysql/http_wrapper.go | 4 ++-- cfmysql/http_wrapper_test.go | 6 +++--- cfmysql/models/models.go | 30 ++++++++++++++--------------- cfmysql/mysql_runner.go | 8 ++++---- cfmysql/mysql_runner_test.go | 4 ++-- cfmysql/net_wrapper.go | 2 +- cfmysql/os_wrapper.go | 4 ++-- cfmysql/plugin.go | 4 ++-- cfmysql/plugin_test.go | 12 ++++++------ cfmysql/port_finder.go | 2 +- cfmysql/port_waiter.go | 4 ++-- cfmysql/port_waiter_test.go | 8 ++++---- cfmysql/request_dumper.go | 4 ++-- cfmysql/request_dumper_test.go | 22 ++++++++++----------- cfmysql/resources/resources.go | 10 +++++----- cfmysql/resources/resources_test.go | 10 +++++----- cfmysql/ssh_runner.go | 2 +- cfmysql/ssh_runner_test.go | 10 +++++----- main.go | 2 +- 24 files changed, 89 insertions(+), 89 deletions(-) diff --git a/cfmysql/api_client.go b/cfmysql/api_client.go index 409c921..cd03969 100644 --- a/cfmysql/api_client.go +++ b/cfmysql/api_client.go @@ -4,13 +4,13 @@ import ( "encoding/json" "fmt" + "bytes" "code.cloudfoundry.org/cli/plugin" sdkModels "code.cloudfoundry.org/cli/plugin/models" pluginModels "github.com/andreasf/cf-mysql-plugin/cfmysql/models" "github.com/andreasf/cf-mysql-plugin/cfmysql/resources" - "net/url" "io" - "bytes" + "net/url" ) //go:generate counterfeiter . ApiClient diff --git a/cfmysql/api_client_test.go b/cfmysql/api_client_test.go index 68089b6..fd70d1e 100644 --- a/cfmysql/api_client_test.go +++ b/cfmysql/api_client_test.go @@ -6,15 +6,15 @@ import ( "errors" "fmt" + "bytes" "code.cloudfoundry.org/cli/plugin/models" "code.cloudfoundry.org/cli/plugin/pluginfakes" "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" + "github.com/andreasf/cf-mysql-plugin/cfmysql/models" "github.com/andreasf/cf-mysql-plugin/cfmysql/test_resources" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/andreasf/cf-mysql-plugin/cfmysql/models" "io" - "bytes" ) var _ = Describe("ApiClient", func() { diff --git a/cfmysql/cf_service.go b/cfmysql/cf_service.go index d7343b9..221626a 100644 --- a/cfmysql/cf_service.go +++ b/cfmysql/cf_service.go @@ -1,9 +1,9 @@ package cfmysql import ( - "fmt" "code.cloudfoundry.org/cli/plugin" sdkModels "code.cloudfoundry.org/cli/plugin/models" + "fmt" pluginModels "github.com/andreasf/cf-mysql-plugin/cfmysql/models" "io" ) @@ -22,7 +22,7 @@ func NewCfService(apiClient ApiClient, runner SshRunner, waiter PortWaiter, http portWaiter: waiter, httpClient: httpClient, randWrapper: randWrapper, - logWriter: logWriter, + logWriter: logWriter, } } diff --git a/cfmysql/cf_service_test.go b/cfmysql/cf_service_test.go index 60d02c9..18a4097 100644 --- a/cfmysql/cf_service_test.go +++ b/cfmysql/cf_service_test.go @@ -1,15 +1,15 @@ package cfmysql_test import ( - . "github.com/andreasf/cf-mysql-plugin/cfmysql" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/plugin/pluginfakes" - "code.cloudfoundry.org/cli/plugin/models" "code.cloudfoundry.org/cli/cf/errors" - "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/plugin/pluginfakes" + . "github.com/andreasf/cf-mysql-plugin/cfmysql" + "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" "github.com/andreasf/cf-mysql-plugin/cfmysql/models" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" ) diff --git a/cfmysql/http_client_factory.go b/cfmysql/http_client_factory.go index fdec21d..f9487d3 100644 --- a/cfmysql/http_client_factory.go +++ b/cfmysql/http_client_factory.go @@ -1,8 +1,8 @@ package cfmysql import ( - "net/http" "crypto/tls" + "net/http" ) //go:generate counterfeiter . HttpClientFactory @@ -14,11 +14,11 @@ func NewHttpClientFactory() HttpClientFactory { return new(httpClientFactory) } -type httpClientFactory struct {} +type httpClientFactory struct{} func (self *httpClientFactory) NewClient(sslDisabled bool) *http.Client { transport := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: sslDisabled}, } return &http.Client{Transport: transport} -} \ No newline at end of file +} diff --git a/cfmysql/http_wrapper.go b/cfmysql/http_wrapper.go index 9490a90..642f744 100644 --- a/cfmysql/http_wrapper.go +++ b/cfmysql/http_wrapper.go @@ -1,11 +1,11 @@ package cfmysql import ( + "code.cloudfoundry.org/cli/cf/net" "fmt" + "io" "io/ioutil" "net/http" - "io" - "code.cloudfoundry.org/cli/cf/net" ) //go:generate counterfeiter . HttpWrapper diff --git a/cfmysql/http_wrapper_test.go b/cfmysql/http_wrapper_test.go index 5f263d4..bf104bd 100644 --- a/cfmysql/http_wrapper_test.go +++ b/cfmysql/http_wrapper_test.go @@ -7,11 +7,11 @@ import ( "fmt" "net/http" - "github.com/andreasf/cf-mysql-plugin/cfmysql" - "github.com/onsi/gomega/ghttp" - "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" "bytes" "code.cloudfoundry.org/cli/cf/net/netfakes" + "github.com/andreasf/cf-mysql-plugin/cfmysql" + "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" + "github.com/onsi/gomega/ghttp" ) var _ = Describe("HttpWrapper", func() { diff --git a/cfmysql/models/models.go b/cfmysql/models/models.go index ae7a60c..bf412a7 100644 --- a/cfmysql/models/models.go +++ b/cfmysql/models/models.go @@ -1,27 +1,27 @@ package models type ServiceInstance struct { - Name string - Guid string + Name string + Guid string SpaceGuid string } type ServiceBinding struct { ServiceInstanceGuid string - Uri string - DbName string - Hostname string - Port string - Username string - Password string + Uri string + DbName string + Hostname string + Port string + Username string + Password string } type ServiceKey struct { ServiceInstanceGuid string - Uri string - DbName string - Hostname string - Port string - Username string - Password string -} \ No newline at end of file + Uri string + DbName string + Hostname string + Port string + Username string + Password string +} diff --git a/cfmysql/mysql_runner.go b/cfmysql/mysql_runner.go index 009409a..89051b4 100644 --- a/cfmysql/mysql_runner.go +++ b/cfmysql/mysql_runner.go @@ -1,11 +1,11 @@ package cfmysql import ( - "os/exec" - "strconv" "code.cloudfoundry.org/cli/cf/errors" "fmt" "os" + "os/exec" + "strconv" "strings" ) @@ -63,7 +63,7 @@ func (self *mysqlRunner) RunMysqlDump(hostname string, port int, dbName string, } tableArgs = append(tableArgs, argument) - nonTableArgs = mysqlDumpArgs[i + 1:] + nonTableArgs = mysqlDumpArgs[i+1:] } args := []string{"-u", username, "-p" + password, "-h", hostname, "-P", strconv.Itoa(port)} @@ -85,5 +85,5 @@ func (self *mysqlRunner) RunMysqlDump(hostname string, port int, dbName string, } func (self *mysqlRunner) MakeMysqlCommand(hostname string, port int, dbName string, username string, password string) *exec.Cmd { - return exec.Command("mysql", "-u", "username", "-p" + password, "-h", "hostname", "-P", strconv.Itoa(port), dbName) + return exec.Command("mysql", "-u", "username", "-p"+password, "-h", "hostname", "-P", strconv.Itoa(port), dbName) } diff --git a/cfmysql/mysql_runner_test.go b/cfmysql/mysql_runner_test.go index 3937dba..bebb673 100644 --- a/cfmysql/mysql_runner_test.go +++ b/cfmysql/mysql_runner_test.go @@ -3,10 +3,10 @@ package cfmysql_test import ( . "github.com/andreasf/cf-mysql-plugin/cfmysql" + "errors" + "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" - "errors" "os" ) diff --git a/cfmysql/net_wrapper.go b/cfmysql/net_wrapper.go index 9d63b8f..d26b6a2 100644 --- a/cfmysql/net_wrapper.go +++ b/cfmysql/net_wrapper.go @@ -12,7 +12,7 @@ func NewNetWrapper() NetWrapper { return new(netWrapper) } -type netWrapper struct {} +type netWrapper struct{} func (self *netWrapper) Dial(network, address string) (net.Conn, error) { return net.Dial(network, address) diff --git a/cfmysql/os_wrapper.go b/cfmysql/os_wrapper.go index 5c0ae44..a9bf398 100644 --- a/cfmysql/os_wrapper.go +++ b/cfmysql/os_wrapper.go @@ -11,8 +11,8 @@ func NewOsWrapper() OsWrapper { return new(osWrapper) } -type osWrapper struct {} +type osWrapper struct{} func (self *osWrapper) LookupEnv(key string) (string, bool) { return os.LookupEnv(key) -} \ No newline at end of file +} diff --git a/cfmysql/plugin.go b/cfmysql/plugin.go index 8f1d8fc..8e30a65 100644 --- a/cfmysql/plugin.go +++ b/cfmysql/plugin.go @@ -2,9 +2,9 @@ package cfmysql import ( "code.cloudfoundry.org/cli/plugin" - "io" - "fmt" "code.cloudfoundry.org/cli/plugin/models" + "fmt" + "io" ) type MysqlPlugin struct { diff --git a/cfmysql/plugin_test.go b/cfmysql/plugin_test.go index f388b55..41002f0 100644 --- a/cfmysql/plugin_test.go +++ b/cfmysql/plugin_test.go @@ -1,16 +1,16 @@ package cfmysql_test import ( + "code.cloudfoundry.org/cli/cf/errors" + "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/plugin/pluginfakes" + "fmt" . "github.com/andreasf/cf-mysql-plugin/cfmysql" + "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/plugin/pluginfakes" "github.com/onsi/gomega/gbytes" - "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" - "code.cloudfoundry.org/cli/plugin" - "fmt" - "code.cloudfoundry.org/cli/plugin/models" - "code.cloudfoundry.org/cli/cf/errors" ) var _ = Describe("Plugin", func() { diff --git a/cfmysql/port_finder.go b/cfmysql/port_finder.go index 16a4275..a90ea94 100644 --- a/cfmysql/port_finder.go +++ b/cfmysql/port_finder.go @@ -11,7 +11,7 @@ func NewPortFinder() PortFinder { return new(portFinder) } -type portFinder struct {} +type portFinder struct{} func (self *portFinder) GetPort() int { return freeport.GetPort() diff --git a/cfmysql/port_waiter.go b/cfmysql/port_waiter.go index 307f966..9684742 100644 --- a/cfmysql/port_waiter.go +++ b/cfmysql/port_waiter.go @@ -1,10 +1,10 @@ package cfmysql import ( - "time" - "strconv" "errors" "net" + "strconv" + "time" ) //go:generate counterfeiter . PortWaiter diff --git a/cfmysql/port_waiter_test.go b/cfmysql/port_waiter_test.go index d975e72..f73b0b8 100644 --- a/cfmysql/port_waiter_test.go +++ b/cfmysql/port_waiter_test.go @@ -3,12 +3,12 @@ package cfmysql_test import ( . "github.com/andreasf/cf-mysql-plugin/cfmysql" + "errors" + "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" + "github.com/andreasf/cf-mysql-plugin/cfmysql/netfakes" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" "net" - "errors" - "github.com/andreasf/cf-mysql-plugin/cfmysql/netfakes" ) var _ = Describe("PortWaiter", func() { @@ -18,7 +18,7 @@ var _ = Describe("PortWaiter", func() { const SucceedAfterTries = 5 dialCount := 0 mockDial := func(network, address string) (net.Conn, error) { - if dialCount < SucceedAfterTries- 1 { + if dialCount < SucceedAfterTries-1 { dialCount++ return nil, errors.New("GURU MEDITATION") } diff --git a/cfmysql/request_dumper.go b/cfmysql/request_dumper.go index de78502..e77217e 100644 --- a/cfmysql/request_dumper.go +++ b/cfmysql/request_dumper.go @@ -1,11 +1,11 @@ package cfmysql import ( + "code.cloudfoundry.org/cli/cf/i18n" "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/cf/trace" "io" "net/http" - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/trace" ) type conditionalRequestDumper struct { diff --git a/cfmysql/request_dumper_test.go b/cfmysql/request_dumper_test.go index b32bba9..b5ccff2 100644 --- a/cfmysql/request_dumper_test.go +++ b/cfmysql/request_dumper_test.go @@ -1,15 +1,15 @@ package cfmysql_test import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" + "code.cloudfoundry.org/cli/cf/terminal" "github.com/andreasf/cf-mysql-plugin/cfmysql" "github.com/andreasf/cf-mysql-plugin/cfmysql/cfmysqlfakes" - "net/http" - "regexp" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" - "code.cloudfoundry.org/cli/cf/terminal" + "net/http" "net/url" + "regexp" ) var _ = Describe("RequestDumper", func() { @@ -24,17 +24,17 @@ var _ = Describe("RequestDumper", func() { Expect(err).To(BeNil()) request = http.Request{ - Method: "BARK", - URL: url, - Proto: "HTTP/1.1", + Method: "BARK", + URL: url, + Proto: "HTTP/1.1", ProtoMajor: 1, ProtoMinor: 1, } response = http.Response{ - Status: "BORK", + Status: "BORK", StatusCode: 200, - Proto: "HTTP/1.1", + Proto: "HTTP/1.1", ProtoMajor: 1, ProtoMinor: 1, } @@ -109,4 +109,4 @@ func removeTimestampAndColors(requestOrResponse []byte) string { withoutTimestamp := string(re.ReplaceAll([]byte(withoutColors), []byte("[timestamp]"))) return withoutTimestamp -} \ No newline at end of file +} diff --git a/cfmysql/resources/resources.go b/cfmysql/resources/resources.go index 4217c0e..26d88af 100644 --- a/cfmysql/resources/resources.go +++ b/cfmysql/resources/resources.go @@ -3,10 +3,10 @@ package resources import ( "code.cloudfoundry.org/cli/cf/api/resources" "encoding/json" + "fmt" "github.com/andreasf/cf-mysql-plugin/cfmysql/models" - "strings" "strconv" - "fmt" + "strings" ) type ServiceBindingResource struct { @@ -21,9 +21,9 @@ type ServiceBindingEntity struct { } type MysqlCredentials struct { - Uri string `json:"uri"` - DbName string `json:"name"` - Hostname string `json:"hostname"` + Uri string `json:"uri"` + DbName string `json:"name"` + Hostname string `json:"hostname"` Port string RawPort json.RawMessage `json:"port"` Username string `json:"username"` diff --git a/cfmysql/resources/resources_test.go b/cfmysql/resources/resources_test.go index 17a6329..5635669 100644 --- a/cfmysql/resources/resources_test.go +++ b/cfmysql/resources/resources_test.go @@ -3,13 +3,13 @@ package resources_test import ( . "github.com/andreasf/cf-mysql-plugin/cfmysql/resources" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/andreasf/cf-mysql-plugin/cfmysql/test_resources" - "encoding/json" "code.cloudfoundry.org/cli/cf/api/resources" - "github.com/andreasf/cf-mysql-plugin/cfmysql/models" + "encoding/json" "errors" + "github.com/andreasf/cf-mysql-plugin/cfmysql/models" + "github.com/andreasf/cf-mysql-plugin/cfmysql/test_resources" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" ) var _ = Describe("Resources", func() { diff --git a/cfmysql/ssh_runner.go b/cfmysql/ssh_runner.go index e3c73dc..185003b 100644 --- a/cfmysql/ssh_runner.go +++ b/cfmysql/ssh_runner.go @@ -2,8 +2,8 @@ package cfmysql import ( "code.cloudfoundry.org/cli/plugin" - "strconv" "fmt" + "strconv" ) //go:generate counterfeiter . SshRunner diff --git a/cfmysql/ssh_runner_test.go b/cfmysql/ssh_runner_test.go index 27c0da1..989e35b 100644 --- a/cfmysql/ssh_runner_test.go +++ b/cfmysql/ssh_runner_test.go @@ -1,21 +1,21 @@ package cfmysql_test import ( + "code.cloudfoundry.org/cli/plugin/pluginfakes" + "errors" . "github.com/andreasf/cf-mysql-plugin/cfmysql" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/plugin/pluginfakes" - "errors" ) var _ = Describe("SshRunner", func() { var cliConnection *pluginfakes.FakeCliConnection var sshRunner SshRunner service := MysqlService{ - Name: "database-a", + Name: "database-a", Hostname: "database-a.host", - Port: "3306", - DbName: "dbname-a", + Port: "3306", + DbName: "dbname-a", Username: "username-a", Password: "password-a", } diff --git a/main.go b/main.go index 37b2aa6..39bdb68 100644 --- a/main.go +++ b/main.go @@ -2,9 +2,9 @@ package main import ( "code.cloudfoundry.org/cli/plugin" + "fmt" "github.com/andreasf/cf-mysql-plugin/cfmysql" "os" - "fmt" ) func main() {