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/8f8e8eeea6c38446838cdd174d29718a886e9515 below:

add option to skip loading config file · orgrim/pg_back@8f8e8ee · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+25

-13

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+25

-13

lines changed Original file line number Diff line number Diff line change

@@ -29,14 +29,15 @@ import (

29 29

_ "embed"

30 30

"errors"

31 31

"fmt"

32 -

"github.com/anmitsu/go-shlex"

33 -

"github.com/spf13/pflag"

34 -

"gopkg.in/ini.v1"

35 32

"os"

36 33

"runtime"

37 34

"strconv"

38 35

"strings"

39 36

"time"

37 + 38 +

"github.com/anmitsu/go-shlex"

39 +

"github.com/spf13/pflag"

40 +

"gopkg.in/ini.v1"

40 41

)

41 42 42 43

var defaultCfgFile = "/etc/pg_back/pg_back.conf"

@@ -46,6 +47,7 @@ var defaultCfg string

46 47 47 48

// options struct holds command line and configuration file options

48 49

type options struct {

50 +

NoConfigFile bool

49 51

BinDirectory string

50 52

Directory string

51 53

Host string

@@ -112,6 +114,7 @@ func defaultOptions() options {

112 114

}

113 115 114 116

return options{

117 +

NoConfigFile: false,

115 118

Directory: "/var/backups/postgresql",

116 119

Format: 'c',

117 120

DirJobs: 1,

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

245 248

pflag.PrintDefaults()

246 249

}

247 250 251 +

pflag.BoolVar(&opts.NoConfigFile, "no-config-file", false, "skip reading config file\n")

248 252

pflag.StringVarP(&opts.BinDirectory, "bin-directory", "B", "", "PostgreSQL binaries directory. Empty to search $PATH")

249 253

pflag.StringVarP(&opts.Directory, "backup-directory", "b", "/var/backups/postgresql", "store dump files there")

250 254

pflag.StringVarP(&opts.CfgFile, "config", "c", defaultCfgFile, "alternate config file")

Original file line number Diff line number Diff line change

@@ -28,15 +28,16 @@ package main

28 28

import (

29 29

"errors"

30 30

"fmt"

31 -

"github.com/google/go-cmp/cmp"

32 -

"github.com/google/go-cmp/cmp/cmpopts"

33 -

"github.com/spf13/pflag"

34 -

"gopkg.in/ini.v1"

35 31

"io/ioutil"

36 32

"os"

37 33

"runtime"

38 34

"testing"

39 35

"time"

36 + 37 +

"github.com/google/go-cmp/cmp"

38 +

"github.com/google/go-cmp/cmp/cmpopts"

39 +

"github.com/spf13/pflag"

40 +

"gopkg.in/ini.v1"

40 41

)

41 42 42 43

func TestValidateDumpFormat(t *testing.T) {

Original file line number Diff line number Diff line change

@@ -148,16 +148,23 @@ func run() (retVal error) {

148 148

// Enable verbose mode or quiet mode as soon as possible

149 149

l.SetVerbosity(cliOpts.Verbose, cliOpts.Quiet)

150 150 151 -

// Load configuration file and allow the default configuration

152 -

// file to be absent

153 -

configOpts, err := loadConfigurationFile(cliOpts.CfgFile)

154 -

if err != nil {

155 -

return err

151 +

var cliOptions options

152 + 153 +

if cliOpts.NoConfigFile {

154 +

l.Infoln("*** Skipping reading config file")

155 +

cliOptions = defaultOptions()

156 +

} else {

157 +

// Load configuration file and allow the default configuration

158 +

// file to be absent

159 +

cliOptions, err = loadConfigurationFile(cliOpts.CfgFile)

160 +

if err != nil {

161 +

return err

162 +

}

156 163

}

157 164 158 165

// override options from the configuration file with ones from

159 166

// the command line

160 -

opts := mergeCliAndConfigOptions(cliOpts, configOpts, cliOptList)

167 +

opts := mergeCliAndConfigOptions(cliOpts, cliOptions, cliOptList)

161 168 162 169

// Ensure a non-empty passphrase is set when asking for encryption

163 170

if (opts.Encrypt || opts.Decrypt) && len(opts.CipherPassphrase) == 0 {

You can’t perform that action at this time.


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