Skip to content

Commit d0442ab

Browse files
authored
catalog-backend-module-annotate-scm-slug: add option for configuring applicable entity kinds (#9445)
* catalog-backend-module-annotate-scm-slug: add option for configuring applicable entity kinds Signed-off-by: Kashish Mittal <kmittal@redhat.com> * add changeset Signed-off-by: Kashish Mittal <kmittal@redhat.com> * update changeset Signed-off-by: Kashish Mittal <kmittal@redhat.com> --------- Signed-off-by: Kashish Mittal <kmittal@redhat.com>
1 parent 908d9af commit d0442ab

7 files changed

Lines changed: 142 additions & 3 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@backstage-community/plugin-catalog-backend-module-annotate-scm-slug': patch
3+
---
4+
5+
add an option for configuring applicable entity kinds through app-config.yaml:
6+
7+
```yaml
8+
catalog:
9+
processors:
10+
annotateScmSlug:
11+
kinds:
12+
- API
13+
- Component
14+
- Resource
15+
- System
16+
```

workspaces/catalog/plugins/catalog-backend-module-annotate-scm-slug/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ Here's how to get the module up and running:
3131

3232
Once catalog process has ran you should see the SCM slug added as an annotation on your entities.
3333

34+
## Configuration
35+
36+
By default, the processor only annotates `Component` entities. You can configure which entity kinds are processed in `app-config.yaml`:
37+
38+
```yaml
39+
catalog:
40+
processors:
41+
annotateScmSlug:
42+
kinds:
43+
- API
44+
- Component
45+
- Resource
46+
- System
47+
```
48+
3449
## Slugs Added
3550
3651
These are the current SCM tools and their related annotation and value that are being added by this processor.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2026 The Backstage Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export interface Config {
18+
catalog?: {
19+
processors?: {
20+
/**
21+
* Configuration for the annotate-scm-slug catalog processor.
22+
*/
23+
annotateScmSlug?: {
24+
/**
25+
* Entity kinds that the processor should annotate with SCM slug metadata.
26+
* Defaults to ['Component'] when not specified.
27+
*/
28+
kinds?: string[];
29+
};
30+
};
31+
};
32+
}

workspaces/catalog/plugins/catalog-backend-module-annotate-scm-slug/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
"@types/lodash": "^4.17.13"
4646
},
4747
"files": [
48-
"dist"
49-
]
48+
"dist",
49+
"config.d.ts"
50+
],
51+
"configSchema": "config.d.ts"
5052
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2026 The Backstage Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { ConfigReader } from '@backstage/config';
18+
import { readAnnotateScmSlugProcessorConfig } from './config';
19+
20+
describe('readAnnotateScmSlugProcessorConfig', () => {
21+
it('returns undefined kinds when config is not set', () => {
22+
expect(readAnnotateScmSlugProcessorConfig(new ConfigReader({}))).toEqual({
23+
kinds: undefined,
24+
});
25+
});
26+
27+
it('reads kinds from config', () => {
28+
const config = new ConfigReader({
29+
catalog: {
30+
processors: {
31+
annotateScmSlug: {
32+
kinds: ['API', 'Component', 'Resource', 'System'],
33+
},
34+
},
35+
},
36+
});
37+
38+
expect(readAnnotateScmSlugProcessorConfig(config)).toEqual({
39+
kinds: ['API', 'Component', 'Resource', 'System'],
40+
});
41+
});
42+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2026 The Backstage Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import type { Config } from '@backstage/config';
18+
19+
/** @internal */
20+
export function readAnnotateScmSlugProcessorConfig(config: Config): {
21+
kinds?: string[];
22+
} {
23+
return {
24+
kinds: config.getOptionalStringArray(
25+
'catalog.processors.annotateScmSlug.kinds',
26+
),
27+
};
28+
}

workspaces/catalog/plugins/catalog-backend-module-annotate-scm-slug/src/module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
createBackendModule,
1919
} from '@backstage/backend-plugin-api';
2020
import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node';
21+
import { readAnnotateScmSlugProcessorConfig } from './config';
2122
import { AnnotateScmSlugEntityProcessor } from './processor/AnnotateScmSlugEntityProcessor';
2223

2324
/** @public */
@@ -31,7 +32,10 @@ export const catalogModuleAnnotateScmSlug = createBackendModule({
3132
catalog: catalogProcessingExtensionPoint,
3233
},
3334
async init({ catalog, config }) {
34-
catalog.addProcessor(AnnotateScmSlugEntityProcessor.fromConfig(config));
35+
const processorConfig = readAnnotateScmSlugProcessorConfig(config);
36+
catalog.addProcessor(
37+
AnnotateScmSlugEntityProcessor.fromConfig(config, processorConfig),
38+
);
3539
},
3640
});
3741
},

0 commit comments

Comments
 (0)