diff --git a/Makefile b/Makefile index b9268fef..b61f2d5a 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CMD_FILES = $(wildcard *.go) TEST_FILES = $(wildcard *.go) COVERAGE_FILE := coverage.out VERSION ?= $(shell git tag --points-at HEAD) -LDFLAGS ?= -X main.version=$(VERSION) +LDFLAGS ?= -X github.com/greenmaskio/greenmask/cmd/greenmask/cmd.Version=$(VERSION) .PHONY: build diff --git a/cmd/greenmask/main.go b/cmd/greenmask/main.go index 4afb8991..21fb64b2 100644 --- a/cmd/greenmask/main.go +++ b/cmd/greenmask/main.go @@ -20,10 +20,7 @@ import ( "github.com/greenmaskio/greenmask/cmd/greenmask/cmd" ) -var version string - func main() { - cmd.Version = version if err := cmd.Execute(); err != nil { log.Fatal().Err(err).Msg("") } diff --git a/internal/db/postgres/pgdump/pgdump.go b/internal/db/postgres/pgdump/pgdump.go index 817dd9eb..d511c3e5 100644 --- a/internal/db/postgres/pgdump/pgdump.go +++ b/internal/db/postgres/pgdump/pgdump.go @@ -104,10 +104,11 @@ type Options struct { } func (o *Options) GetPgDSN() (string, error) { - //return "host=localhost port=5432 user=postgres dbname=postgres", nil - if strings.Contains(o.DbName, "=") { + // URI or Standard format + if strings.HasPrefix(o.DbName, "postgresql://") || strings.Contains(o.DbName, "=") { return o.DbName, nil } + return fmt.Sprintf("host=%s port=%d user=%s dbname=%s", o.Host, o.Port, o.UserName, o.DbName), nil }