LoadCommandsConfig loads the commands config
(f factory.Factory, configLoader loader.ConfigLoader, configOptions *loader.ConfigOptions, log log.Logger)
| 237 | |
| 238 | // LoadCommandsConfig loads the commands config |
| 239 | func (cmd *RunCmd) LoadCommandsConfig(f factory.Factory, configLoader loader.ConfigLoader, configOptions *loader.ConfigOptions, log log.Logger) (devspacecontext.Context, error) { |
| 240 | // load generated |
| 241 | localCache, err := configLoader.LoadLocalCache() |
| 242 | if err != nil { |
| 243 | return nil, err |
| 244 | } |
| 245 | |
| 246 | // try to load client |
| 247 | client, err := f.NewKubeClientFromContext(cmd.KubeContext, cmd.Namespace) |
| 248 | if err != nil { |
| 249 | log.Debugf("Unable to create new kubectl client: %v", err) |
| 250 | client = nil |
| 251 | } |
| 252 | |
| 253 | // verify client connectivity / authn / authz |
| 254 | if client != nil { |
| 255 | // If the current kube context or namespace is different than old, |
| 256 | // show warnings and reset kube client if necessary |
| 257 | client, err = kubectl.CheckKubeContext(client, localCache, cmd.NoWarn, cmd.SwitchContext, false, log) |
| 258 | if err != nil { |
| 259 | log.Debugf("Unable to verify kube context %v", err) |
| 260 | client = nil |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | // Parse commands |
| 265 | commandsInterface, err := configLoader.LoadWithParser(context.Background(), localCache, client, loader.NewCommandsParser(), configOptions, log) |
| 266 | if err != nil { |
| 267 | return nil, err |
| 268 | } |
| 269 | |
| 270 | // create context |
| 271 | return devspacecontext.NewContext(context.Background(), commandsInterface.Variables(), log). |
| 272 | WithKubeClient(client). |
| 273 | WithConfig(commandsInterface), nil |
| 274 | } |
| 275 | |
| 276 | func executeShellCommand(ctx context.Context, shellCommand string, variables map[string]interface{}, args []string, dir string, stdout io.Writer, stderr io.Writer, stdin io.Reader) error { |
| 277 | extraEnv := map[string]string{} |
no test coverage detected