-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.go
More file actions
34 lines (30 loc) · 728 Bytes
/
utils.go
File metadata and controls
34 lines (30 loc) · 728 Bytes
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
package main
import (
"fmt"
"strings"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// parseKindStrings parses Group/Version/Kind strings into GVK objects
func parseKindStrings(csv string) []schema.GroupVersionKind {
if csv == "" {
return nil
}
var out []schema.GroupVersionKind
parts := strings.Split(csv, ",")
for _, s := range parts {
s = strings.TrimSpace(s)
if s == "" {
continue
}
frags := strings.Split(s, "/")
if len(frags) != 3 {
fatal(fmt.Errorf("kind %q must be group/version/kind", s))
}
out = append(out, schema.GroupVersionKind{Group: frags[0], Version: frags[1], Kind: frags[2]})
}
return out
}
// fatal prints an error and exits
func fatal(err error) {
NewLogger().Fatal(err)
}