Skip to content
Permalink
Browse files

cmd: add err handling

Signed-off-by: hwdef <hwdef97@gmail.com>
  • Loading branch information...
hwdef committed Sep 18, 2019
1 parent 9114104 commit 389bd6a7b74b5cf9c34c90a8ed3fa2eab589dcdb
Showing with 16 additions and 7 deletions.
  1. +4 −2 cmd/dfdaemon/app/root_test.go
  2. +3 −1 cmd/dfget/app/server.go
  3. +9 −4 cmd/supernode/app/root.go
@@ -105,8 +105,10 @@ func (ts *rootTestSuite) TestDecodeWithYAML() {
f, err := ioutil.TempFile("", "")
r.Nil(err)
defer os.RemoveAll(f.Name())
f.WriteString(testCrt)
f.Close()
_, err = f.WriteString(testCrt)
r.Nil(err)
err = f.Close()
r.Nil(err)
v.Set("registry_mirror.certs", []string{f.Name()})

cfg, err := getConfigFromViper(v)
@@ -65,7 +65,9 @@ func initServerFlags() {
}

func runServer() error {
initServerLog()
if err := initServerLog(); err != nil {
return err
}
// launch a peer server as a uploader server
port, err := uploader.LaunchPeerServer(cfg)
if err != nil {
@@ -205,7 +205,10 @@ func initConfig() error {
return nil
}

opt := getPureOptionFromCLI()
opt, err := getPureOptionFromCLI()
if err != nil {
return err
}
choosePropValue(opt.BaseProperties, cfg.BaseProperties)
return nil
}
@@ -253,12 +256,14 @@ func choosePropValue(cliProp, cfgProp *config.BaseProperties) {
}
}

func getPureOptionFromCLI() *Options {
func getPureOptionFromCLI() (*Options, error) {
cmd := &cobra.Command{}
opt := &Options{&config.BaseProperties{}}
setupFlags(cmd, opt)
cmd.ParseFlags(os.Args)
return opt
if err := cmd.ParseFlags(os.Args); err != nil {
return nil, err
}
return opt, nil
}

// Execute will process supernode.

0 comments on commit 389bd6a

Please sign in to comment.
You can’t perform that action at this time.