Argocd-ComparisonError : FailedPrecondition desc = Failed to unmarshal “template-child-apps.yml

I am trying to add if condition in an applicationset

Here is my template-child-apps.yml

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: child-app-template
spec:
  goTemplate: true
  goTemplateOptions: ["missingkey=error"]
  generators:
  - matrix:
      generators:
      - git:
          repoURL: https://github.com/shamonshan/argocd-root
          revision: HEAD
          files:
          - path: configs/config.yml
      - list:
          elements: []
          elementsYaml: "{{ .configs.components | toJson }}"
  template:
    metadata:
      name: '{{.name}}'
    spec:
      project: '{{.configs.project}}'
      destination:
        name: in-cluster
        namespace: '{{.namespace}}'
      source:
         path : helm
        {{- if .type eq "fc" }}
        repoURL: '{{.configs.repos.fc.url}}'
        targetRevision: '{{.configs.repos.fc.commitHash}}'
        {{- end }}
        {{- if .type eq "wl" }}
        repoURL: '{{.configs.repos.wl.url}}'
        targetRevision: '{{.configs.repos.wl.commitHash}}'
        {{- end }}

And here is my config.yaml from the git file generator

configs:  
  project: appbundle-project-dev
  cluster: in-cluster
  cluster-url : https://kubernetes.default.svc
  repos:  
    fc: 
      url: "https://github.com/<user>/argocd-demo-deployment.git"
      commitHash: "HEAD"
    wl: 
      url: "https://github.com/<user>/argocd-demo-deployment-1.git"
      commitHash: "HEAD"
  components:  
    - name: component1
      namespace: app1
      type: "fc"
    - name: component2
      namespace: app2
      type: "wl"

The error which i m getting is

Failed to load target state: failed to generate manifest for source 1 of 1: rpc error: code = FailedPrecondition desc = Failed to unmarshal "template-child-apps.yml": <nil>

Can somebody help me to resolve the issue

Leave a Comment