Add documentation and simplify framework

This commit is contained in:
Phillip Wittrock
2020-05-07 10:58:37 -07:00
parent 259624ac07
commit dab0f3cf22
15 changed files with 453 additions and 398 deletions

View File

@@ -0,0 +1,9 @@
// Package main contains a function to be used for e2e testing.
//
// The function is written using the framework, and parses the ResourceList.functionConfig
// into a go struct.
//
// The function will set 3 annotations on each resource.
//
// See https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/api-conventions/functions-spec.md
package main

View File

@@ -11,18 +11,25 @@ import (
"sigs.k8s.io/kustomize/kyaml/yaml"
)
// Data contains the items
type Data struct {
StringValue string `yaml:"stringValue,omitempty"`
IntValue int `yaml:"intValue,omitempty"`
BoolValue bool `yaml:"boolValue,omitempty"`
}
// Example defines the ResourceList.functionConfig schema.
type Example struct {
// Data contains configuration data for the Example
// Nest values under Data so that the function can accept a ConfigMap as its
// functionConfig (`run` generates a ConfigMap for the functionConfig when run with --)
Data Data `yaml:"data,omitempty"`
}
func main() {
type Data struct {
StringValue string `yaml:"stringValue,omitempty"`
IntValue int `yaml:"intValue,omitempty"`
BoolValue bool `yaml:"boolValue,omitempty"`
}
type ExampleServiceGenerator struct {
Data Data `yaml:"data,omitempty"`
}
functionConfig := &ExampleServiceGenerator{}
functionConfig := &Example{}
cmd := framework.Command(functionConfig, func(items []*yaml.RNode) ([]*yaml.RNode, error) {
for i := range items {