Skip to content

Commit

Permalink
feat: Revised supported console utils supported params
Browse files Browse the repository at this point in the history
  • Loading branch information
wwoytenko committed Dec 7, 2024
1 parent 73bd76e commit ba8405d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
7 changes: 2 additions & 5 deletions cmd/greenmask/cmd/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ var (
// TODO: Check how does work mixed options - use-list + tables, etc.
// TODO: Options currently are not implemented:
// - encoding
// - disable-triggers
// - lock-wait-timeout
// - no-sync
// - data-only
Expand Down Expand Up @@ -104,7 +103,6 @@ func init() {
)
Cmd.Flags().BoolP("no-owner", "O", false, "skip restoration of object ownership in plain-text format")
Cmd.Flags().BoolP("schema-only", "s", false, "dump only the schema, no data")
Cmd.Flags().StringP("superuser", "S", "", "superuser user name to use in plain-text format")
Cmd.Flags().StringSliceVarP(
&Config.Dump.PgDumpOptions.Table, "table", "t", []string{}, "dump the specified table(s) only",
)
Expand All @@ -113,7 +111,6 @@ func init() {
)
Cmd.Flags().BoolP("no-privileges", "X", false, "do not dump privileges (grant/revoke)")
Cmd.Flags().BoolP("disable-dollar-quoting", "", false, "disable dollar quoting, use SQL standard quoting")
Cmd.Flags().BoolP("disable-triggers", "", false, "disable triggers during data-only restore")
Cmd.Flags().BoolP(
"enable-row-security", "", false, "enable row security (dump only content user has access to)",
)
Expand Down Expand Up @@ -163,8 +160,8 @@ func init() {
"file", "jobs", "verbose", "compress", "dbname", "host", "username", "lock-wait-timeout", "no-sync",

"data-only", "blobs", "no-blobs", "clean", "create", "extension", "encoding", "schema", "exclude-schema",
"no-owner", "schema-only", "superuser", "table", "exclude-table", "no-privileges", "disable-dollar-quoting",
"disable-triggers", "enable-row-security", "exclude-table-data", "extra-float-digits", "if-exists",
"no-owner", "schema-only", "table", "exclude-table", "no-privileges", "disable-dollar-quoting",
"enable-row-security", "exclude-table-data", "extra-float-digits", "if-exists",
"include-foreign-data", "load-via-partition-root", "no-comments", "no-publications", "no-security-labels",
"no-subscriptions", "no-synchronized-snapshots", "no-tablespaces", "no-toast-compression",
"no-unlogged-table-data", "quote-all-identifiers", "section",
Expand Down
13 changes: 9 additions & 4 deletions cmd/greenmask/cmd/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,11 @@ func init() {
Cmd.Flags().BoolP("no-owner", "O", false, "skip restoration of object ownership")
Cmd.Flags().StringSliceVarP(&Config.Restore.PgRestoreOptions.Function, "function", "P", []string{}, "restore named function")
Cmd.Flags().BoolP("schema-only", "s", false, "restore only the schema, no data")
Cmd.Flags().StringP("superuser", "S", "", "superuser user name to use for disabling triggers")
Cmd.Flags().StringSliceVarP(&Config.Restore.PgRestoreOptions.Table, "table", "t", []string{}, "restore named relation (table, view, etc.)")
Cmd.Flags().StringSliceVarP(&Config.Restore.PgRestoreOptions.Trigger, "trigger", "T", []string{}, "restore named trigger")
Cmd.Flags().BoolP("no-privileges", "X", false, "skip restoration of access privileges (grant/revoke)")
Cmd.Flags().BoolP("single-transaction", "1", false, "restore as a single transaction")
Cmd.Flags().BoolP("disable-triggers", "", false, "disable triggers during data-only restore")
Cmd.Flags().BoolP("disable-triggers", "", false, "disable triggers during data section restore")
Cmd.Flags().BoolP("enable-row-security", "", false, "enable row security")
Cmd.Flags().BoolP("if-exists", "", false, "use IF EXISTS when dropping objects")
Cmd.Flags().BoolP("no-comments", "", false, "do not restore comments")
Expand All @@ -169,6 +168,12 @@ func init() {
Cmd.Flags().BoolP("strict-names", "", false, "restore named section (pre-data, data, or post-data) match at least one entity each")
Cmd.Flags().BoolP("use-set-session-authorization", "", false, "use SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to set ownership")
Cmd.Flags().BoolP("on-conflict-do-nothing", "", false, "add ON CONFLICT DO NOTHING to INSERT commands")
Cmd.Flags().StringP("superuser", "S", "", "superuser user name to use for disabling triggers")
Cmd.Flags().BoolP(
"use-session-replication-role-replica", "", false,
"use SET session_replication_role = 'replica' to disable triggers during data section restore"+
" (alternative for --disable-triggers)",
)
Cmd.Flags().BoolP("inserts", "", false, "restore data as INSERT commands, rather than COPY")
Cmd.Flags().BoolP("restore-in-order", "", false, "restore tables in topological order, ensuring that dependent tables are not restored until the tables they depend on have been restored")
Cmd.Flags().BoolP(
Expand All @@ -193,11 +198,11 @@ func init() {
"dbname", "file", "verbose",

"data-only", "clean", "create", "exit-on-error", "jobs", "list-format", "use-list", "schema", "exclude-schema",
"no-owner", "function", "schema-only", "superuser", "table", "trigger", "no-privileges", "single-transaction",
"no-owner", "function", "schema-only", "table", "trigger", "no-privileges", "single-transaction",
"disable-triggers", "enable-row-security", "if-exists", "no-comments", "no-data-for-failed-tables",
"no-security-labels", "no-subscriptions", "no-table-access-method", "no-tablespaces", "section",
"strict-names", "use-set-session-authorization", "inserts", "on-conflict-do-nothing", "restore-in-order",
"pgzip", "batch-size", "overriding-system-value",
"pgzip", "batch-size", "overriding-system-value", "disable-triggers", "superuser", "use-session-replication-role-replica",

"host", "port", "username",
} {
Expand Down
22 changes: 8 additions & 14 deletions internal/db/postgres/pgdump/pgdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ type Options struct {
ExcludeSchema []string `mapstructure:"exclude-schema"`
NoOwner bool `mapstructure:"no-owner"`
SchemaOnly bool `mapstructure:"schema-only"`
SuperUser string `mapstructure:"superuser"`
Table []string `mapstructure:"table"`
ExcludeTable []string `mapstructure:"exclude-table"`
NoPrivileges bool `mapstructure:"no-privileges"`
DisableDollarQuoting bool `mapstructure:"disable-dollar-quoting"`
DisableTriggers bool `mapstructure:"disable-triggers"`
EnableRowSecurity bool `mapstructure:"enable-row-security"`
ExcludeTableData []string `mapstructure:"exclude-table-data"`
ExtraFloatDigits string `mapstructure:"extra-float-digits"`
Expand Down Expand Up @@ -149,7 +147,8 @@ func (o *Options) GetParams() []string {
args = append(args, "--verbose")
}
if o.Compression != -1 {
args = append(args, "--compress", strconv.FormatInt(int64(o.Compression), 10))
panic("FIXME: --compress is not implemented")
//args = append(args, "--compress", strconv.FormatInt(int64(o.Compression), 10))
}
if o.LockWaitTimeout != -1 {
args = append(args, "--lock-wait-timeout", strconv.FormatInt(int64(o.Compression), 10))
Expand All @@ -163,10 +162,12 @@ func (o *Options) GetParams() []string {
args = append(args, "--data-only")
}
if o.Blobs {
args = append(args, "--blobs")
panic("FIXME: --blobs is not implemented")
//args = append(args, "--blobs")
}
if o.NoBlobs {
args = append(args, "--no-blobs")
panic("FIXME: --no-blobs is not implemented")
//args = append(args, "--no-blobs")
}
if o.Clean {
args = append(args, "--clean")
Expand Down Expand Up @@ -198,9 +199,6 @@ func (o *Options) GetParams() []string {
if o.SchemaOnly {
args = append(args, "--schema-only")
}
if o.SuperUser != "" {
args = append(args, "--superuser", o.SuperUser)
}
if len(o.Table) > 0 {
for _, item := range o.Table {
args = append(args, "--table", item)
Expand All @@ -217,14 +215,10 @@ func (o *Options) GetParams() []string {
if o.DisableDollarQuoting {
args = append(args, "--disable-dollar-quoting")
}
if o.DisableTriggers {
//args = append(args, "--disable-triggers")
panic("FIXME: --disable-triggers is not implemented")
}
if o.EnableRowSecurity {
// TODO: Seems that this options affects COPY
log.Warn().Msgf("FIXME: Seems that this options affects COPY and is not implemented")
args = append(args, "--enable-row-security")
panic("FIXME: --enable-row-security is not implemented")
//args = append(args, "--enable-row-security")
}
if len(o.ExcludeTableData) > 0 {
for _, item := range o.ExcludeTableData {
Expand Down

0 comments on commit ba8405d

Please sign in to comment.