github.com/pluralsh/plural-cli@v0.9.5/pkg/utils/kind.go (about)

     1  package utils
     2  
     3  import (
     4  	"os/exec"
     5  	"strings"
     6  )
     7  
     8  const noKindClustersError = "No kind clusters found."
     9  
    10  func IsKindClusterAlreadyExists(name string) bool {
    11  	cmd := exec.Command("kind", "get", "clusters")
    12  	out, err := ExecuteWithOutput(cmd)
    13  	if err != nil {
    14  		return false
    15  	}
    16  	if strings.Contains(out, noKindClustersError) {
    17  		return false
    18  	}
    19  
    20  	return strings.Contains(out, name)
    21  }
    22  
    23  func GetKindClusterKubeconfig(name string, internal bool) (string, error) {
    24  	kubeconfigArgs := []string{"get", "kubeconfig", "--name", name}
    25  	if internal {
    26  		kubeconfigArgs = append(kubeconfigArgs, "--internal")
    27  	}
    28  
    29  	cmd := exec.Command("kind", kubeconfigArgs...)
    30  	return ExecuteWithOutput(cmd)
    31  }