Functions don't seem to work at all
filiy opened this issue · 3 comments
Trying to use functions fails with errors. I've tried upper, lower, lookup, and regexFind and all get the same error "function not defined"
This example of creating a namespace from a namespace with a label (goal here is to use one namespace to provision multiple environment namespaces)
Config:
---
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: multi-project
spec:
labelSelector:
matchLabels:
multienv: "true"
templates:
- objectTemplate: |
- apiVersion: v1
kind: Namespace
metadata:
name: {{ .Name | upper }}-prod
Error from operator pod:
name: {{ .Name | upper }}-prod\n:4: function \"upper\" not defined","stacktrace":"github.com/go-logr/zapr.(*zapLogger).Error\n\t/home/travis/gopath/pkg/mod/github.com/go-logr/zapr@v0.1.1/zapr.go:128\ngithub.com/redhat-cop/operator-utils/pkg/util/lockedresourcecontroller/lockedresource.GetLockedResourcesFromTemplates\n\t/home/travis/gopath/pkg/mod/github.com/redhat-cop/operator-utils@v0.3.4/pkg/util/lockedresourcecontroller/lockedresource/locked-resource.go:75\ngithub.com/redhat-cop/namespace-configuration-operator/pkg/controller/namespaceconfig.(*ReconcileNamespaceConfig).getResourceList\n\t/home/travis/gopath/src/github.com/redhat-cop/namespace-configuration-operator/pkg/controller/namespaceconfig/namespaceconfig_controller.go:232\ngithub.com/redhat-cop/namespace-configuration-operator/pkg/controller/namespaceconfig.(*ReconcileNamespaceConfig).Reconcile\n\t/home/travis/gopath/src/github.com/redhat-cop/namespace-configuration-operator/pkg/controller/namespaceconfig/namespaceconfig_controller.go:183\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/home/travis/gopath/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.0/pkg/internal/controller/controller.go:256\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/home/travis/gopath/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.0/pkg/internal/controller/controller.go:232\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).worker\n\t/home/travis/gopath/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.0/pkg/internal/controller/controller.go:211\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1\n\t/home/travis/gopath/pkg/mod/k8s.io/apimachinery@v0.18.2/pkg/util/wait/wait.go:155\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil\n\t/home/travis/gopath/pkg/mod/k8s.io/apimachinery@v0.18.2/pkg/util/wait/wait.go:156\nk8s.io/apimachinery/pkg/util/wait.JitterUntil\n\t/home/travis/gopath/pkg/mod/k8s.io/apimachinery@v0.18.2/pkg/util/wait/wait.go:133\nk8s.io/apimachinery/pkg/util/wait.Until\n\t/home/travis/gopath/pkg/mod/k8s.io/apimachinery@v0.18.2/pkg/util/wait/wait.go:90"}
the function feature is not released yet, so if you want to use you'll have to build your own image or pull the :latest
.
if you are doing that already then we probably have a bug and I would like to better understand your use case.
@cnuland cc
Ahh that would make sense. The readme explains how to use functions which is why I thought they were working.
I can try and pull latest and test again.
The use case here is to use to use something other than {{ .Name }} variable for creating objects. Say we have a group called projectname-admins. I want to create multiple namespaces with just the projectname portion of the group name like projectname-stg, -prod, etc.
This could be a knowledge gap thing on my end too.
Functions are working with the latest image. This is working for my needs. Happy to close this. Maybe update the readme to call this out?