-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutil.go
104 lines (95 loc) · 1.96 KB
/
util.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package main
import (
"crypto/rand"
"encoding/hex"
"errors"
)
const END_OF_TRANSMISSION = "\u0004"
var WSCloseCode = struct {
info, warning, error uint
}{
info: 3000,
warning: 3001,
error: 3002,
}
var WSOpType = struct {
bind,
accessReview,
rulesReview,
list,
listAll,
helmList,
get,
helmShowValues,
helmGet,
helmInstall,
helmUpgrade,
helmPull,
helmGetTags,
update,
check,
delete,
helmUninstall,
close,
stdin,
stdout,
resize,
toast string
}{
bind: "bind",
accessReview: "accessReview",
rulesReview: "rulesReview",
list: "list",
listAll: "listAll",
helmList: "helmList",
get: "get",
helmShowValues: "helmShowValues",
helmGet: "helmGet",
helmInstall: "helmInstall",
helmUpgrade: "helmUpgrade",
helmPull: "helmPull",
helmGetTags: "helmGetTags",
check: "check",
update: "update",
delete: "delete",
helmUninstall: "helmUninstall",
close: "close",
stdin: "stdin",
stdout: "stdout",
resize: "resize",
toast: "toast",
}
var KubernetesConfigType = struct {
inClusterConfig,
kubeconfigPath,
kubeconfigRaw,
accessToken string
}{
inClusterConfig: "inClusterConfig",
kubeconfigPath: "kubeconfigPath",
kubeconfigRaw: "kubeconfigRaw",
accessToken: "accessToken",
}
func genSessionId() (string, error) {
bytes := make([]byte, 16)
if _, err := rand.Read(bytes); err != nil {
return "", err
}
id := make([]byte, hex.EncodedLen(len(bytes)))
hex.Encode(id, bytes)
return string(id), nil
}
func isValidShell(validShells []string, shell string) bool {
for _, validShell := range validShells {
if validShell == shell {
return true
}
}
return false
}
func reverseStringSlice(input []string) {
for i, j := 0, len(input)-1; i < j; i, j = i+1, j-1 {
input[i], input[j] = input[j], input[i]
}
}
var errCouldNotFindResource = errors.New("the server could not find the requested resource")