0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Helmチャート(Go Template)のループの中で上位スコープの変数を参照する方法

Posted at

概要

ループの手前で変数を定義し、それを参照します。

まずvalues.yamlの変数を定義

repository:
  username: craftsman-software
  name: focas

branches:
  - name: main
    project: focas
    service: web
    environment: prod
  - name: prototype
    project: focas
    service: web
    environment: prototype
# ループの前で変数定義
{{ $repositoryFullName := printf "%s/%s" .Values.repository.username .Values.repository.name }}

apiVersion: triggers.tekton.dev/v1alpha1
kind: EventListener
metadata:
  name: eventlistener-focas
  namespace: focas
spec:
  serviceAccountName: focas-pipeline-sa
  triggers:
    {{- range .Values.branches }}
    - name: github-push-listener-for-{{ .name }}
      interceptors:
        - name: "only when specified branch"
          ref:
            name: cel
          params:
            - name: filter
              # ループないで事前に定義した変数を参照
              value: "body.repository.full_name in ['{{ $repositoryFullName }}']"
            - name: filter
              value: "body.ref in ['refs/heads/{{ .name }}']"
      bindings:
        - ref: pipelinebinding-focas-for-{{ .name }}
      template:
        ref: triggertemplate-focas
      {{- end }}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?