# [sinks.database]
# enabled = true
# type = "db"
# url = "postgresql://postgres:passwd@localhost:5432/cdviz?search_path=cdviz"
# pool_connections_min = 1
# pool_connections_max = 10

# [sinks.sse_001]
# # This will create an SSE endpoint at http://localhost:8080/sse/001
# enabled = false
# type = "sse"
# id = "001"
# [sinks.sse_001.headers]
# "Authorization" = { type = "exists" }
# "X-API-Key" = { type = "matches", pattern = "^[a-zA-Z0-9]{32}$" }

[sinks.cdevents_local_json]
enabled = false
parameters = { root = "./sinks.off" }

[sources.cdevents_local_json]
enabled = true

[sources.cdevents_local_json.extractor]
parameters = { root = "./inputs/cdevents_json" }

[sources.cdevents_local_csv]
enabled = true
transformer_refs = ["service_deployed"]

[sources.cdevents_local_csv.extractor]
type = "opendal"
kind = "fs"
polling_interval = "10s"
parameters = { root = "./inputs" }
recursive = false
path_patterns = ["cdevents.csv"]
parser = "csv_row"
metadata = { environment_id = "/cluster-d"}

[sources.cdevents_webhook]
enabled = true
# type = "http"

[transformers.service_deployed]
type = "vrl"
template = """
[{
    "metadata": .metadata,
    "headers": .headers,
    "body": {
        "context": {
            "version": "0.4.1",
            "id": "0",
            "source": .metadata.context.source,
            "type": "dev.cdevents.service.deployed.0.1.1",
            "timestamp": .body.timestamp,
        },
        "subject": {
            "id": .body.id,
            "type": "service",
            "content": {
                "environment": {
                    "id": .body.env || .metadata.environment_id,
                },
                "artifactId": .body.artifact_id,
            }
        }
    }
}]
"""

# [sources.cdevents_sse]
# enabled = false

# [sources.cdevents_sse.extractor]
# type = "sse"
# url = "http://localhost:8080/sse/001"
# max_retries = 10

# [sources.cdevents_sse.extractor.headers]
# "Authorization" = { type = "static", value = "Bearer your-token-here" }
# "X-API-Key" = { type = "secret", value = "your-api-key-from-env" }
# "X-Signature-256" = { type = "signature", token = "webhook-secret", signature_prefix = "sha256=" }
