From 3b3e3860249aec608ebc3666e1f10ceb1fd8594d Mon Sep 17 00:00:00 2001 From: Nedyalko Andreev Date: Mon, 7 Mar 2022 17:02:25 +0200 Subject: [PATCH] Rename and document better the cmd/inspect.go internals --- cmd/inspect.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/inspect.go b/cmd/inspect.go index c6934b9d998..e154665ad15 100644 --- a/cmd/inspect.go +++ b/cmd/inspect.go @@ -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, "", " ") @@ -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