Skip to content

Commit

Permalink
Rename and document better the cmd/inspect.go internals
Browse files Browse the repository at this point in the history
  • Loading branch information
na-- committed Mar 16, 2022
1 parent 0581cc4 commit 3b3e386
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ func getInspectCmd(gs *globalState) *cobra.Command {
// At the moment, `k6 inspect` output can take 2 forms: standard
// (equal to the lib.Options struct) and extended, with additional
// fields with execution requirements.
inspectOutput := interface{}(test.initRunner.GetOptions())

var inspectOutput interface{}
if addExecReqs {
inspectOutput, err = addExecRequirements(gs, cmd, test)
inspectOutput, err = inspectOutputWithExecRequirements(gs, cmd, test)
if err != nil {
return err
}
} else {
inspectOutput = test.initRunner.GetOptions()
}

data, err := json.MarshalIndent(inspectOutput, "", " ")
Expand All @@ -76,7 +77,9 @@ func getInspectCmd(gs *globalState) *cobra.Command {
return inspectCmd
}

func addExecRequirements(gs *globalState, cmd *cobra.Command, test *loadedTest) (interface{}, error) {
// If --execution-requirements is enabled, this will consolidate the config,
// derive the value of `scenarios` and calculate the max test duration and VUs.
func inspectOutputWithExecRequirements(gs *globalState, cmd *cobra.Command, test *loadedTest) (interface{}, error) {
// we don't actually support CLI flags here, so we pass nil as the getter
if err := test.consolidateDeriveAndValidateConfig(gs, cmd, nil); err != nil {
return nil, err
Expand Down

0 comments on commit 3b3e386

Please sign in to comment.