본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Google Chat

원문 보기 위키 갱신

google chat 웹훅(webhook)으로 메시지 알림을 보내는 Google Chat 알림 서비스예요. 이 서비스는 다음 설정을 사용해요.

출처: 문서

본문

파라미터 (Parameters)

Google Chat 알림 서비스는 google chat 웹훅으로 메시지 알림을 보내요. 이 서비스는 다음 설정을 사용해요.

  • webhooks - webhookName: webhookUrl 형태의 맵(map)이에요

설정 (Configuration)

  • Google chat을 열고 메시지를 보내고 싶은 스페이스(space)로 이동해요
  • 페이지 상단의 메뉴에서 Configure Webhooks를 선택해요
  • Incoming Webhooks 아래에서 Add Webhook을 클릭해요
  • 웹훅에 이름을 정하고, 선택적으로 이미지를 추가한 뒤 Save를 클릭해요
  • 웹훅 옆의 URL을 복사해요
  • argocd-notification-secret에 URL을 저장하고 argo-rollouts-notification-configmap에 선언해요
apiVersion: v1
kind: ConfigMap
metadata:
  name: argo-rollouts-notification-configmap
data:
  service.googlechat: |
    webhooks:
      spaceName: $space-webhook-url
apiVersion: v1
kind: Secret
metadata:
  name: <secret-name>
stringData:
  space-webhook-url: https://chat.googleapis.com/v1/spaces/<space_id>/messages?key=<key>&token=<token>
  • 스페이스에 대한 구독(subscription)을 만들어요
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    notifications.argoproj.io/subscribe.on-sync-succeeded.googlechat: spaceName

템플릿 (Templates)

Google Chat 스페이스에 간단한 텍스트나 카드 메시지를 보낼 수 있어요. 간단한 텍스트 메시지 템플릿은 다음과 같이 정의할 수 있어요.

template.app-sync-succeeded: |
  message: The app {{ .app.metadata.name }} has successfully synced!

카드 메시지는 다음과 같이 정의할 수 있어요.

template.app-sync-succeeded: |
  googlechat:
    cardsV2: |
      - header:
          title: ArgoCD Bot Notification
        sections:
          - widgets:
              - decoratedText:
                  text: The app {{ .app.metadata.name }} has successfully synced!
          - widgets:
              - decoratedText:
                  topLabel: Repository
                  text: {{ call .repo.RepoURLToHTTPS .app.spec.source.repoURL }}
              - decoratedText:
                  topLabel: Revision
                  text: {{ .app.spec.source.targetRevision }}
              - decoratedText:
                  topLabel: Author
                  text: {{ (call .repo.GetCommitMetadata .app.status.sync.revision).Author }}

모든 Card 필드가 지원되며 알림에 사용할 수 있어요. 또한 이전(현재는 폐기된 deprecated) cards 키를 사용해 레거시 카드 필드를 사용할 수도 있지만, Google이 이 필드를 폐기하고 더 새로운 cardsV2를 권장하므로 권장하지 않아요.

카드 메시지는 JSON으로도 작성할 수 있어요.

채팅 스레드 (Chat Threads)

채팅 스레드에서 스레드에 고유한 키를 지정해 간단한 텍스트와 카드 메시지를 모두 보낼 수 있어요. 스레드 키는 다음과 같이 정의할 수 있어요.

template.app-sync-succeeded: |
  message: The app {{ .app.metadata.name }} has successfully synced!
  googlechat:
    threadKey: {{ .app.metadata.name }}

더 알아보기 (Learn more)