mirror of
https://github.com/stakater/Reloader.git
synced 2026-05-17 14:16:39 +00:00
28 lines
711 B
Go
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
|
|
}
|