Skip to content

Commit

Permalink
Merge pull request #8 from fuweid/weifu/fix-runner-option
Browse files Browse the repository at this point in the history
runner: use default value if flag is not set
  • Loading branch information
fuweid authored Dec 21, 2023
2 parents a57838b + c6080af commit 2c93ca6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmd/kperf/commands/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ func loadConfig(cliCtx *cli.Context) (*types.LoadProfile, error) {
}

// override value by flags
//
// TODO(weifu): do not override if flag is not set
profileCfg.Spec.Rate = cliCtx.Int("rate")
profileCfg.Spec.Conns = cliCtx.Int("conns")
profileCfg.Spec.Total = cliCtx.Int("total")
if v := "rate"; cliCtx.IsSet(v) {
profileCfg.Spec.Rate = cliCtx.Int(v)
}
if v := "conns"; cliCtx.IsSet(v) || profileCfg.Spec.Conns == 0 {
profileCfg.Spec.Conns = cliCtx.Int(v)
}
if v := "total"; cliCtx.IsSet(v) || profileCfg.Spec.Total == 0 {
profileCfg.Spec.Total = cliCtx.Int(v)
}

if err := profileCfg.Validate(); err != nil {
return nil, err
Expand Down

0 comments on commit 2c93ca6

Please sign in to comment.