mirror of https://github.com/dapr/cli.git
clear error on missing kube config (#124)
This commit is contained in:
parent
64f2ed6493
commit
05e4a022d3
|
@ -6,6 +6,7 @@
|
||||||
package kubernetes
|
package kubernetes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -21,6 +22,11 @@ const daprManifestPath = "https://daprreleases.blob.core.windows.net/manifest/da
|
||||||
|
|
||||||
// Initialize to deploy the Dapr operator
|
// Initialize to deploy the Dapr operator
|
||||||
func Init() error {
|
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..."
|
msg := "Deploying the Dapr Operator to your cluster..."
|
||||||
var s *spinner.Spinner
|
var s *spinner.Spinner
|
||||||
|
|
||||||
|
@ -49,6 +55,11 @@ func Init() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func kubeconfigExists() bool {
|
||||||
|
_, err := Client()
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
func runCmdAndWait(name string, args ...string) error {
|
func runCmdAndWait(name string, args ...string) error {
|
||||||
cmd := exec.Command(name, args...)
|
cmd := exec.Command(name, args...)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
|
|
Loading…
Reference in New Issue