-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes.go
71 lines (59 loc) · 2.24 KB
/
types.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
package fn
import (
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/kustomize/kyaml/fn/framework"
)
//ResourceList is a Kubernetes list type used as the output data format in the Functions execution
type ResourceList struct {
// Items is the ResourceList.items input and output value.
//
// e.g. given the function input:
//
// items:
// - kind: Deployment
// ...
// - kind: Service
// ...
//
// Items will be a slice containing the Deployment and Service resources
// Mutating functions will alter this field during processing.
// This field is required.
Items []runtime.Object
// Results is ResourceList.results output value.
// Validating functions can optionally use this field to communicate structured
// validation error data to downstream functions.
Results map[string]framework.Result
}
// Function specifies a KRM function to run.
type Function struct {
// Name is the name of the function.
Name string
// `Image` specifies the function container image.
// image: gcr.io/kpt-fn/set-labels
Image string `yaml:"image,omitempty" json:"image,omitempty"`
// Exec specifies the function binary executable.
// The executable can be fully qualified, or it must exist in the $PATH e.g:
//
// exec: set-namespace
// exec: /usr/local/bin/my-custom-fn
Exec string `yaml:"exec,omitempty" json:"exec,omitempty"`
// `ConfigMap` is a convenient way to specify a function config of kind ConfigMap.
ConfigMap map[string]string `yaml:"configMap,omitempty" json:"configMap,omitempty"`
}
// RunnerBuilder is a executeFn builder that can be used to build a FunctionRunner.
type RunnerBuilder interface {
// WithInput adds raw input to the builder.
WithInput([]byte) RunnerBuilder
// WithInputs adds runtime.objects as the input resource.
WithInputs(...runtime.Object) RunnerBuilder
// WithFunctions provide a list of functions to run.
WithFunctions(...Function) RunnerBuilder
// WhereExecWorkingDir specifies which working directory an exec function should run in.
WhereExecWorkingDir(string) RunnerBuilder
// Build builds the runner with the provided options.
Build() (FunctionRunner, error)
}
// FunctionRunner is a runner that can execute the functions.
type FunctionRunner interface {
Execute() (ResourceList, error)
}