https://pulumi.com logo
#typescript
Title
# typescript
r

red-area-47037

11/12/2020, 5:42 PM
Hi all, I am fighting with the right format to pass in a config setting for a Helm Chart I am deploying using Pulumi and I hope someone can help me out. We use Pulumi to bootstrap all core components which includes ArgoCD which will then deploy services developed by our teams. ArgoCD allows the configuration of private Gitrepos via Helm Values. You can find an example of the expected syntax here: https://github.com/argoproj/argo-helm/blob/1f67a85a587182a5f741cb3f846eeb6f2ec887ce/charts/argo-cd/values.yaml#L528
Copy code
repositories: |
      - url: git@github.com:group/repo.git
        sshPrivateKeySecret:
          name: secret-name
          key: sshPrivateKey
In Pulumi I use the following code to deploy the ArgoCD chart and try to pass in the relevant configuration for the repositories as part of the values. The values are defined in Javascript Object notation and I don't know how I can define the configration in the expected literal YAML block scalar format...
Copy code
const argocdChart = new k8s.helm.v3.Chart(
  'argocd',
  {
    chart: 'argo-cd',
    namespace: 'argocd',
    version: '2.9.3',
    fetchOpts: {
      repo: '<https://argoproj.github.io/argo-helm>'
    },
    values: {
      configs: {
        secret: {
          argocdServerAdminPassword: config.argocd.passwordHash
        }
      },
      server: {
        config: {
          'application.instanceLabelKey': '<http://argocd.argoproj.io/instance|argocd.argoproj.io/instance>', 
          repositories: `
            - url: "<https://github.com/mycorp/myprivaterepo>"
              passwordSecret:
                name: "${argocdGitHubTokenSecretName}", 
                key: "password"
              usernameSecret:
                name: "${argocdGitHubTokenSecretName}", 
                key: "username"`,
            }
      }
    }
  },
  {
    provider: cluster.provider,
    dependsOn: [certmanager]
  }
)
I tried different solutions (e.g. Raw string
as you see above or just using js object notation), but somehow nothing so far worked and I am stuck right now 😞 I know this is basically more a Typescript / Javascript question, but I hope someone of you has the right tip. Thanks, Andreas
b

billowy-army-68599

11/12/2020, 5:45 PM
It's because you're trying to get around the YAML anchors, luckily, JSON is also valid YAML, so I do this create an object: https://github.com/lbrlabs/pulumi-homelab/blob/master/argocd/index.ts#L34-L40 use
JSON.stringify
to encode that object: https://github.com/lbrlabs/pulumi-homelab/blob/master/argocd/index.ts#L55
r

red-area-47037

11/12/2020, 7:48 PM
wow, thx @billowy-army-68599 this was exactly what I was looking for 😉
anf thinking about it, pretty straight forward 😉 cool
8 Views