-
Notifications
You must be signed in to change notification settings - Fork 197
/
kubernetes.go
55 lines (45 loc) · 1.15 KB
/
kubernetes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
package kubernetes
import (
"fmt"
"os"
"runtime"
"time"
"github.com/dapr/cli/pkg/print"
"github.com/dapr/cli/utils"
"github.com/briandowns/spinner"
)
const daprManifestPath = "https://daprreleases.blob.core.windows.net/manifest/dapr-operator.yaml"
// Init deploys the Dapr operator
func Init() error {
_, err := Client()
if err != nil {
return fmt.Errorf("can't connect to a Kubernetes cluster: %v", err)
}
msg := "Deploying the Dapr Operator to your cluster..."
var s *spinner.Spinner
if runtime.GOOS == "windows" {
print.InfoStatusEvent(os.Stdout, msg)
} else {
s = spinner.New(spinner.CharSets[0], 100*time.Millisecond)
s.Writer = os.Stdout
s.Color("cyan")
s.Suffix = fmt.Sprintf(" %s", msg)
s.Start()
}
_, err = utils.RunCmdAndWait("kubectl", "apply", "-f", daprManifestPath)
if err != nil {
if s != nil {
s.Stop()
}
return err
}
if s != nil {
s.Stop()
print.SuccessStatusEvent(os.Stdout, msg)
}
return nil
}