Documentation
¶
Overview ¶
Package exec provides utilities for executing external commands.
Index ¶
- func GetComposeCommand() []string
- type DockerExecutor
- type KubectlExecutor
- func (k *KubectlExecutor) Apply(yamls ...[]byte) error
- func (k *KubectlExecutor) CheckAvailability() error
- func (k *KubectlExecutor) RolloutRestart(name string) error
- func (k *KubectlExecutor) Run(args ...string) error
- func (k *KubectlExecutor) RunWithOutput(args ...string) ([]byte, error)
- func (k *KubectlExecutor) WaitForDeployment(name string, timeout time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetComposeCommand ¶
func GetComposeCommand() []string
GetComposeCommand returns the appropriate docker compose command for the system. It tries "docker compose" (newer version) first, then falls back to "docker-compose" (older version).
Types ¶
type DockerExecutor ¶
type DockerExecutor struct {
// Verbose enables detailed logging of Docker commands
Verbose bool
// WorkDir sets the working directory for Docker commands
WorkDir string
}
DockerExecutor provides utilities for running Docker commands with consistent error handling, logging, and configuration across the CLI.
func NewDockerExecutor ¶
func NewDockerExecutor(verbose bool, workDir string) *DockerExecutor
NewDockerExecutor creates a new Docker executor with the specified configuration.
func (*DockerExecutor) Build ¶
func (d *DockerExecutor) Build(imageName, context string, extraArgs ...string) error
Build builds a Docker image with the specified name and context. Additional build arguments can be provided (e.g., "--platform", "linux/amd64").
func (*DockerExecutor) CheckAvailability ¶
func (d *DockerExecutor) CheckAvailability() error
CheckAvailability checks if Docker is installed and the daemon is running. Returns an error if Docker is not available or not properly configured.
func (*DockerExecutor) Push ¶
func (d *DockerExecutor) Push(imageName string) error
Push pushes a Docker image to a registry.
func (*DockerExecutor) Run ¶
func (d *DockerExecutor) Run(args ...string) error
Run executes a docker command with the given arguments. It automatically handles verbose logging and working directory configuration.
type KubectlExecutor ¶
type KubectlExecutor struct {
// Verbose enables detailed logging of kubectl commands
Verbose bool
// Namespace sets the default namespace for kubectl commands
Namespace string
}
KubectlExecutor provides utilities for running kubectl commands with consistent error handling, logging, and configuration.
func NewKubectlExecutor ¶
func NewKubectlExecutor(verbose bool, namespace string) *KubectlExecutor
NewKubectlExecutor creates a new kubectl executor with the specified configuration.
func (*KubectlExecutor) Apply ¶
func (k *KubectlExecutor) Apply(yamls ...[]byte) error
Apply applies YAML resources to the Kubernetes cluster. Multiple YAML documents can be provided and will be combined with separators.
func (*KubectlExecutor) CheckAvailability ¶
func (k *KubectlExecutor) CheckAvailability() error
CheckAvailability checks if kubectl is installed and accessible.
func (*KubectlExecutor) RolloutRestart ¶
func (k *KubectlExecutor) RolloutRestart(name string) error
RolloutRestart restarts a Kubernetes deployment by triggering a rollout restart. This causes the deployment to recreate all pods with the latest configuration.
func (*KubectlExecutor) Run ¶
func (k *KubectlExecutor) Run(args ...string) error
Run executes a kubectl command with the given arguments. It automatically handles verbose logging and captures stderr for better error messages.
func (*KubectlExecutor) RunWithOutput ¶
func (k *KubectlExecutor) RunWithOutput(args ...string) ([]byte, error)
RunWithOutput executes a kubectl command and returns the combined output. This is useful for capturing command output for further processing.
func (*KubectlExecutor) WaitForDeployment ¶
func (k *KubectlExecutor) WaitForDeployment(name string, timeout time.Duration) error
WaitForDeployment waits for a Kubernetes deployment to be ready. It uses kubectl rollout status to monitor the deployment progress.