A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/orgrim/pg_back/commit/bf909b7f2fbc3494b6981a7a545d7332a5b729c9 below:

Add an option to download from remote locations · orgrim/pg_back@bf909b7 · GitHub

@@ -83,6 +83,7 @@ type options struct {

83 83

DumpOnly bool

84 84 85 85

Upload string // values are none, s3, sftp, gcs

86 +

Download string // values are none, s3, sftp, gcs

86 87

PurgeRemote bool

87 88

S3Region string

88 89

S3Bucket string

@@ -132,6 +133,7 @@ func defaultOptions() options {

132 133

TimeFormat: timeFormat,

133 134

WithRolePasswords: true,

134 135

Upload: "none",

136 +

Download: "none",

135 137

AzureEndpoint: "blob.core.windows.net",

136 138

}

137 139

}

@@ -284,6 +286,7 @@ func parseCli(args []string) (options, []string, error) {

284 286

pflag.StringVar(&opts.CipherPrivateKey, "cipher-private-key", "", "AGE private key for decryption; in Bech32 encoding starting with 'AGE-SECRET-KEY-1'\n")

285 287 286 288

pflag.StringVar(&opts.Upload, "upload", "none", "upload produced files to target (s3, gcs,..) use \"none\" to override\nconfiguration file and disable upload")

289 +

pflag.StringVar(&opts.Download, "download", "none", "download files from target (s3, gcs,..) instead of dumping. DBNAMEs become\nglobs to select files")

287 290

purgeRemote := pflag.String("purge-remote", "no", "purge the file on remote location after upload, with the same rules\nas the local directory")

288 291 289 292

pflag.StringVar(&opts.S3Region, "s3-region", "", "S3 region")

@@ -438,35 +441,41 @@ func parseCli(args []string) (options, []string, error) {

438 441

}

439 442

}

440 443 441 -

// Validate upload option

444 +

// Validate upload and download options

442 445

stores := []string{"none", "s3", "sftp", "gcs", "azure"}

443 446

if err := validateEnum(opts.Upload, stores); err != nil {

444 447

return opts, changed, fmt.Errorf("invalid value for --upload: %s", err)

445 448

}

446 449 450 +

if err := validateEnum(opts.Download, stores); err != nil {

451 +

return opts, changed, fmt.Errorf("invalid value for --download: %s", err)

452 +

}

453 + 447 454

opts.PurgeRemote, err = validateYesNoOption(*purgeRemote)

448 455

if err != nil {

449 456

return opts, changed, fmt.Errorf("invalid value for --purge-remote: %s", err)

450 457

}

451 458 452 -

switch opts.Upload {

453 -

case "s3":

454 -

// Validate S3 options

455 -

opts.S3ForcePath, err = validateYesNoOption(*S3ForcePath)

456 -

if err != nil {

457 -

return opts, changed, fmt.Errorf("invalid value for --s3-force-path: %s", err)

458 -

}

459 +

for _, o := range []string{opts.Upload, opts.Download} {

460 +

switch o {

461 +

case "s3":

462 +

// Validate S3 options

463 +

opts.S3ForcePath, err = validateYesNoOption(*S3ForcePath)

464 +

if err != nil {

465 +

return opts, changed, fmt.Errorf("invalid value for --s3-force-path: %s", err)

466 +

}

459 467 460 -

S3WithTLS, err := validateYesNoOption(*S3UseTLS)

461 -

if err != nil {

462 -

return opts, changed, fmt.Errorf("invalid value for --s3-tls: %s", err)

463 -

}

464 -

opts.S3DisableTLS = !S3WithTLS

468 +

S3WithTLS, err := validateYesNoOption(*S3UseTLS)

469 +

if err != nil {

470 +

return opts, changed, fmt.Errorf("invalid value for --s3-tls: %s", err)

471 +

}

472 +

opts.S3DisableTLS = !S3WithTLS

465 473 466 -

case "sftp":

467 -

opts.SFTPIgnoreKnownHosts, err = validateYesNoOption(*SFTPIgnoreHostKey)

468 -

if err != nil {

469 -

return opts, changed, fmt.Errorf("invalid value for --sftp-ignore-hostkey: %s", err)

474 +

case "sftp":

475 +

opts.SFTPIgnoreKnownHosts, err = validateYesNoOption(*SFTPIgnoreHostKey)

476 +

if err != nil {

477 +

return opts, changed, fmt.Errorf("invalid value for --sftp-ignore-hostkey: %s", err)

478 +

}

470 479

}

471 480

}

472 481

@@ -816,6 +825,8 @@ func mergeCliAndConfigOptions(cliOpts options, configOpts options, onCli []strin

816 825 817 826

case "upload":

818 827

opts.Upload = cliOpts.Upload

828 +

case "download":

829 +

opts.Download = cliOpts.Download

819 830

case "purge-remote":

820 831

opts.PurgeRemote = cliOpts.PurgeRemote

821 832

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4