BootstrapInvocationContext extracts global invocation options before the real command tree is built, so provider-backed config resolution sees the correct profile from the start.
(args []string)
| 15 | // the real command tree is built, so provider-backed config resolution sees |
| 16 | // the correct profile from the start. |
| 17 | func BootstrapInvocationContext(args []string) (cmdutil.InvocationContext, error) { |
| 18 | var globals GlobalOptions |
| 19 | |
| 20 | fs := pflag.NewFlagSet("bootstrap", pflag.ContinueOnError) |
| 21 | fs.ParseErrorsAllowlist.UnknownFlags = true |
| 22 | fs.SetInterspersed(true) |
| 23 | fs.SetOutput(io.Discard) |
| 24 | RegisterGlobalFlags(fs, &globals) |
| 25 | |
| 26 | if err := fs.Parse(args); err != nil && !errors.Is(err, pflag.ErrHelp) { |
| 27 | return cmdutil.InvocationContext{}, err |
| 28 | } |
| 29 | return cmdutil.InvocationContext{Profile: globals.Profile}, nil |
| 30 | } |