diff --git a/charts/gitops-runtime/templates/_components/event-reporters/_helpers.tpl b/charts/gitops-runtime/templates/_components/event-reporters/_helpers.tpl index f8dd300e..d3783d6c 100644 --- a/charts/gitops-runtime/templates/_components/event-reporters/_helpers.tpl +++ b/charts/gitops-runtime/templates/_components/event-reporters/_helpers.tpl @@ -134,6 +134,10 @@ assumes the name, condition and payload.dependencyName are identical retryStrategy: {{- .retryStrategy | toYaml | nindent 4 }} {{- end }} + {{- if .policy }} + policy: + {{- .policy | toYaml | nindent 4 }} + {{- end }} {{- end -}} {{/* Logging trigger for the sensor - gets sensor.logging dict */}} diff --git a/charts/gitops-runtime/templates/_components/event-reporters/rollout-reporter/_sensor.yaml b/charts/gitops-runtime/templates/_components/event-reporters/rollout-reporter/_sensor.yaml index 6639b51b..c58b073a 100644 --- a/charts/gitops-runtime/templates/_components/event-reporters/rollout-reporter/_sensor.yaml +++ b/charts/gitops-runtime/templates/_components/event-reporters/rollout-reporter/_sensor.yaml @@ -40,8 +40,8 @@ spec: {{- . | toYaml | nindent 6 }} {{- end }} triggers: - {{- include "event-reporters.http.trigger" (dict "name" "rollouts" "Values" .Values "payloadDest" "data.object" "retryStrategy" .Values.rollout.sensor.retryStrategy) | nindent 4 }} - {{- include "event-reporters.http.trigger" (dict "name" "replicasets" "Values" .Values "payloadDest" "data.object" "retryStrategy" .Values.rollout.sensor.retryStrategy) | nindent 4 }} - {{- include "event-reporters.http.trigger" (dict "name" "analysisruns" "Values" .Values "payloadDest" "data.object" "retryStrategy" .Values.rollout.sensor.retryStrategy) | nindent 4 }} + {{- include "event-reporters.http.trigger" (dict "name" "rollouts" "Values" .Values "payloadDest" "data.object" "retryStrategy" .Values.rollout.sensor.retryStrategy "policy" .Values.rollout.sensor.policy) | nindent 4 }} + {{- include "event-reporters.http.trigger" (dict "name" "replicasets" "Values" .Values "payloadDest" "data.object" "retryStrategy" .Values.rollout.sensor.retryStrategy "policy" .Values.rollout.sensor.policy) | nindent 4 }} + {{- include "event-reporters.http.trigger" (dict "name" "analysisruns" "Values" .Values "payloadDest" "data.object" "retryStrategy" .Values.rollout.sensor.retryStrategy "policy" .Values.rollout.sensor.policy) | nindent 4 }} {{- include "event-reporters.log.trigger" (.Values.rollout.sensor.logging) | nindent 4 }} {{- end }} diff --git a/charts/gitops-runtime/templates/_components/event-reporters/workflow-reporter/_sensor.yaml b/charts/gitops-runtime/templates/_components/event-reporters/workflow-reporter/_sensor.yaml index 77f02f91..abe1b662 100644 --- a/charts/gitops-runtime/templates/_components/event-reporters/workflow-reporter/_sensor.yaml +++ b/charts/gitops-runtime/templates/_components/event-reporters/workflow-reporter/_sensor.yaml @@ -34,6 +34,6 @@ spec: {{- . | toYaml | nindent 6 }} {{- end }} triggers: - {{- include "event-reporters.http.trigger" (dict "name" "workflows" "Values" .Values "payloadDest" "data.object" "retryStrategy" .Values.workflow.sensor.retryStrategy) | nindent 4 }} + {{- include "event-reporters.http.trigger" (dict "name" "workflows" "Values" .Values "payloadDest" "data.object" "retryStrategy" .Values.workflow.sensor.retryStrategy "policy" .Values.workflow.sensor.policy) | nindent 4 }} {{- include "event-reporters.log.trigger" (.Values.workflow.sensor.logging) | nindent 4 }} {{- end }} diff --git a/charts/gitops-runtime/templates/eventbus/codefresh-eventbus.yaml b/charts/gitops-runtime/templates/eventbus/codefresh-eventbus.yaml index 571e578e..d9957b19 100644 --- a/charts/gitops-runtime/templates/eventbus/codefresh-eventbus.yaml +++ b/charts/gitops-runtime/templates/eventbus/codefresh-eventbus.yaml @@ -1,5 +1,6 @@ {{- $eventBusName := default "codefresh-eventbus" .Values.global.runtime.eventBus.name }} {{- $eventBusSpec := .Values.global.runtime.eventBus }} +{{- $eventBusType := .Values.global.runtime.eventBus.type }} {{/* Remove name from eventbus spec */}} {{- if hasKey $eventBusSpec "name" }} {{- $eventBusSpec = unset $eventBusSpec "name" }} @@ -8,12 +9,22 @@ {{- if hasKey $eventBusSpec "pdb" }} {{- $eventBusSpec = unset $eventBusSpec "pdb" }} {{- end }} +{{/* Remove annotations from eventbus spec */}} {{- if hasKey $eventBusSpec "annotations" }} {{- $eventBusSpec = unset $eventBusSpec "annotations" }} {{- end }} -{{- $_ := set $eventBusSpec.nats.native "nodeSelector" ($eventBusSpec.nats.native.nodeSelector | default .Values.global.nodeSelector) }} -{{- $_ := set $eventBusSpec.nats.native "tolerations" ($eventBusSpec.nats.native.tolerations | default .Values.global.tolerations) }} +{{- if eq $eventBusType "nats" }} + {{- $eventBusSpec = unset $eventBusSpec "jetstream" }} + {{- $_ := set $eventBusSpec.nats.native "nodeSelector" ($eventBusSpec.nats.native.nodeSelector | default .Values.global.nodeSelector) }} + {{- $_ := set $eventBusSpec.nats.native "tolerations" ($eventBusSpec.nats.native.tolerations | default .Values.global.tolerations) }} +{{- end }} + +{{- if eq $eventBusType "jetstream" }} + {{- $eventBusSpec = unset $eventBusSpec "nats" }} + {{- $_ := set $eventBusSpec.jetstream "nodeSelector" ($eventBusSpec.jetstream.nodeSelector | default .Values.global.nodeSelector) }} + {{- $_ := set $eventBusSpec.jetstream "tolerations" ($eventBusSpec.jetstream.tolerations | default .Values.global.tolerations) }} +{{- end }} apiVersion: argoproj.io/v1alpha1 kind: EventBus diff --git a/charts/gitops-runtime/tests/event-reporters-sensors_test.yaml b/charts/gitops-runtime/tests/event-reporters-sensors_test.yaml index 340b5879..4fe6a30c 100644 --- a/charts/gitops-runtime/tests/event-reporters-sensors_test.yaml +++ b/charts/gitops-runtime/tests/event-reporters-sensors_test.yaml @@ -245,3 +245,20 @@ tests: factor: 1.2 jitter: 3 + - it: HTTP trigger contains policy if set - workflow reporter + template: 'event-reporters/workflow-reporter/sensor.yaml' + values: + - './values/mandatory-values.yaml' + set: + event-reporters.workflow.sensor: + policy: + status: + allow: + - 200 + asserts: + - equal: + path: spec.triggers[0].policy + value: + status: + allow: + - 200 diff --git a/charts/gitops-runtime/tests/eventbus_test.yaml b/charts/gitops-runtime/tests/eventbus_test.yaml new file mode 100644 index 00000000..f15c6462 --- /dev/null +++ b/charts/gitops-runtime/tests/eventbus_test.yaml @@ -0,0 +1,28 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json +suite: eventbus tests +templates: + - eventbus/codefresh-eventbus.yaml +tests: + - it: Should create an EventBus with the correct type (nats) + template: eventbus/codefresh-eventbus.yaml + values: + - ./values/mandatory-values.yaml + set: + global.runtime.eventBus.type: nats + asserts: + - exists: + path: spec.nats + - notExists: + path: spec.jetstream + + - it: Should create an EventBus with the correct type (jetstream) + template: eventbus/codefresh-eventbus.yaml + values: + - ./values/mandatory-values.yaml + set: + global.runtime.eventBus.type: jetstream + asserts: + - exists: + path: spec.jetstream + - notExists: + path: spec.nats diff --git a/charts/gitops-runtime/values.yaml b/charts/gitops-runtime/values.yaml index 470790fa..9f170218 100644 --- a/charts/gitops-runtime/values.yaml +++ b/charts/gitops-runtime/values.yaml @@ -89,6 +89,7 @@ global: enabled: true # -- Minimum number of available eventbus pods. For eventbus to stay functional the majority of its replicas should always be available. minAvailable: 2 + type: nats # -- Eventbus type. Can be nats or jetstream. nats: native: nodeSelector: {} @@ -107,6 +108,24 @@ global: cpu: 200m memory: 1Gi ephemeral-storage: 2Gi + jetstream: + version: latest + nodeSelector: {} + tolerations: [] + affinity: {} + replicas: 3 + maxPayload: "4MB" + containerTemplate: + resources: + limits: + cpu: 500m + memory: 4Gi + ephemeral-storage: 2Gi + requests: + cpu: 200m + memory: 1Gi + ephemeral-storage: 2Gi + # -- Configuration for external ArgoCD # Should be used when `argo-cd.enabled` is set to false external-argo-cd: