Skip to content

Commit fb23720

Browse files
authored
Introduce integrity (#1191)
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
1 parent c2501eb commit fb23720

8 files changed

Lines changed: 43 additions & 5 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-marketplace-backend': patch
3+
'@red-hat-developer-hub/backstage-plugin-marketplace-common': patch
4+
'@red-hat-developer-hub/backstage-plugin-marketplace': patch
5+
---
6+
7+
Introduce `spec.integrity` field for Marketplace package

workspaces/marketplace/examples/packages/backstage-community-plugin-quay.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ metadata:
1717
tags: []
1818
spec:
1919
packageName: '@backstage-community/plugin-quay'
20-
dynamicArtifact: ./dynamic-plugins/dist/backstage-community-plugin-quay
20+
dynamicArtifact: '@backstage-community/plugin-quay'
21+
integrity: sha512-qaZgy2lV28qlwsNnympCUbkewYCqXxLmXQXr3WWpS7gREWj4YBpytU/hQnDnqxAnQ+dQB/9U/rPdGJnLLAOB3w==
2122
version: 1.18.1
2223
backstage:
2324
role: frontend-plugin

workspaces/marketplace/json-schema/packages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
"dynamicArtifact": {
9494
"type": "string"
9595
},
96+
"integrity": {
97+
"type": "string"
98+
},
9699
"version": {
97100
"type": "string"
98101
},

workspaces/marketplace/plugins/marketplace-backend/src/validation/configValidation.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ describe('validateConfigurationFormat', () => {
3232
- package: package1
3333
- package: package2
3434
disabled: false
35+
integrity: dummyabcd
3536
pluginConfig:
3637
key: value
3738
`);
@@ -104,6 +105,15 @@ describe('validatePackageFormat', () => {
104105
`,
105106
error: "optional 'disabled' field in package item must be a boolean",
106107
},
108+
{
109+
testCase: "'integrity' is not a string",
110+
yaml: `
111+
package: package1
112+
integrity: []
113+
`,
114+
error:
115+
"optional 'integrity' field in package item must be a non-empty string",
116+
},
107117
{
108118
testCase: "'pluginConfig' is not a map",
109119
yaml: `

workspaces/marketplace/plugins/marketplace-backend/src/validation/configValidation.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ export function validatePackageFormat(
7373
);
7474
}
7575

76+
const integrity = item.get('integrity');
77+
if (integrity && (typeof integrity !== 'string' || integrity.trim() === '')) {
78+
throw new ConfigFormatError(
79+
"Invalid installation configuration, optional 'integrity' field in package item must be a non-empty string",
80+
);
81+
}
82+
7683
if (packageName && packageToValidate !== packageName) {
7784
throw new ConfigFormatError(
7885
`Invalid installation configuration, 'package' field value in package item differs from '${packageName}'`,

workspaces/marketplace/plugins/marketplace-common/report.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ export interface MarketplacePackageSpec extends JsonObject {
382382
// (undocumented)
383383
installStatus?: MarketplacePackageInstallStatus;
384384
// (undocumented)
385+
integrity?: string;
386+
// (undocumented)
385387
lifecycle?: string;
386388
// (undocumented)
387389
owner?: string;

workspaces/marketplace/plugins/marketplace-common/src/types/MarketplacePackage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export interface MarketplacePackageSpec extends JsonObject {
5858
appConfigExamples?: MarketplacePackageSpecAppConfigExample[];
5959
owner?: string;
6060
partOf?: string[];
61+
integrity?: string;
6162
installStatus?: MarketplacePackageInstallStatus;
6263
}
6364

workspaces/marketplace/plugins/marketplace/src/components/MarketplacePluginInstallContent.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { useNavigate } from 'react-router-dom';
3636

3737
import {
3838
MarketplacePackage,
39+
MarketplacePackageSpec,
3940
MarketplacePackageSpecAppConfigExample,
4041
MarketplacePlugin,
4142
MarketplacePluginInstallStatus,
@@ -274,10 +275,16 @@ export const MarketplacePluginInstallContent = ({
274275
codeEditor.setValue(configYaml);
275276
} else {
276277
const dynamicPluginYaml = {
277-
plugins: (packages ?? []).map(pkg => ({
278-
package: pkg.spec?.dynamicArtifact ?? './dynamic-plugins/dist/....',
279-
disabled: false,
280-
})),
278+
plugins: (packages ?? []).map(pkg => {
279+
const pkgEntry: MarketplacePackageSpec = {
280+
package: pkg.spec?.dynamicArtifact ?? './dynamic-plugins/dist/....',
281+
disabled: false,
282+
};
283+
if (pkg.spec?.integrity) {
284+
pkgEntry.integrity = pkg.spec.integrity;
285+
}
286+
return pkgEntry;
287+
}),
281288
};
282289
codeEditor.setValue(yaml.stringify(dynamicPluginYaml));
283290
}

0 commit comments

Comments
 (0)