Skip to content

Commit

Permalink
add documentation and examples to describe how the feature works
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsheah committed Jan 15, 2025
1 parent bbb659c commit 581aa9a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
69 changes: 69 additions & 0 deletions docs/outputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,72 @@ given a single attribute:
For more information on how to use filter expressions, read [Using
expressions](expressions.md) or look at the [Backstage](backstage) example for
real-life use cases.

### Enum attribute

Enums are useful when you have an attribute of 'String' type (both array and non-array), that you'd like to have as as separate catalog type, such as tags. Using the above example of `BackstageAPIType`, we can instead generate it from `BackstageAPI`

```jsonnet
{
sync_id: 'example-org/example-repo',
pipelines: [
// Backstage API
{
sources: [
{
inline: {
entries: [
{
name: "Payments API",
external_id: "payments"
type: "grpc",
}
],
},
},
],
outputs: [
{
name: 'Backstage API',
description: 'APIs that we have',
type_name: 'Custom["BackstageAPI"]',
source: {
name: 'name',
external_id: 'external_id',
},
categories: ['service'],
attributes: [
{
id: "type",
name: "API type",
array: false,
source: "$.type"
enum: {
name: 'Backstage API Type',
description: 'Type or format of the API.',
type_name: 'Custom["BackstageAPIType"]',
enable_backlink: true,
},
},
],
},
],
},
],
}
```

The above we generate the following catalog types:

- `BackstageAPI` with attributes:
- `Name`
- `API type`
- `BackstageAPIType` with attributes:
- `Name`
- `Backstage API`

The `enable_backlink` option allows you to specify if the created enum should have an attribute pointing back to the
attribute that created it. If disabled, the `BackstageAPIType` above will not have a `Backstage API` attribute.


See [simple/importer.jsonnet](https://github.com/incident-io/catalog-importer/blob/bbb659c312af7c45a626a68643e1cd4e890376d5/docs/simple/importer.jsonnet#L161-L166) for a working example
3 changes: 3 additions & 0 deletions docs/simple/catalog.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,9 @@
name: 'Zoom',
description: 'Use Zoom to automatically start call links for your incident channels, and more.',
owner: 'response',
contacts: [
'[email protected]',
]
},
]
],
Expand Down
12 changes: 12 additions & 0 deletions docs/simple/importer.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ local catalog = import 'catalog.jsonnet';
type: 'Text',
source: '$.description',
},
{
id: 'contacts',
name: 'Contacts',
array: true,
source: '$.contacts',
enum: {
name: 'Integration Contact',
type_name: 'Custom["IntegrationContact"]',
description: 'Contact we have in the company for this integration.',
enable_backlink: true,
}
}
],
},
],
Expand Down

0 comments on commit 581aa9a

Please sign in to comment.