update cmd/config e2e tests with new go function framework

This commit is contained in:
Phillip Wittrock
2020-05-08 09:10:15 -07:00
parent 83c7c29132
commit cc84eb108d
5 changed files with 18 additions and 13 deletions

View File

@@ -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 {