Skip to content

Commit 6c1ef1b

Browse files
authored
Merge pull request #1168 from fluxcd/fix-docs-github-dispatch
docs: Fix GitHub dispatch example
2 parents 6554603 + b8f0c5a commit 6c1ef1b

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

docs/spec/v1beta3/providers.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,14 +1522,14 @@ you need to set the event type for the repository_dispatch trigger to match the
15221522
name: test-github-dispatch-provider
15231523
on:
15241524
repository_dispatch:
1525-
types: [Kustomization/podinfo.flux-system]
1525+
types: [Kustomization/app1.apps]
15261526
```
15271527

15281528
Assuming that we deploy all Flux kustomization resources in the same namespace,
15291529
it will be useful to have a unique kustomization resource name for each application.
15301530
This will allow you to use only `event_type` to trigger tests for the exact application.
15311531

1532-
Let's say we have following folder structure for applications kustomization manifests:
1532+
Let's say we have the following kustomize overlays structure for two applications:
15331533

15341534
```bash
15351535
apps/
@@ -1543,21 +1543,21 @@ apps/
15431543
└── staging
15441544
```
15451545

1546-
You can then create a flux kustomization resource for the app to have unique `event_type` per app.
1546+
You can then create a Flux Kustomization resource for the app to have unique `event_type` per app.
15471547
The kustomization manifest for app1/staging:
15481548

15491549
```yaml
1550-
apiVersion: kustomize.toolkit.fluxcd.io/v1beta3
1550+
apiVersion: kustomize.toolkit.fluxcd.io/v1
15511551
kind: Kustomization
15521552
metadata:
15531553
name: app1
1554-
namespace: flux-system
1554+
namespace: apps
15551555
spec:
15561556
path: "./app1/staging"
15571557
```
15581558

1559-
You would also like to know from the notification which cluster is being used for deployment.
1560-
You can add the `spec.summary` field to the Flux alert configuration to mention the relevant cluster:
1559+
You would also like to know from the notification which environment the event is coming from.
1560+
You can add the `spec.eventMetadata` field to the Flux Alert and mention the relevant environment info:
15611561

15621562
```yaml
15631563
apiVersion: notification.toolkit.fluxcd.io/v1beta3
@@ -1566,13 +1566,15 @@ metadata:
15661566
name: github-dispatch
15671567
namespace: flux-system
15681568
spec:
1569-
summary: "staging (us-west-2)"
1569+
eventMetadata:
1570+
env: "staging"
1571+
region: "us-west-2"
15701572
providerRef:
15711573
name: github-dispatch
15721574
eventSeverity: info
15731575
eventSources:
15741576
- kind: Kustomization
1575-
name: 'podinfo'
1577+
name: app1
15761578
```
15771579

15781580
Now you can trigger the tests in the GitHub workflow for app1 in a staging cluster when
@@ -1582,11 +1584,13 @@ the app1 resources defined in `./app1/staging/` are reconciled by Flux:
15821584
name: test-github-dispatch-provider
15831585
on:
15841586
repository_dispatch:
1585-
types: [Kustomization/podinfo.flux-system]
1587+
types: [Kustomization/app1.apps]
15861588
jobs:
15871589
run-tests-staging:
1588-
if: github.event.client_payload.metadata.summary == 'staging (us-west-2)'
1589-
runs-on: ubuntu-18.04
1590+
if: |
1591+
github.event.client_payload.metadata.env == 'staging' &&
1592+
github.event.client_payload.severity == 'info'
1593+
runs-on: ubuntu-latest
15901594
steps:
15911595
- name: Run tests
15921596
run: echo "running tests.."

0 commit comments

Comments
 (0)