| 320 | } |
| 321 | |
| 322 | func (s *scaletestOutputFlags) parse() ([]scaleTestOutput, error) { |
| 323 | var stdoutFormat scaleTestOutputFormat |
| 324 | |
| 325 | validFormats := map[scaleTestOutputFormat]struct{}{ |
| 326 | scaleTestOutputFormatText: {}, |
| 327 | scaleTestOutputFormatJSON: {}, |
| 328 | } |
| 329 | |
| 330 | var out []scaleTestOutput |
| 331 | for i, o := range s.outputSpecs { |
| 332 | parts := strings.SplitN(o, ":", 2) |
| 333 | format := scaleTestOutputFormat(parts[0]) |
| 334 | if _, ok := validFormats[format]; !ok { |
| 335 | return nil, xerrors.Errorf("invalid output format %q in output flag %d", parts[0], i) |
| 336 | } |
| 337 | |
| 338 | if len(parts) == 1 { |
| 339 | if stdoutFormat != "" { |
| 340 | return nil, xerrors.Errorf("multiple output flags specified for stdout") |
| 341 | } |
| 342 | stdoutFormat = format |
| 343 | continue |
| 344 | } |
| 345 | if len(parts) != 2 { |
| 346 | return nil, xerrors.Errorf("invalid output flag %d: %q", i, o) |
| 347 | } |
| 348 | |
| 349 | out = append(out, scaleTestOutput{ |
| 350 | format: format, |
| 351 | path: parts[1], |
| 352 | }) |
| 353 | } |
| 354 | |
| 355 | // Default to --output text |
| 356 | if stdoutFormat == "" && len(out) == 0 { |
| 357 | stdoutFormat = scaleTestOutputFormatText |
| 358 | } |
| 359 | |
| 360 | if stdoutFormat != "" { |
| 361 | out = append([]scaleTestOutput{{ |
| 362 | format: stdoutFormat, |
| 363 | path: "-", |
| 364 | }}, out...) |
| 365 | } |
| 366 | |
| 367 | return out, nil |
| 368 | } |
| 369 | |
| 370 | type scaletestPrometheusFlags struct { |
| 371 | Address string |