mirror of
https://github.com/foomo/posh-providers.git
synced 2025-10-16 12:35:41 +00:00
fix(postgres): dbname docu and add create
This commit is contained in:
parent
d2b995ad1f
commit
d5ca6cf67e
3
go.mod
3
go.mod
@ -13,7 +13,7 @@ require (
|
||||
github.com/cloudrecipes/packagejson v1.0.0
|
||||
github.com/digitalocean/godo v1.142.0
|
||||
github.com/foomo/go v0.0.3
|
||||
github.com/foomo/gokazi v0.1.4
|
||||
github.com/foomo/gokazi v0.1.5
|
||||
github.com/foomo/posh v0.12.0
|
||||
github.com/goccy/go-json v0.10.5
|
||||
github.com/golang-migrate/migrate/v4 v4.18.2
|
||||
@ -31,6 +31,7 @@ require (
|
||||
github.com/shirou/gopsutil/v3 v3.24.5
|
||||
github.com/slack-go/slack v0.16.0
|
||||
github.com/spf13/viper v1.20.1
|
||||
github.com/stoewer/go-strcase v1.3.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
go.uber.org/zap v1.27.0
|
||||
golang.org/x/oauth2 v0.29.0
|
||||
|
||||
8
go.sum
8
go.sum
@ -52,6 +52,7 @@ github.com/foomo/go v0.0.3 h1:5pGzcPC78dImuBTT7nsZZnH+GIQUylbCtMkFEH26uZk=
|
||||
github.com/foomo/go v0.0.3/go.mod h1:x6g64wiQusqaFElnh5rlk9unCgLKmfUWy0YFLejJxio=
|
||||
github.com/foomo/gokazi v0.1.4 h1:ULVtNmWbwBgoYe4FMN6V7lMgXPLj1c3Ftby+w7EjeMg=
|
||||
github.com/foomo/gokazi v0.1.4/go.mod h1:2aLwoCPC2ecwtqU/67qGWoYn7UcZwgCbSdrimVbF7Zc=
|
||||
github.com/foomo/gokazi v0.1.5/go.mod h1:2aLwoCPC2ecwtqU/67qGWoYn7UcZwgCbSdrimVbF7Zc=
|
||||
github.com/foomo/posh v0.12.0 h1:A0rWQv33ZxUBI5uTbfgLnHtdRKzu8o7NN/nQI2QKsVg=
|
||||
github.com/foomo/posh v0.12.0/go.mod h1:h6Pq7wiEAU1+arsWp5v6VZWNzVEvmXI2MkkYKbFi6gE=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
@ -214,7 +215,11 @@ github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4=
|
||||
github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
|
||||
github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs=
|
||||
github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
@ -222,6 +227,9 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||
|
||||
@ -52,7 +52,7 @@ func NewCommand(l log.Logger, opts ...CommandOption) *Command {
|
||||
connectionFlags := func(fs *readline.FlagSets) {
|
||||
fs.Default().String("port", "", "database server port number")
|
||||
fs.Default().String("host", "", "database server host or socket directory")
|
||||
fs.Default().String("dbname", "", "database to dump")
|
||||
fs.Default().String("dbname", "", "connect to database name")
|
||||
fs.Default().String("username", "", "connect as specified database user")
|
||||
}
|
||||
|
||||
@ -133,6 +133,7 @@ func NewCommand(l log.Logger, opts ...CommandOption) *Command {
|
||||
// Options controlling the output content:
|
||||
fs.Default().Bool("data-only", false, "restore only the data, no schema")
|
||||
fs.Default().Bool("clean", false, "clean (drop) database objects before recreating")
|
||||
fs.Default().Bool("create", false, "create the target database")
|
||||
fs.Default().Bool("exit-on-error", false, "exit on error, default is to continue")
|
||||
fs.Default().Bool("schema-only", false, "restore only the schema, no data")
|
||||
fs.Default().Bool("no-owner", false, "skip restoration of object ownership")
|
||||
@ -229,6 +230,7 @@ func (c *Command) dump(ctx context.Context, r *readline.Readline) error {
|
||||
filename += ".sql"
|
||||
}
|
||||
|
||||
c.l.Info("Creating database dump: " + filename)
|
||||
if out, err := shell.New(ctx, c.l, "pg_dump").
|
||||
Args(fs.Visited().Args()...).
|
||||
Args(r.AdditionalFlags()...).
|
||||
@ -240,12 +242,14 @@ func (c *Command) dump(ctx context.Context, r *readline.Readline) error {
|
||||
}
|
||||
|
||||
if log.MustGet(ifs.GetBool("zip"))(c.l) {
|
||||
c.l.Info("Compressing database dump...")
|
||||
if err := c.zip.Create(ctx, filename); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if cred := log.MustGet(ifs.GetString("zip-cred"))(c.l); cred != "" {
|
||||
c.l.Info("Securing database dump...")
|
||||
if err := c.zip.CreateWithPassword(ctx, filename, cred); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -258,6 +262,7 @@ func (c *Command) restore(ctx context.Context, r *readline.Readline) error {
|
||||
flags := r.Flags()
|
||||
filename := r.Args().At(1)
|
||||
|
||||
c.l.Info("Restoring database dump: " + filename)
|
||||
if out, err := shell.New(ctx, c.l, "pg_restore").
|
||||
Args(flags...).
|
||||
Args(r.AdditionalFlags()...).
|
||||
|
||||
Loading…
Reference in New Issue
Block a user