Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templates using the lookup function fail to render #31

Open
gberche-orange opened this issue Jan 5, 2021 · 1 comment
Open

templates using the lookup function fail to render #31

gberche-orange opened this issue Jan 5, 2021 · 1 comment

Comments

@gberche-orange
Copy link

Describe the bug

As a hcunit user

  • in order to assert templates making use of the lookup function
  • I need hcunit to support this keyword

To Reproduce

With the following serviceinstance.yml template

apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceInstance
  {{ $serviceInstance:= ( lookup "servicecatalog.k8s.io/v1beta1" "ServiceInstance" .Release.Namespace  $fullName) -}}
metadata:
  namespace: {{ .Release.Namespace }}
  name: {{ include "p-mysql.fullname" . }}
  labels:
  {{- include "p-mysql.labels" . | nindent 4 }}
spec:

  #Let svcat reference service class and service plans from external names (i.e. OSB names)
  #See https://github.com/kubernetes-sigs/service-catalog/blob/a204c0d26c60b42121aa608c39a179680e499d2a/contrib/examples/walkthrough/mini-instance.yaml#L1-L11
  clusterServiceClassExternalName: {{ .Values.serviceClassName }}
  clusterServicePlanExternalName: {{ .Values.servicePlanName }}

when running

 helm unit eval -t templates/ -c values.yaml -p my_assert.rego

then

error while rendering: parse error in "hcunit/templates/serviceinstance.yaml": template: hcunit/templates/serviceinstance.yaml:3: function "lookup" not defined
Error: plugin "unit" exited with error
helm.go:81: [debug] plugin "unit" exited with error

on version 0.7.5

@gberche-orange
Copy link
Author

gberche-orange commented Jan 5, 2021

Tried to workaround the issue with a if/else/end block with a onlyDuringUnitTest value, but this did not help.

The only workaround I found is to only assert templates without the lookup function :-(

gberche-orange added a commit to orange-cloudfoundry/osb-to-helm-poc that referenced this issue Jan 5, 2021
Note: this breaks hcunit tests, submitted xchapter7x/hcunit#31 did not yet find a workaround
gberche-orange added a commit to orange-cloudfoundry/osb-to-helm-poc that referenced this issue Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant