-
Notifications
You must be signed in to change notification settings - Fork 1
/
helm.go
55 lines (46 loc) · 974 Bytes
/
helm.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
package main
import (
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"kubepack.dev/lib-helm/repo"
"time"
)
func NewCmdHelm() *cobra.Command {
cmd := &cobra.Command{
Use: "helm",
Short: `Test lib-helm`,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
timeIT(testLibHelm)
time.Sleep(5 * time.Second)
timeIT(testLibHelm)
time.Sleep(5 * time.Second)
timeIT(testLibHelm)
return nil
},
}
return cmd
}
func timeIT(f func() error) {
start := time.Now()
f()
d := time.Since(start)
fmt.Println("Duration", d)
}
func testLibHelm() error {
reg := repo.NewDiskCacheRegistry()
chrt, err := reg.GetChart("https://charts.appscode.com/stable/", "stash", "v0.11.8")
if err != nil {
return err
}
data, err := json.MarshalIndent(chrt.Values, "", " ")
if err != nil {
return err
}
fmt.Println(string(data))
for _, f := range chrt.Raw {
fmt.Println(f.Name)
}
return nil
}