From a295b920edd236e405f14ce8ae01ddeb899f8b57 Mon Sep 17 00:00:00 2001 From: Vladimir Garvardt Date: Wed, 25 Mar 2020 13:53:13 +0100 Subject: [PATCH] Update packages and fix code issues --- .gitignore | 1 + .travis.yml | 21 +++++++------- Makefile | 19 +++++++++++-- build/test.sh | 50 --------------------------------- cmd/init.go | 20 +++++++++---- cmd/root.go | 25 ++++++----------- cmd/steal.go | 29 ++++++++++++++----- cmd/update.go | 18 ++++++++---- features/mysql_test.go | 6 ++-- features/postgres_test.go | 6 ++-- go.mod | 7 ++--- go.sum | 25 ++++++----------- main.go | 6 ++-- pkg/reader/postgres/postgres.go | 2 +- pkg/reader/postgres/reader.go | 2 +- 15 files changed, 106 insertions(+), 131 deletions(-) delete mode 100755 build/test.sh diff --git a/.gitignore b/.gitignore index 66507f0..b61ff7e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ klepto /dist debug .klepto.toml +coverage.txt # Vendor stuff .glide/ diff --git a/.travis.yml b/.travis.yml index 7c5d1ba..22153b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,9 @@ sudo: required language: go go: - - 1.13.x + - "1.13" + - "1.14" + - "stable" services: - mysql @@ -16,9 +18,9 @@ env: TEST_MYSQL="root@tcp(localhost:3306)/" install: - - mkdir -p $GOPATH/bin - - go get github.com/go-playground/overalls - - go get github.com/goreleaser/goreleaser + - go get -u github.com/go-playground/overalls + - go get -u github.com/goreleaser/goreleaser + - make deps script: - make test @@ -29,9 +31,8 @@ after_success: # calls goreleaser deploy: -- provider: script - skip_cleanup: true - script: curl -sL http://git.io/goreleaser | bash - on: - tags: true - + - provider: script + skip_cleanup: true + script: curl -sL http://git.io/goreleaser | bash + on: + tags: true diff --git a/Makefile b/Makefile index c482060..a6bb17a 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ all: clean deps build deps: @echo "$(OK_COLOR)==> Installing dependencies$(NO_COLOR)" - @go get github.com/goreleaser/goreleaser + @go get -u golang.org/x/lint/golint @go mod vendor # Builds the project @@ -20,8 +20,21 @@ build: @echo "$(OK_COLOR)==> Building... $(NO_COLOR)" @goreleaser --snapshot --rm-dist --skip-validate -test: - @/bin/sh -c "./build/test.sh $(allpackages)" +test: lint format vet + @echo "$(OK_COLOR)==> Running tests$(NO_COLOR)" + @CGO_ENABLED=0 go test -cover ./... -coverprofile=coverage.txt -covermode=atomic + +lint: + @echo "$(OK_COLOR)==> Checking code style with 'golint' tool$(NO_COLOR)" + @go list ./... | xargs -n 1 golint -set_exit_status + +format: + @echo "$(OK_COLOR)==> Checking code formating with 'gofmt' tool$(NO_COLOR)" + @gofmt -l -s cmd pkg | grep ".*\.go"; if [ "$$?" = "0" ]; then exit 1; fi + +vet: + @echo "$(OK_COLOR)==> Checking code correctness with 'go vet' tool$(NO_COLOR)" + @go vet ./... test-docker: docker-compose up -d diff --git a/build/test.sh b/build/test.sh deleted file mode 100755 index 799f271..0000000 --- a/build/test.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -# -# Copyright 2016 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -export CGO_ENABLED=1 -NO_COLOR='\033[0m' -OK_COLOR='\033[32;01m' -ERROR_COLOR='\033[31;01m' -WARN_COLOR='\033[33;01m' -PASS="${OK_COLOR}PASS ${NO_COLOR}" -FAIL="${ERROR_COLOR}FAIL ${NO_COLOR}" - -TARGETS=$@ - -echo "${OK_COLOR}Running tests: ${NO_COLOR}" -go test -v -race -cover -covermode=atomic ${TARGETS} - -echo "${OK_COLOR}Formatting: ${NO_COLOR}" -ERRS=$(find cmd pkg -type f -name \*.go | xargs gofmt -l 2>&1 || true) -if [ -n "${ERRS}" ]; then - echo "${ERROR_COLOR}FAIL - the following files need to be gofmt'ed: ${NO_COLOR}" - for e in ${ERRS}; do - echo " $e" - done - exit 1 -fi -echo ${PASS} - -echo "${OK_COLOR}Vetting: ${NO_COLOR}" -ERRS=$(go vet ${TARGETS} 2>&1 || true) -if [ -n "${ERRS}" ]; then - echo ${FAIL} - echo "${ERRS}" - exit 1 -fi -echo ${PASS} diff --git a/cmd/init.go b/cmd/init.go index 198358e..eea773a 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -5,9 +5,11 @@ import ( "os" "github.com/BurntSushi/toml" - "github.com/hellofresh/klepto/pkg/config" + wErrors "github.com/pkg/errors" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" + + "github.com/hellofresh/klepto/pkg/config" ) // NewInitCmd creates a new init command @@ -15,8 +17,8 @@ func NewInitCmd() *cobra.Command { cmd := &cobra.Command{ Use: "init", Short: "Create a fresh config file", - Run: func(cmd *cobra.Command, args []string) { - RunInit() + RunE: func(cmd *cobra.Command, args []string) error { + return RunInit() }, } @@ -24,7 +26,7 @@ func NewInitCmd() *cobra.Command { } // RunInit runs the init command -func RunInit() { +func RunInit() error { log.Infof("Initializing %s", configFileName) _, err := os.Stat(configFileName) @@ -33,7 +35,9 @@ func RunInit() { } f, err := os.Create(configFileName) - failOnError(err, "Could not create the file") + if err != nil { + return wErrors.Wrap(err, "could not create file") + } e := toml.NewEncoder(bufio.NewWriter(f)) err = e.Encode(config.Spec{ @@ -67,7 +71,11 @@ func RunInit() { }, }, }) - failOnError(err, "Could not encode config") + if err != nil { + return wErrors.Wrap(err, "could not encode config") + } log.Infof("Created %s!", configFileName) + + return nil } diff --git a/cmd/root.go b/cmd/root.go index 189fe70..eb21bc5 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -5,7 +5,7 @@ import ( "github.com/hellofresh/klepto/pkg/config" "github.com/hellofresh/klepto/pkg/formatter" - "github.com/pkg/errors" + wErrors "github.com/pkg/errors" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -55,32 +55,25 @@ func initConfig(c *cobra.Command, args []string) error { // Use config file from the flag. viper.SetConfigFile(configFile) } else { + cwd, err := os.Getwd() + if err != nil { + return wErrors.Wrap(err, "can't find current working directory") + } + viper.SetConfigName(".klepto") - viper.AddConfigPath(workingDir()) + viper.AddConfigPath(cwd) viper.AddConfigPath(".") } err := viper.ReadInConfig() if err != nil { - return errors.Wrap(err, "Could not read configurations") + return wErrors.Wrap(err, "could not read configurations") } err = viper.Unmarshal(&globalConfig) if err != nil { - return errors.Wrap(err, "Could not unmarshal config file") + return wErrors.Wrap(err, "could not unmarshal config file") } return nil } -func workingDir() string { - cwd, err := os.Getwd() - failOnError(err, "Can't find the working directory") - - return cwd -} - -func failOnError(err error, message string) { - if err != nil { - log.WithError(err).Fatal(message) - } -} diff --git a/cmd/steal.go b/cmd/steal.go index 636beda..4e8c378 100644 --- a/cmd/steal.go +++ b/cmd/steal.go @@ -7,6 +7,7 @@ import ( "github.com/hellofresh/klepto/pkg/anonymiser" "github.com/hellofresh/klepto/pkg/dumper" "github.com/hellofresh/klepto/pkg/reader" + wErrors "github.com/pkg/errors" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -64,16 +65,24 @@ func NewStealCmd() *cobra.Command { // RunSteal is the handler for the rootCmd. func RunSteal(opts *StealOptions) (err error) { readTimeout, err := time.ParseDuration(opts.readOpts.timeout) - failOnError(err, "Failed to parse read timeout duration") + if err != nil { + return wErrors.Wrap(err, "Failed to parse read timeout duration") + } writeTimeout, err := time.ParseDuration(opts.readOpts.timeout) - failOnError(err, "Failed to parse write timeout duration") + if err != nil { + return wErrors.Wrap(err, "Failed to parse write timeout duration") + } readMaxConnLifetime, err := time.ParseDuration(opts.readOpts.maxConnLifetime) - failOnError(err, "Failed to parse the timeout duration") + if err != nil { + return wErrors.Wrap(err, "Failed to parse write timeout duration") + } writeMaxConnLifetime, err := time.ParseDuration(opts.writeOpts.maxConnLifetime) - failOnError(err, "Failed to parse the timeout duration") + if err != nil { + return wErrors.Wrap(err, "Failed to parse the timeout duration") + } source, err := reader.Connect(reader.ConnOpts{ DSN: opts.from, @@ -82,7 +91,9 @@ func RunSteal(opts *StealOptions) (err error) { MaxConns: opts.readOpts.maxConns, MaxIdleConns: opts.readOpts.maxIdleConns, }) - failOnError(err, "Error connecting to reader") + if err != nil { + return wErrors.Wrap(err, "Could not connecting to reader") + } defer source.Close() source = anonymiser.NewAnonymiser(source, globalConfig.Tables) @@ -93,7 +104,9 @@ func RunSteal(opts *StealOptions) (err error) { MaxConns: opts.writeOpts.maxConns, MaxIdleConns: opts.writeOpts.maxIdleConns, }, source) - failOnError(err, "Error creating dumper") + if err != nil { + return wErrors.Wrap(err, "Error creating dumper") + } defer target.Close() log.Info("Stealing...") @@ -101,7 +114,9 @@ func RunSteal(opts *StealOptions) (err error) { done := make(chan struct{}) defer close(done) start := time.Now() - failOnError(target.Dump(done, globalConfig, opts.concurrency), "Error while dumping") + if err := target.Dump(done, globalConfig, opts.concurrency); err != nil { + return wErrors.Wrap(err, "Error while dumping") + } <-done log.WithField("total_time", time.Since(start)).Info("Done!") diff --git a/cmd/update.go b/cmd/update.go index c6c24f6..c358920 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -8,6 +8,7 @@ import ( "github.com/hellofresh/updater-go" "github.com/palantir/stacktrace" + wErrors "github.com/pkg/errors" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -31,8 +32,8 @@ func NewUpdateCmd() *cobra.Command { Use: "update", Aliases: []string{"self-update"}, Short: "Check for new versions of kepto", - Run: func(cmd *cobra.Command, args []string) { - RunUpdate(opts) + RunE: func(cmd *cobra.Command, args []string) error { + return RunUpdate(opts) }, } @@ -44,7 +45,7 @@ func NewUpdateCmd() *cobra.Command { } // RunUpdate runs the update command -func RunUpdate(opts *UpdateOptions) { +func RunUpdate(opts *UpdateOptions) error { log.Info("Checking for new versions of Klepto!") if opts.token == "" { @@ -69,19 +70,24 @@ func RunUpdate(opts *UpdateOptions) { // fatal exits with code 1 log.Fatal("Unable to access the Klepto! repository.") } - failOnError(err, "failed to retrieve the update release") + if err != nil { + return wErrors.Wrap(err, "failed to retrieve the update release") + } if updateTo.Name != version { // Fetch the release and update if !opts.dryRun { - err = updater.SelfUpdate(updateTo) - failOnError(err, "failed to update to version %s") + if err := updater.SelfUpdate(updateTo); err != nil { + return wErrors.Wrapf(err, "failed to update to version %s", updateTo.Name) + } } log.Infof("Klepto! updated to version %s", updateTo.Name) } else { log.Infof("No updates available for your version %s", version) } + + return nil } func newReleaseLocator(token string, filter updater.ReleaseFilter) updater.ReleaseLocator { diff --git a/features/mysql_test.go b/features/mysql_test.go index a195621..ba75b99 100644 --- a/features/mysql_test.go +++ b/features/mysql_test.go @@ -86,10 +86,10 @@ func (s *MysqlTestSuite) createDatabase(name string) string { _, err := s.rootConnection.Exec(fmt.Sprintf("CREATE DATABASE %s", name)) s.Require().NoError(err, "Unable to create db") - dbUrl, _ := mysql.ParseDSN(s.rootDSN) - dbUrl.DBName = name + dbURL, _ := mysql.ParseDSN(s.rootDSN) + dbURL.DBName = name - return dbUrl.FormatDSN() + return dbURL.FormatDSN() } func (s *MysqlTestSuite) dropDatabase(name string) { diff --git a/features/postgres_test.go b/features/postgres_test.go index dc22905..7a03277 100644 --- a/features/postgres_test.go +++ b/features/postgres_test.go @@ -92,9 +92,9 @@ func (s *PostgresTestSuite) createDatabase(name string) string { _, err := s.rootConnection.Exec(fmt.Sprintf("CREATE DATABASE %s", name)) s.Require().NoError(err, "Unable to create db") - dbUrl, _ := url.Parse(s.rootDSN) - dbUrl.Path = name - return dbUrl.String() + dbURL, _ := url.Parse(s.rootDSN) + dbURL.Path = name + return dbURL.String() } func (s *PostgresTestSuite) dropDatabase(name string) { diff --git a/go.mod b/go.mod index d4dd37f..5a64172 100644 --- a/go.mod +++ b/go.mod @@ -17,19 +17,18 @@ require ( github.com/pelletier/go-toml v1.6.0 // indirect github.com/pkg/errors v0.9.1 github.com/shurcooL/githubv4 v0.0.0-20191127044304-8f68eb5628d0 // indirect - github.com/shurcooL/go v0.0.0-20191216061654-b114cc39af9f // indirect github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f // indirect - github.com/sirupsen/logrus v1.4.2 + github.com/sirupsen/logrus v1.5.0 github.com/spf13/afero v1.2.2 // indirect github.com/spf13/cast v1.3.1 // indirect github.com/spf13/cobra v0.0.5 github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.6.2 - github.com/stretchr/testify v1.4.0 + github.com/stretchr/testify v1.5.1 golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa // indirect golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect - golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 // indirect + golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd // indirect google.golang.org/appengine v1.6.5 // indirect gopkg.in/ini.v1 v1.51.1 // indirect gopkg.in/yaml.v2 v2.2.8 // indirect diff --git a/go.sum b/go.sum index 6bbac4d..1be43ca 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,6 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hellofresh/updater-go v1.0.1 h1:oDVcKxwaW1P6vgaqyhbg5plphqAF3vPfhXoR5apYzUo= github.com/hellofresh/updater-go v1.0.1/go.mod h1:6swO4b2TNhQvluGAHT0M8nCXXlYCUeVBm75Lr5AxmDU= -github.com/icrowley/fake v0.0.0-20170723151011-e64cc2cf9204 h1:sDfxvavYvmIoUCpISbdKtnvT78guOnbmEOW8KrwPMK0= -github.com/icrowley/fake v0.0.0-20170723151011-e64cc2cf9204/go.mod h1:uhpZMVGznybq1itEKXj6RYw9I71qK4kH+OGMjRC4KEo= github.com/icrowley/fake v0.0.0-20180203215853-4178557ae428 h1:Mo9W14pwbO9VfRe+ygqZ8dFbPpoIK1HFrG/zjTuQ+nc= github.com/icrowley/fake v0.0.0-20180203215853-4178557ae428/go.mod h1:uhpZMVGznybq1itEKXj6RYw9I71qK4kH+OGMjRC4KEo= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= @@ -121,20 +119,13 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/shurcooL/githubv4 v0.0.0-20180509030948-19298c78142b h1:rvtz1nqABF64h0VCWseq6aiR4i1eAnbU9Zd3am6JpC0= -github.com/shurcooL/githubv4 v0.0.0-20180509030948-19298c78142b/go.mod h1:hAF0iLZy4td2EX+/8Tw+4nodhlMrwN3HupfaXj3zkGo= github.com/shurcooL/githubv4 v0.0.0-20191127044304-8f68eb5628d0 h1:T9uus1QvcPgeLShS30YOnnzk3r9Vvygp45muhlrufgY= github.com/shurcooL/githubv4 v0.0.0-20191127044304-8f68eb5628d0/go.mod h1:hAF0iLZy4td2EX+/8Tw+4nodhlMrwN3HupfaXj3zkGo= -github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e h1:MZM7FHLqUHYI0Y/mQAt3d2aYa0SiNms/hFqC9qJYolM= -github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= -github.com/shurcooL/go v0.0.0-20191216061654-b114cc39af9f/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= -github.com/shurcooL/graphql v0.0.0-20180514000029-62c9ce094e75 h1:tm3k/UttRKDcrwI1BWe3Vvhjsb2FKmT+z5UDtyNVZ88= -github.com/shurcooL/graphql v0.0.0-20180514000029-62c9ce094e75/go.mod h1:AuYgA5Kyo4c7HfUmvRGs/6rGlMMV/6B1bVnB9JxJEEg= github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f h1:tygelZueB1EtXkPI6mQ4o9DQ0+FKW41hTbunoXZCTqk= github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f/go.mod h1:AuYgA5Kyo4c7HfUmvRGs/6rGlMMV/6B1bVnB9JxJEEg= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q= +github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= @@ -145,6 +136,7 @@ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= @@ -158,11 +150,12 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.6.2 h1:7aKfF+e8/k68gda3LOjo5RxiUqddoFxVq4BKBPrxk5E= github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -204,11 +197,9 @@ golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSfrPzImPoVxuomtbT2nk= -golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20171218113626-eb22672bea55 h1:ZCyNx6yst4X06K4ncRrHu773b1ADJ0EePv3NGG3vwFw= -golang.org/x/text v0.3.1-0.20171218113626-eb22672bea55/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/main.go b/main.go index 082da89..927c177 100644 --- a/main.go +++ b/main.go @@ -1,15 +1,13 @@ package main import ( - "fmt" - "os" + "log" "github.com/hellofresh/klepto/cmd" ) func main() { if err := cmd.RootCmd.Execute(); err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } } diff --git a/pkg/reader/postgres/postgres.go b/pkg/reader/postgres/postgres.go index a26958b..a8303ef 100644 --- a/pkg/reader/postgres/postgres.go +++ b/pkg/reader/postgres/postgres.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/hellofresh/klepto/pkg/reader" - _ "github.com/lib/pq" + _ "github.com/lib/pq" // import postgres driver ) type driver struct{} diff --git a/pkg/reader/postgres/reader.go b/pkg/reader/postgres/reader.go index 1952ead..7bc4131 100644 --- a/pkg/reader/postgres/reader.go +++ b/pkg/reader/postgres/reader.go @@ -17,7 +17,7 @@ type ( conn *sql.DB } - // PgDump executes the pg dump command. + // PgDumper executes the pg dump command. PgDumper interface { GetStructure() (stmt string, err error) }