Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(score-card): New config jsonNameOfAllEntities #197

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smooth-dryers-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@oriflame/backstage-plugin-score-card': minor
---

New config [jsonNameOfAllEntities]
1 change: 1 addition & 0 deletions app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ scaffolder:

scorecards:
jsonDataUrl: http://localhost:8090/plugins/score-card/sample-data/ #this is being served via http-server
jsonNameOfAllEntities: all.json
wikiLinkTemplate: https://link-to-wiki/{id}

catalog:
Expand Down
1 change: 1 addition & 0 deletions plugins/score-card/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Also the server providing the data needs to have correctly configured CORS polic
All configuration options:

- `jsonDataUrl`[optional]: url for the JSON data client, see [ScoringDataJsonClient](#scoringdatajsonclient).
- `jsonNameOfAllEntities`[optional]: Json file name of all entities. Default is `all.json`
- `wikiLinkTemplate`[optional]: the template for the link to the wiki. You may use any existing properties from the `EntityScoreEntry`, e.g. `"https://TBD/XXX/_wiki/wikis/XXX.wiki/{id}"` or `"{scoreUrl}"`.

### How to use the plugin
Expand Down
5 changes: 5 additions & 0 deletions plugins/score-card/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export interface Config {
* @visibility frontend
*/
jsonDataUrl?: string;
/**
* Json file name of all entities
* @visibility frontend
*/
jsonNameOfAllEntities?: string;
/**
* The template for the link to the wiki, e.g. "https://TBD/XXX/_wiki/wikis/XXX.wiki/{id}"
* @visibility frontend
Expand Down
12 changes: 10 additions & 2 deletions plugins/score-card/src/api/ScoringDataJsonClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export class ScoringDataJsonClient implements ScoringDataApi {

public async getAllScores(entityKindFilter?: string[]): Promise<EntityScoreExtended[] | undefined> {
const jsonDataUrl = this.getJsonDataUrl();
const urlWithData = `${jsonDataUrl}all.json`;
const jsonName = this.getsJsonNameOfAllEntities();
const urlWithData = `${jsonDataUrl}${jsonName}`;
let result: EntityScore[] | undefined = await fetch(urlWithData).then(
res => {
switch (res.status) {
Expand Down Expand Up @@ -105,7 +106,7 @@ export class ScoringDataJsonClient implements ScoringDataApi {
filter: {
'metadata.name': entity_names

},
},
fields: ['kind', 'metadata.name', 'spec.owner', 'relations'],
});
const entities: Entity[] = response.items;
Expand All @@ -124,6 +125,13 @@ export class ScoringDataJsonClient implements ScoringDataApi {
);
}

private getsJsonNameOfAllEntities() {
return (
this.configApi.getOptionalString('scorecards.jsonNameOfAllEntities') ??
'all.json'
);
}

private extendEntityScore(
score: EntityScore,
entities: Entity[] | undefined,
Expand Down
Loading