mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Add documentation and simplify framework
This commit is contained in:
@@ -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
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user