-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.go
56 lines (53 loc) · 1.23 KB
/
main.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
package main
import (
"fmt"
"os"
"kcl-lang.io/krm-kcl/pkg/options"
)
func main() {
// Input KRM resource list and KCL function config from os.Stdin
// YAML Stream Example
//
// ```yaml
// apiVersion: apps/v1
// kind: Deployment
// metadata:
// name: deployment
// spec:
// replicas: 2
// ---
// apiVersion: krm.kcl.dev/v1alpha1
// kind: KCLRun
// metadata:
// name: set-annotation
// spec:
// source: |
// [resource | {if resource.kind == "Deployment": metadata.annotations: {"managed-by" = "krm-kcl"}} for resource in option("resource_list").items]
// ```
//
// Resource List Example
//
// ```yaml
// apiVersion: config.kubernetes.io/v1
// kind: ResourceList
// items:
// - apiVersion: apps/v1
// kind: Deployment
// metadata:
// name: deployment
// spec:
// replicas: 2
// functionConfig:
// apiVersion: krm.kcl.dev/v1alpha1
// kind: KCLRun
// metadata:
// name: set-annotation
// spec:
// source: |
// [resource | {if resource.kind == "Deployment": metadata.annotations: {"managed-by" = "krm-kcl"}} for resource in option("resource_list").items]
// ```
if err := options.NewRunOptions().Run(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}