profile
viewpoint

Ask questionserror calling eq: invalid type for comparison

<!-- If you need help or think you have found a bug, please help us with your issue by entering the following information (otherwise you can delete this text): -->

I have a chart template which contains this line

  {{- if eq $.Values.global.environment "dev" }}

When running helm lint this fails:

> helm lint my-services/
==> Linting my-services/
[INFO] Chart.yaml: icon is recommended
[ERROR] templates/: render error in "my-services/templates/istio-gateway.yaml": template: acquiring-services/templates/istio-gateway.yaml:64:9: executing "my-services/templates/istio-gateway.yaml" at <eq $.Values.global.e...>: error calling eq: invalid type for comparison

Interestingly I have the same comparison - just with another string - in line 8, which is not a problem at all. Removing the erronous line makes lint passing successfully

helm lint my-services/
==> Linting my-services/
[INFO] Chart.yaml: icon is recommended

1 chart(s) linted, no failures

Here the relevant yaml-file:

kind: VirtualService
metadata:
  name: acquiring-gateway-virtualservice
  namespace: {{ default $.Release.Namespace }}
spec:
  hosts:
  {{- if eq $.Release.Namespace $.Values.global.defaultNamespace }}
  {{- if eq $.Values.global.environment "prd" }}
  - {{ $.Values.global.ingressName }}.{{$.Values.global.environment}}.sc.intra
  {{- else }}
  - {{ $.Values.global.ingressName }}.svc.{{$.Values.global.environment}}.sc.intra
  {{- end }}
  {{- else }}
  - {{ $.Values.global.ingressName }}-{{ default $.Release.Namespace }}.svc.{{$.Values.global.environment}}.sc.intra
  {{- end }}
  gateways:
  - acquiring-gateway
  http:
  - match:
    - uri:
        prefix: /uaa

        prefix: /uaa/
    route:
    - destination:
        port:
          number: 80
        host: auth-server.{{ $.Release.Namespace }}.svc.cluster.local
    corsPolicy:
      allowOrigin:
      - '*'
      allowMethods:
      - OPTIONS
        - GET
        - PUT
        - POST
        - PATCH
      allowHeaders:
      - authorization

  {{- if eq $.Values.global.environment "dev" }}
  - match:

Also following the suggestion under #2979 does not help

Output of helm version:

Client: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}

Output of kubectl version:

N/A

Cloud Provider/Platform (AKS, GKE, Minikube etc.):

On-Premise

helm/helm

Answer questions papanito

Well, if I do this

#{{- if eq $.Release.Namespace $.Values.global.defaultNamespace }}
{{- if eq $.Values.global.environment "prd" }}
- {{ $.Values.global.ingressName }}.{{$.Values.global.environment}}.sc.intra
{{- else }}
- {{ $.Values.global.ingressName }}.svc.{{$.Values.global.environment}}.intra
{{- end }}
#{{- else }}
#- {{ $.Values.global.ingressName }}-{{ default $.Release.Namespace }}.svc.{{$.Values.global.environment}}.intra
#{{- end }}

lint does not complain.

useful!

Related questions

Error: validation: chart.metadata is required when using --repo - helm hot 4
"Error: Transport is closing" message when attempting to install hot 2
Error: open .helm\repository\cache\local-index.yaml hot 2
"helm dep build" fails if requirements.yaml contains local dependencies and remote one hot 2
Helm upgrade fails the release after adding a new resource hot 2
Error: could not find a ready tiller pod hot 2
Error: apiVersion 'v2' is not valid. The value must be "v1" hot 2
Unable to start Tiller pod, bind address already in use hot 2
Upgrading releases with immutable resources (e.g. persitentVolume) hot 2
helm 3: Not able to push chart to docker hub hot 1
`helm upgrade --recreate-pods` flag should do a soft restart - helm hot 1
Helm3: No 'init', doesn't use existing ~/.helm hot 1
No kind Job is registered for version batch/v1 hot 1
`Error: rendered manifests contain a resource that already exists` but nothing shows up on `helm list --all` - helm hot 1
upgrade apiVersion in k8s from 1.14 to 1.16 FAILED hot 1
Github User Rank List