(cmd *cobra.Command, _ []string)
| 138 | } |
| 139 | |
| 140 | func (c *rootCommand) persistentPreRunE(cmd *cobra.Command, _ []string) error { |
| 141 | // The 'cloud' secret source is managed automatically and is not a valid value for |
| 142 | // --secret-source. Reject it here, before auto-injection, so the check only sees |
| 143 | // user-provided values. The logger is not yet configured at this point, so write |
| 144 | // the error directly to gs.Stderr and return errAlreadyReported to suppress the |
| 145 | // duplicate log entry that execute() would otherwise emit. |
| 146 | if err := validateNoCloudSecretSource(c.globalState.Flags.SecretSource); err != nil { |
| 147 | _, _ = fmt.Fprintln(c.globalState.Stderr, err.Error()) |
| 148 | return errext.WithExitCodeIfNone(errAlreadyReported, exitcodes.InvalidConfig) |
| 149 | } |
| 150 | |
| 151 | // For 'k6 cloud run --local-execution', automatically register the cloud secret source |
| 152 | // so scripts can call secrets.get() without any extra flags. |
| 153 | // This must happen before setupLoggers, which calls createSecretSources internally. |
| 154 | if isCloudRunWithLocalExecution(cmd) { |
| 155 | f := cmd.Flag("no-cloud-secrets") |
| 156 | if f == nil || f.Value.String() != "true" { |
| 157 | c.globalState.Flags.SecretSource = append(c.globalState.Flags.SecretSource, "cloud") |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | err := c.setupLoggers(c.stopLoggersCh) |
| 162 | if err != nil { |
| 163 | return err |
| 164 | } |
| 165 | |
| 166 | c.globalState.Logger.Debugf("k6 version: v%s", fullVersion()) |
| 167 | |
| 168 | return nil |
| 169 | } |
| 170 | |
| 171 | func (c *rootCommand) execute() { |
| 172 | ctx, cancel := context.WithCancel(c.globalState.Ctx) |
nothing calls this directly
no test coverage detected