feat: add targets support for scorecardClassic#2651
Conversation
🦋 Changeset detectedLatest commit: a4b3851 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
targets support for scorecardClassic
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
It might be a good idea to add some documentation for this property. |
|
@JLekawa the whole config for |
| } | ||
|
|
||
| for (const target of targets) { | ||
| const matches = Object.entries(target.where?.metadata || {}).every(([key, value]) => { |
There was a problem hiding this comment.
Please extract the callback to a named function so the name conveys the intention.
| levels: [{ name: 'Baseline' }], | ||
| targets: [{ where: { metadata: { env: 'prod' } }, minimumLevel: 'Gold' }], | ||
| }; | ||
| expect(getTarget(scorecardConfig.targets, { env: 'dev' })?.minimumLevel).toBeUndefined(); |
There was a problem hiding this comment.
| expect(getTarget(scorecardConfig.targets, { env: 'dev' })?.minimumLevel).toBeUndefined(); | |
| expect(getTarget(scorecardConfig.targets, { env: 'dev' })!.minimumLevel).toBeUndefined(); |
There was a problem hiding this comment.
This will throw an error, because the purpose of this test is to check if it is undefined
There was a problem hiding this comment.
Oh, indeed. Didn't notice.
What/Why/How?
targetsproperty inscorecardClassiccommand. Usingtargetsproperty we can override rules insidescorecardClassicfor specific api, which matches the criteria's under where statement. We find the matching api usingmetadata. We can add metadata in three places: under api in config, inside openapi file inx-metadataortitleandversioninside openapi. If the target matches we apply rules for the levels.Reference
Resolves #2580
Testing
Locally.
Screenshots (optional)
Check yourself
Security