Skip to content

Commit

Permalink
chore(demos): create csv for some usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
davidB committed Oct 28, 2024
1 parent fd18eee commit eb44520
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 35 deletions.
5 changes: 5 additions & 0 deletions demos/example_01/202401-dev-uat-prods.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
timestamp,id,env,artifact_id
2024-01-01T11:00:00.926Z,app-a,group1-dev/eu-1/ns-a,pkg:oci/[email protected]
2024-01-01T11:30:00.926Z,app-a,group1-uat/eu-1/ns-a,pkg:oci/[email protected]
2024-01-02T13:10:00.926Z,app-a,group1-prod/eu-2/ns-a,pkg:oci/[email protected]
2024-01-02T13:10:10.926Z,app-a,group1-prod/us-2/ns-a,pkg:oci/[email protected]
5 changes: 5 additions & 0 deletions demos/example_01/202402-dev-uat-prod1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
timestamp,id,env,artifact_id
2024-02-01T11:00:00.926Z,app-a,group1-dev/eu-1/ns-a,pkg:oci/[email protected]
2024-02-01T11:30:00.926Z,app-a,group1-uat/eu-1/ns-a,pkg:oci/[email protected]
2024-02-02T13:10:00.926Z,app-a,group1-prod/eu-2/ns-a,pkg:oci/[email protected]
2024-02-03T13:10:10.926Z,app-a,group1-prod/us-2/ns-a,pkg:oci/[email protected]
2 changes: 2 additions & 0 deletions demos/example_01/202403-dev.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
timestamp,id,env,artifact_id
2024-03-01T11:00:00.926Z,app-a,group1-dev/eu-1/ns-a,pkg:oci/[email protected]
3 changes: 3 additions & 0 deletions demos/example_01/202404-dev-uat.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
timestamp,id,env,artifact_id
2024-04-01T11:00:00.926Z,app-b,group1-dev/eu-1/ns-b,pkg:oci/app-b@f2b4da
2024-04-01T11:30:00.926Z,app-b,group1-uat/eu-1/ns-b,pkg:oci/app-b@f2b4da
3 changes: 3 additions & 0 deletions demos/example_01/202405-dev-prod.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
timestamp,id,env,artifact_id
2024-05-01T11:00:00.926Z,app-b,group1-dev/eu-1/ns-b,pkg:oci/[email protected]
2024-05-01T11:30:00.926Z,app-b,group1-prod/eu-2/ns-b,pkg:oci/[email protected]
25 changes: 25 additions & 0 deletions demos/example_01/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Examples of use cases

## Context

- artifacts:
- format: [purl](https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst) short:`scheme:type/namespace/name@version?qualifiers#subpath`
- type: `oci`
- namespace: `` (none)
- name x several versions (and convention):
- `app-a` (semver only): `0.0.1`, `0.1.0`, `1.0.0`
- `app-b` (git describe + semver): `f2b4da`, `a32d55` `0.1.0-2-ge453fae`
- environments:
- format `{cluster}/{namespace}` => `{family}-{stage}/{region}/{namespace}`
- family: `group1`
- stages: `dev`, `uat`, `prod`
- regions: `eu-1`, `eu-2`, `us-2` (dev and uat on `eu-1`, prod on `us-2` and `eu-2`)
- namespace: `ns-a`, `ns-b`

## Scenarii

- sequence stages: [202401-dev-uat-prods](`202401-dev-uat-prods.csv`): dev -> uat -> all prod
- sequence clusters: [202402-dev-uat-prod1](`202402-dev-uat-prod1.csv`): dev -> uat -> prod 1 -> prod 2
- wip: [202403-dev](`202403-dev.csv`): dev
- rejected on uat: [202404-dev-uat](`202404-dev-uat.csv`): dev -> uat
- hotfix: [202405-dev-prod](`202405-dev-prod.csv`): dev -> prod 1
6 changes: 0 additions & 6 deletions demos/example_01/cdevents/cdevents.csv

This file was deleted.

70 changes: 41 additions & 29 deletions demos/example_01/cdviz-collector.toml
Original file line number Diff line number Diff line change
@@ -1,47 +1,59 @@
[sinks.debug]
type = "debug"

[sinks.cdviz_db]
enabled = true
type = "db"
url = "postgresql://cdviz:[email protected]:5432/cdviz"
pool_connections_min = 1
pool_connections_max = 10

[sources.cdevents_json]
[sources.cdevents_local_json]
enabled = true

[sources.cdevents_local_json.extractor]
type = "opendal"
kind = "fs"
polling_interval = "10s"
polling_interval = "60s"
parameters = { root = "./cdevents" }
recursive = false
recursive = true
path_patterns = ["*.json"]
transformer = { extractor = "json" }
parser = "json"

[sources.cdevents_csv]
[sources.cdevents_local_csv]
enabled = true

[sources.cdevents_local_csv.extractor]
type = "opendal"
kind = "fs"
polling_interval = "10s"
polling_interval = "20s"
parameters = { root = "./cdevents" }
recursive = false
path_patterns = ["cdevents.csv"]
transformer = { extractor = "csv_row", transform = { format = "hbs", content = """
path_patterns = ["*.csv"]
parser = "csv_row"

[[sources.cdevents_local_csv.transformers]]
type = "hbs"
template = """
{
"context": {
"version": "0.4.0-draft",
"id": "{{ content.uuid }}",
"source": "/event/source/123",
"type": "dev.cdevents.service.deployed.0.1.1",
"timestamp": "{{ content.timestamp }}"
},
"subject": {
"id": "{{ content.id }}",
"source": "/event/source/123",
"type": "service",
"content": {
"environment": {
"id": "{{ content.env }}"
},
"artifactId": "{{ content.artifact_id }}"
"metadata": {{ json_to_str metadata }},
"header": {{ json_to_str header }},
"body": {
"context": {
"version": "0.4.0-draft",
"id": "0",
"source": "/event/source/123",
"type": "dev.cdevents.service.deployed.0.1.1",
"timestamp": "{{ body.timestamp }}"
},
"subject": {
"id": "{{ body.id }}",
"source": "/event/source/123",
"type": "service",
"content": {
"environment": {
"id": "{{ body.env }}"
},
"artifactId": "{{ body.artifact_id }}"
}
}
}
}
}
""" } }
"""

0 comments on commit eb44520

Please sign in to comment.