clear error on missing kube config (#124)

This commit is contained in:
Yaron Schneider 2019-10-11 10:47:29 -07:00 committed by GitHub
parent 64f2ed6493
commit 05e4a022d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -6,6 +6,7 @@
package kubernetes
import (
"errors"
"fmt"
"os"
"os/exec"
@ -21,6 +22,11 @@ const daprManifestPath = "https://daprreleases.blob.core.windows.net/manifest/da
// Initialize to deploy the Dapr operator
func Init() error {
kubeExists := kubeconfigExists()
if !kubeExists {
return errors.New("Can't connect to a Kubernetes cluster. Make sure you have the Kubernetes config file on your machine")
}
msg := "Deploying the Dapr Operator to your cluster..."
var s *spinner.Spinner
@ -49,6 +55,11 @@ func Init() error {
return nil
}
func kubeconfigExists() bool {
_, err := Client()
return err == nil
}
func runCmdAndWait(name string, args ...string) error {
cmd := exec.Command(name, args...)
err := cmd.Start()