ExecCommandString executes a command string directly with KUBECONFIG environment set. This is a convenience function that parses a command string and calls ExecCommand. The command string is parsed using shell-like parsing with support for quoted arguments. This function blocks until the command e
(ctx context.Context, config *Config, commandStr string, stopCh chan struct{}, stopOnce *sync.Once)
| 80 | // |
| 81 | // This function blocks until the command exits or the context is cancelled. |
| 82 | func ExecCommandString(ctx context.Context, config *Config, commandStr string, stopCh chan struct{}, stopOnce *sync.Once) error { |
| 83 | command, err := shlex.Split(commandStr) |
| 84 | if err != nil { |
| 85 | stopOnce.Do(func() { close(stopCh) }) |
| 86 | return fmt.Errorf("failed to parse command: %w", err) |
| 87 | } |
| 88 | |
| 89 | if len(command) == 0 { |
| 90 | stopOnce.Do(func() { close(stopCh) }) |
| 91 | return fmt.Errorf("empty command provided") |
| 92 | } |
| 93 | return ExecCommand(ctx, config, command, stopCh, stopOnce) |
| 94 | } |
| 95 | |
| 96 | // spawnShell is the internal implementation that spawns an interactive shell |
| 97 | // with KUBECONFIG environment set and custom prompt configuration. |
nothing calls this directly
no test coverage detected