microsoft / vscode-copilot-release

Feedback on GitHub Copilot Chat UX in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat
Creative Commons Attribution 4.0 International
342 stars 37 forks source link

could not resolve the issue for yaml code #2775

Open dan-hoeger opened 16 hours ago

dan-hoeger commented 16 hours ago

Type: Bug

I was getting an error helm.go:84: [debug] parse error at (ardia-core/templates/ingress.yaml:20): unexpected <.> in operand

trying to call the following helm template {{/ Create the name of the team and environment to use for a given string. This changes "default" to the .Values.teamName and "dev" to .Values.environmentName. /}} {{- define "updateTeamAndEnv" -}} {{- $param1 := index . 0 -}} {{- $context := index . 1 -}} {{ $param1 | replace "default" $context.Values.teamName | replace "dev" $context.Values.environmentName -}} {{- end -}}

from this template code: apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ $fullName }} labels: {{- include "ardia-core-services.labels" . | nindent 4 }} {{- with .Values.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} nginx.ingress.kubernetes.io/cors-allow-origin: {{ (include "updateTeamAndEnv" (list .Values.ingress.hosts.primaryHost.domain .)) | quote }} spec: {{- if .Values.ingress.tls }} tls: {{- range .Values.ingress.tls }}

it kept saying: I apologize for the confusion. Let's address the issue by ensuring that the variable scoping within the range loops is handled correctly and that we avoid conflicts with the . variable. Here's the corrected YAML with clear changes:

  1. Use a different variable name within the range loops to avoid conflicts.
  2. Ensure proper indentation.
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "ardia-core-services.fullname" . -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ $fullName }}
  labels:
    {{- include "ardia-core-services.labels" . | nindent 4 }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  nginx.ingress.kubernetes.io/cors-allow-origin: {{ (include "updateTeamAndEnv" (list .Values.ingress.hosts.primaryHost.domain .)) | quote }}
spec:
  {{- if .Values.ingress.tls }}
  tls:
    {{- range .Values.ingress.tls }}
    - hosts:
        {{- range $host := .hosts }}
        - {{ include "updateTeamAndEnv" (list $host $. ) | quote }}

 {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
  rules:
    - host: {{ (include "updateTeamAndEnv" (list .Values.ingress.hosts.primaryHost.domain .)) | quote }}
      http:
        paths:
          {{- range $path := .Values.ingress.hosts.primaryHost.paths }}
          - path: {{ $path.path }}
            pathType: {{ $path.pathType | default "ImplementationSpecific" }}
            backend:
              service:
                name: {{ $path.serviceName }}
                port:
                  number: {{ $path.servicePort | default "80"}}
          {{- end }}
    - host: {{ (include "updateTeamAndEnv" (list .Values.ingress.hosts.identityHost.domain .)) | quote }}
      http:
        paths:
          {{- range $path := .Values.ingress.hosts.identityHost.paths }}
          - path: {{ $path.path }}
            pathType: {{ $path.pathType | default "ImplementationSpecific"}}
            backend:
              service:
                name: {{ $path.serviceName }}
                port:
                  number: {{ $path.servicePort | default "80"}}
          {{- end }}
    - host: {{ (include "updateTeamAndEnv" (list .Values.ingress.hosts.chromeleonIdpHost.domain .)) | quote }}
      http:
        paths:
          {{- range $path := .Values.ingress.hosts.chromeleonIdpHost.paths }}
          - path: {{ $path.path }}
            pathType: {{ $path.pathType | default "ImplementationSpecific"}}
            backend:
              service:
                name: {{ $path.serviceName }}
                port:
                  number: {{ $path.servicePort | default "80"}}
          {{- end }}
    - host: {{ (include "updateTeamAndEnv" (list .Values.ingress.hosts.ardiaIdpHost.domain .)) | quote }}
      http:
        paths:
          {{- range $path := .Values.ingress.hosts.ardiaIdpHost.paths }}
          - path: {{ $path.path }}
            pathType: {{ $path.pathType | default "ImplementationSpecific"}}
            backend:
              service:
                name: {{ $path.serviceName }}
                port:
                  number: {{ $path.servicePort | default "80"}}
          {{- end }}
{{- end }}

In this corrected version, I replaced . with $path within the range loops to avoid conflicts. This should resolve the parse error.

and then it kept giving me the same exact code back

Extension version: 0.22.4 VS Code version: Code 1.95.3 (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z) OS version: Windows_NT x64 10.0.22631 Modes:

System Info |Item|Value| |---|---| |CPUs|13th Gen Intel(R) Core(TM) i7-13850HX (28 x 2304)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off| |Load (avg)|undefined| |Memory (System)|63.69GB (32.37GB free)| |Process Argv|--crash-reporter-id 6c72f5b2-ace6-43e1-be81-3f7d37cf4a30| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 da93g388:31013173 dvdeprecation:31068756 dwnewjupytercf:31046870 newcmakeconfigv2:31071590 nativerepl2:31139839 pythonrstrctxt:31112756 cf971741:31144450 iacca1:31171482 notype1:31157159 5fd0e150:31155592 dwcopilot:31170013 stablechunks:31184530 ```