hcunit icon indicating copy to clipboard operation
hcunit copied to clipboard

templates using the lookup function fail to render

Open gberche-orange opened this issue 3 years ago • 1 comments

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 avatar Jan 05 '21 14:01 gberche-orange