Files
Reloader/test/e2e/utils/kind.go
2026-01-08 11:06:45 +01:00

28 lines
711 B
Go

package utils
import (
"fmt"
"os"
"os/exec"
)
// GetKindClusterName returns the Kind cluster name from the KIND_CLUSTER environment variable,
// or "kind" as the default.
func GetKindClusterName() string {
if cluster := os.Getenv("KIND_CLUSTER"); cluster != "" {
return cluster
}
return "kind"
}
// LoadImageToKindCluster loads a Docker image into the Kind cluster using the default cluster name.
func LoadImageToKindCluster(image string) error {
cmd := exec.Command("kind", "load", "docker-image", image, "--name", GetKindClusterName())
output, err := Run(cmd)
if err != nil {
return fmt.Errorf("failed to load image %s to Kind cluster: %w\nOutput: %s",
image, err, output)
}
return nil
}