Skip to content

Commit

Permalink
Merge pull request #10 from mia-platform/feat/add-source-configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebianchi authored Nov 15, 2024
2 parents 42d04cf + 2588957 commit d7b3130
Show file tree
Hide file tree
Showing 13 changed files with 280 additions and 241 deletions.
2 changes: 1 addition & 1 deletion .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default: true
MD003:
style: atx
MD010: false
MD010: true
MD013:
line_length: 120
heading_line_length: 80
Expand Down
62 changes: 32 additions & 30 deletions docs/10_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,38 @@ to save data into the collection `jira-issues`.

```json
{
"integrations": [
{
"type": "jira",
"authentication": {
"secret": {
"fromEnv": "JIRA_SECRET"
}
},
"processors": [
{
"type": "mapper",
"outputEvent": {
"key": "{{ issue.key }}",
"summary": "{{ issue.fields.summary }}",
"createdAt": "{{ issue.fields.created }}",
"description": "{{ issue.fields.description }}"
}
}
],
"sinks": [
{
"type": "mongo",
"url": {
"fromEnv": "MONGO_URL"
},
"collection": "jira-issues"
}
]
}
]
"integrations": [
{
"source": {
"type": "jira",
"authentication": {
"secret": {
"fromEnv": "JIRA_SECRET"
}
}
},
"processors": [
{
"type": "mapper",
"outputEvent": {
"key": "{{ issue.key }}",
"summary": "{{ issue.fields.summary }}",
"createdAt": "{{ issue.fields.created }}",
"description": "{{ issue.fields.description }}"
}
}
],
"sinks": [
{
"type": "mongo",
"url": {
"fromEnv": "MONGO_URL"
},
"collection": "jira-issues"
}
]
}
]
}
</details>
```
12 changes: 7 additions & 5 deletions docs/20_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ The following is an example of a configuration for integrate source `Jira` with
{
"integrations": [
{
"type": "jira",
"authentication": {
"secret": {
"fromFile": "testdata/secret"
}
"source": {
"type": "jira",
"authentication": {
"secret": {
"fromFile": "testdata/secret"
}
},
},
"processors": [
{
Expand Down
10 changes: 7 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ type Authentication struct {
type Processors []GenericConfig
type Sinks []GenericConfig

type Integration struct {
type Source struct {
Type string `json:"type"`
Authentication Authentication `json:"authentication"`
Processors Processors `json:"processors"`
Sinks Sinks `json:"sinks"`
}

type Integration struct {
Source Source `json:"source"`
Processors Processors `json:"processors"`
Sinks Sinks `json:"sinks"`
}

type Configuration struct {
Expand Down
207 changes: 110 additions & 97 deletions internal/config/config.schema.json
Original file line number Diff line number Diff line change
@@ -1,99 +1,112 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"integrations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"jira"
]
},
"authentication": {
"type": "object",
"properties": {
"secret": {
"$ref": "#/definitions/secret"
}
}
},
"processors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"mapper"
]
},
"outputEvent": {
"type": "object"
}
},
"required": [
"type",
"outputEvent"
]
}
},
"sinks": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "mongo"
},
"url": {
"$ref": "#/definitions/secret"
},
"collection": {
"type": "string"
}
},
"required": [
"type",
"url",
"collection"
]
}
]
}
}
},
"required": [
"type",
"sinks"
],
"additionalProperties": false
},
"minItems": 1
}
},
"required": [
"integrations"
],
"additionalProperties": false,
"definitions": {
"secret": {
"type": "object",
"properties": {
"fromEnv": {
"type": "string"
},
"fromFile": {
"type": "string"
}
}
}
}
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"integrations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"source": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"jira"
]
},
"authentication": {
"type": "object",
"properties": {
"secret": {
"$ref": "#/definitions/secret"
}
}
}
},
"required": [
"type"
]
},
"processors": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"mapper"
]
},
"outputEvent": {
"type": "object"
}
},
"required": [
"type",
"outputEvent"
]
}
]
}
},
"sinks": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "mongo"
},
"url": {
"$ref": "#/definitions/secret"
},
"collection": {
"type": "string"
}
},
"required": [
"type",
"url",
"collection"
]
}
]
},
"minItems": 1
}
},
"required": [
"source",
"sinks"
],
"additionalProperties": false
},
"minItems": 1
}
},
"required": [
"integrations"
],
"additionalProperties": false,
"definitions": {
"secret": {
"type": "object",
"properties": {
"fromEnv": {
"type": "string"
},
"fromFile": {
"type": "string"
}
}
}
}
}
8 changes: 5 additions & 3 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ func TestLoadServiceConfiguration(t *testing.T) {
expectedContent: &Configuration{
Integrations: []Integration{
{
Type: "jira",
Authentication: Authentication{
Secret: SecretSource("MY_SECRET"),
Source: Source{
Type: "jira",
Authentication: Authentication{
Secret: SecretSource("MY_SECRET"),
},
},
Processors: Processors{
{
Expand Down
Loading

0 comments on commit d7b3130

Please sign in to comment.