diff --git a/cmd/dfdaemon/app/root.go b/cmd/dfdaemon/app/root.go index c344bbe80..c153cdf65 100644 --- a/cmd/dfdaemon/app/root.go +++ b/cmd/dfdaemon/app/root.go @@ -24,7 +24,7 @@ import ( "reflect" dferr "github.com/dragonflyoss/Dragonfly/common/errors" - "github.com/dragonflyoss/Dragonfly/common/util" + cutil "github.com/dragonflyoss/Dragonfly/common/util" "github.com/dragonflyoss/Dragonfly/dfdaemon" "github.com/dragonflyoss/Dragonfly/dfdaemon/config" "github.com/dragonflyoss/Dragonfly/dfdaemon/constant" @@ -91,11 +91,8 @@ func init() { // dfget download config rf.String("localrepo", filepath.Join(os.Getenv("HOME"), ".small-dragonfly/dfdaemon/data/"), "temp output dir of dfdaemon") - rf.String("callsystem", "com_ops_dragonfly", "caller name") rf.String("dfpath", defaultDfgetPath, "dfget path") - rf.String("ratelimit", util.NetLimit(), "net speed limit,format:xxxM/K") - rf.String("urlfilter", "Signature&Expires&OSSAccessKeyId", "filter specified url fields") - rf.Bool("notbs", true, "not try back source to download if throw exception") + rf.String("ratelimit", cutil.NetLimit(), "net speed limit,format:xxxM/K") rf.StringSlice("node", nil, "specify the addresses(host:port) of supernodes that will be passed to dfget.") exitOnError(bindRootFlags(viper.GetViper()), "bind root command flags") diff --git a/dfdaemon/config/config.go b/dfdaemon/config/config.go index 478bbc122..af6c0385c 100644 --- a/dfdaemon/config/config.go +++ b/dfdaemon/config/config.go @@ -88,18 +88,16 @@ type Properties struct { CertPem string `yaml:"certpem" json:"certpem"` KeyPem string `yaml:"keypem" json:"keypem"` - // dfget config - SuperNodes []string `yaml:"supernodes" json:"supernodes"` - DFRepo string `yaml:"localrepo" json:"localrepo"` - DFPath string `yaml:"dfpath" json:"dfpath"` - RateLimit string `yaml:"ratelimit" json:"ratelimit"` - URLFilter string `yaml:"urlfilter" json:"urlfilter"` - CallSystem string `yaml:"callsystem" json:"callsystem"` - Notbs bool `yaml:"notbs" json:"notbs"` - Verbose bool `yaml:"verbose" json:"verbose"` MaxProcs int `yaml:"maxprocs" json:"maxprocs"` + + // dfget config + GlobalDfgetParams []string `yaml:"global_dfget_params" json:"global_dfget_params"` + SuperNodes []string `yaml:"supernodes" json:"supernodes"` + RateLimit string `yaml:"ratelimit" json:"ratelimit"` + DFRepo string `yaml:"localrepo" json:"localrepo"` + DFPath string `yaml:"dfpath" json:"dfpath"` } // Validate validates the config @@ -138,27 +136,21 @@ func (p *Properties) Validate() error { // DFGetConfig returns config for dfget downloader func (p *Properties) DFGetConfig() DFGetConfig { return DFGetConfig{ - SuperNodes: p.SuperNodes, - DFRepo: p.DFRepo, - DFPath: p.DFPath, - RateLimit: p.RateLimit, - URLFilter: p.URLFilter, - CallSystem: p.CallSystem, - Notbs: p.Notbs, - Verbose: p.Verbose, + GlobalDfgetParams: p.GlobalDfgetParams, + SuperNodes: p.SuperNodes, + RateLimit: p.RateLimit, + DFRepo: p.DFRepo, + DFPath: p.DFPath, } } // DFGetConfig configures how dfdaemon calls dfget type DFGetConfig struct { - SuperNodes []string `yaml:"supernodes"` - DFRepo string `yaml:"localrepo"` - DFPath string `yaml:"dfpath"` - RateLimit string `yaml:"ratelimit"` - URLFilter string `yaml:"urlfilter"` - CallSystem string `yaml:"callsystem"` - Notbs bool `yaml:"notbs"` - Verbose bool `yaml:"verbose"` + GlobalDfgetParams []string `yaml:"global_dfget_params"` + SuperNodes []string `yaml:"supernodes"` + RateLimit string `yaml:"ratelimit"` + DFRepo string `yaml:"localrepo"` + DFPath string `yaml:"dfpath"` } // RegistryMirror configures the mirror of the official docker registry diff --git a/dfdaemon/config/config_test.go b/dfdaemon/config/config_test.go index e91d81964..1cf2ac5d8 100644 --- a/dfdaemon/config/config_test.go +++ b/dfdaemon/config/config_test.go @@ -266,19 +266,6 @@ func (ts *configTestSuite) TestProxyMatch() { } -func (ts *configTestSuite) TestDFGetConfig() { - r := ts.Require() - cfg := defaultConfig() - dfgetCfg := cfg.DFGetConfig() - r.Equal(cfg.SuperNodes, dfgetCfg.SuperNodes) - r.Equal(cfg.DFRepo, dfgetCfg.DFRepo) - r.Equal(cfg.DFPath, dfgetCfg.DFPath) - r.Equal(cfg.RateLimit, dfgetCfg.RateLimit) - r.Equal(cfg.URLFilter, dfgetCfg.URLFilter) - r.Equal(cfg.CallSystem, dfgetCfg.CallSystem) - r.Equal(cfg.Notbs, dfgetCfg.Notbs) -} - func (ts *configTestSuite) TestMirrorTLSConfig() { r := ts.Require() diff --git a/dfdaemon/downloader/dfget/dfget.go b/dfdaemon/downloader/dfget/dfget.go index 3ed3d515f..dc2c92bb8 100644 --- a/dfdaemon/downloader/dfget/dfget.go +++ b/dfdaemon/downloader/dfget/dfget.go @@ -69,12 +69,8 @@ func (dfGetter *DFGetter) getCommand( "-o", output, } - if dfGetter.config.Notbs { - args = append(args, "--notbs") - } - - if dfGetter.config.Verbose { - args = append(args, "--verbose") + for _, param := range dfGetter.config.GlobalDfgetParams { + args = append(args, param) } add := func(key, value string) { @@ -82,9 +78,6 @@ func (dfGetter *DFGetter) getCommand( args = append(args, key, v) } } - - add("--callsystem", dfGetter.config.CallSystem) - add("-f", dfGetter.config.URLFilter) add("-s", dfGetter.config.RateLimit) add("--totallimit", dfGetter.config.RateLimit) add("--node", strings.Join(dfGetter.config.SuperNodes, ","))