mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
update cmd/config e2e tests with new go function framework
This commit is contained in:
@@ -25,30 +25,33 @@ 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 --)
|
||||
// e.g. `config run DIR/ --image my-image -- a-string-value=foo` will create the input
|
||||
// with ResourceList.functionConfig.data.a-string-value=foo
|
||||
Data Data `yaml:"data,omitempty"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
functionConfig := &Example{}
|
||||
resourceList := &framework.ResourceList{FunctionConfig: functionConfig}
|
||||
|
||||
cmd := framework.Command(functionConfig, func(items []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||
for i := range items {
|
||||
if err := items[i].PipeE(yaml.SetAnnotation("a-string-value",
|
||||
cmd := framework.Command(resourceList, func() error {
|
||||
for i := range resourceList.Items {
|
||||
if err := resourceList.Items[i].PipeE(yaml.SetAnnotation("a-string-value",
|
||||
functionConfig.Data.StringValue)); err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
if err := items[i].PipeE(yaml.SetAnnotation("a-int-value",
|
||||
if err := resourceList.Items[i].PipeE(yaml.SetAnnotation("a-int-value",
|
||||
fmt.Sprintf("%v", functionConfig.Data.IntValue))); err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
if err := items[i].PipeE(yaml.SetAnnotation("a-bool-value",
|
||||
if err := resourceList.Items[i].PipeE(yaml.SetAnnotation("a-bool-value",
|
||||
fmt.Sprintf("%v", functionConfig.Data.BoolValue))); err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
return items, nil
|
||||
return nil
|
||||
})
|
||||
|
||||
if err := cmd.Execute(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user