Skip to content

Commit 39984e2

Browse files
authored
feat: allow to explicitly disable wrapper plugins (#62)
* feat: allow to explicitly disable wrapper plugins Signed-off-by: Jan Richter <jrichter@redhat.com> * restrict to PR checks and bump version --------- Signed-off-by: Jan Richter <jrichter@redhat.com>
1 parent 8aaf22f commit 39984e2

File tree

11 files changed

+95
-8
lines changed

11 files changed

+95
-8
lines changed

docs/.vitepress/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default defineConfig({
3333
{ text: "Examples", link: "/examples/" },
3434
{ text: "Overlay Testing", link: "/overlay/" },
3535
{
36-
text: "v1.1.13",
36+
text: "v1.1.22",
3737
items: [{ text: "Changelog", link: "/changelog" }],
3838
},
3939
],

docs/changelog.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [1.1.21] - Current
5+
## [1.1.22] - Current
6+
7+
### Added
8+
9+
- **disableWrappers option for rhdh.configure**: Allows listing plugins whose wrappers will be disabled in the dynamic plugins config to allow the use of PR images when a wrapper is enabled by default for the same plugin. This option is ignored if the `GIT_PR_NUMBER` environment variable is not set.
10+
11+
## [1.1.21]
612

713
### Fixed
814

@@ -87,7 +93,7 @@ All notable changes to this project will be documented in this file.
8793
- `VAULT_GH_2FA_SECRET` - GitHub user secret for 2 factor authentication
8894
- `VAULT_GITHUB_USER_TOKEN` - Github user token
8995

90-
## [1.1.12] - Current
96+
## [1.1.12]
9197

9298
### Changed
9399

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Disabling Conflicting Wrappers
2+
3+
Some plugins are included as wrappers in RHDH and are enabled by default.
4+
5+
When the plugin metadata is injected from overlays for such plugin, it will lead to duplicate plugin configuration.
6+
7+
For example, if the `dynamic-plugins.default.yaml` file contains a wrapper config like this:
8+
```yaml
9+
- package: ./dynamic-plugins/dist/red-hat-developer-hub-backstage-plugin-adoption-insights
10+
disabled: false
11+
...
12+
```
13+
14+
The plugin metadata injection might generate a plugin entry such as:
15+
```yaml
16+
- package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-adoption-insights:pr_1967__0.6.2!red-hat-developer-hub-backstage-plugin-adoption-insights
17+
disabled: false
18+
...
19+
```
20+
21+
Both entries configure the same plugin, but since the sources are different, one does not override the other, leading to conflicts and initContainer failure. For the deployment to run successfully using the latest oci image, the wrapper must be explicitly disabled.
22+
23+
## Configuring Wrappers to Disable
24+
25+
The `disableWrappers` option can be used to disable wrapper plugins:
26+
27+
```typescript
28+
await rhdh.configure({
29+
auth: "keycloak",
30+
disableWrappers: ['wrapper-plugin-1', 'wrapper-plugin-2', etc],
31+
});
32+
await rhdh.deploy();
33+
```
34+
35+
Wrapper plugin packages are defined as `./dynamic-plugins/dist/$plugin-name`. Use the `$plugin-name` in `disableWrappers` list.
36+
Make sure that the plugin name matches the dynamic plugins default config.
37+
38+
Note that this option is ignored outside of PR checks, since there is no metadata injection enabled in such case.

docs/guide/configuration/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The package provides configuration tools for ESLint, TypeScript, and RHDH deploy
1010
| [ESLint Configuration](/guide/configuration/eslint-config) | Pre-configured ESLint rules |
1111
| [TypeScript Configuration](/guide/configuration/typescript-config) | Base TypeScript settings |
1212
| [Environment Variables](/guide/configuration/environment-variables) | All environment variables |
13+
| [Disabling Conflicting Wrappers](/guide/configuration/disable-wrappers) | Disabling pre-enabled wrappers that may cause configuration conflicts |
1314

1415
## Project Configuration
1516

docs/overlay/examples/basic-plugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ workspaces/<plugin>/e2e-tests/
6868
"eslint-plugin-check-file": "^3.3.1",
6969
"eslint-plugin-playwright": "^2.4.0",
7070
"prettier": "^3.7.4",
71-
"@red-hat-developer-hub/e2e-test-utils": "1.1.13",
71+
"@red-hat-developer-hub/e2e-test-utils": "1.1.22",
7272
"typescript": "^5.9.3",
7373
"typescript-eslint": "^8.50.0"
7474
}

docs/overlay/examples/tech-radar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ workspaces/tech-radar/e2e-tests/
7171
"eslint-plugin-check-file": "^3.3.1",
7272
"eslint-plugin-playwright": "^2.4.0",
7373
"prettier": "^3.7.4",
74-
"@red-hat-developer-hub/e2e-test-utils": "1.1.13",
74+
"@red-hat-developer-hub/e2e-test-utils": "1.1.22",
7575
"typescript": "^5.9.3",
7676
"typescript-eslint": "^8.50.0"
7777
}

docs/overlay/test-structure/directory-layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Defines the test package with dependencies and scripts:
6868
"eslint-plugin-check-file": "^3.3.1",
6969
"eslint-plugin-playwright": "^2.4.0",
7070
"prettier": "^3.7.4",
71-
"@red-hat-developer-hub/e2e-test-utils": "1.1.13",
71+
"@red-hat-developer-hub/e2e-test-utils": "1.1.22",
7272
"typescript": "^5.9.3",
7373
"typescript-eslint": "^8.50.0"
7474
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@red-hat-developer-hub/e2e-test-utils",
3-
"version": "1.1.21",
3+
"version": "1.1.22",
44
"description": "Test utilities for RHDH E2E tests",
55
"license": "Apache-2.0",
66
"repository": {

src/deployment/rhdh/deployment.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
loadAndInjectPluginMetadata,
88
generateDynamicPluginsConfigFromMetadata,
99
getNormalizedPluginMergeKey,
10+
disablePluginWrappers,
1011
} from "../../utils/plugin-metadata.js";
1112
import { envsubst } from "../../utils/common.js";
1213
import { runOnce } from "../../playwright/run-once.js";
@@ -121,6 +122,9 @@ export class RHDHDeployment {
121122
const userConfigPath = this.deploymentConfig.dynamicPlugins;
122123
const userConfigExists = userConfigPath && fs.existsSync(userConfigPath);
123124
const authConfig = AUTH_CONFIG_PATHS[this.deploymentConfig.auth];
125+
const wrapperPlugins = disablePluginWrappers(
126+
this.deploymentConfig.disableWrappers,
127+
);
124128

125129
// If user's dynamic-plugins config doesn't exist, auto-generate from metadata
126130
if (!userConfigExists) {
@@ -136,13 +140,20 @@ export class RHDHDeployment {
136140
[DEFAULT_CONFIG_PATHS.dynamicPlugins, authConfig.dynamicPlugins],
137141
{ arrayMergeStrategy: { byKey: "package" } },
138142
);
139-
return deepMerge(authPlugins, metadataConfig, {
143+
const dynamicPlugins = deepMerge(authPlugins, metadataConfig, {
140144
arrayMergeStrategy: {
141145
byKey: "package",
142146
normalizeKey: (item) =>
143147
getNormalizedPluginMergeKey(item as Record<string, unknown>),
144148
},
145149
});
150+
151+
if (!process.env.GIT_PR_NUMBER) {
152+
return dynamicPlugins;
153+
}
154+
return deepMerge(dynamicPlugins, wrapperPlugins, {
155+
arrayMergeStrategy: "concat",
156+
});
146157
}
147158

148159
// User config exists - merge provided configs and inject metadata for listed plugins only
@@ -159,6 +170,12 @@ export class RHDHDeployment {
159170
dynamicPluginsConfig =
160171
await loadAndInjectPluginMetadata(dynamicPluginsConfig);
161172

173+
if (process.env.GIT_PR_NUMBER) {
174+
dynamicPluginsConfig = deepMerge(dynamicPluginsConfig, wrapperPlugins, {
175+
arrayMergeStrategy: "concat",
176+
});
177+
}
178+
162179
return dynamicPluginsConfig;
163180
}
164181

@@ -407,6 +424,7 @@ export class RHDHDeployment {
407424
secrets: input.secrets ?? `tests/config/rhdh-secrets.yaml`,
408425
dynamicPlugins:
409426
input.dynamicPlugins ?? `tests/config/dynamic-plugins.yaml`,
427+
disableWrappers: input.disableWrappers ?? [],
410428
};
411429

412430
if (method === "helm") {

src/deployment/rhdh/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type DeploymentOptions = {
1111
method?: DeploymentMethod;
1212
valueFile?: string;
1313
subscription?: string;
14+
disableWrappers?: string[];
1415
};
1516

1617
export type HelmDeploymentConfig = {
@@ -30,6 +31,7 @@ export type DeploymentConfigBase = {
3031
appConfig: string;
3132
secrets: string;
3233
dynamicPlugins: string;
34+
disableWrappers: string[];
3335
};
3436

3537
export type DeploymentConfig = DeploymentConfigBase &

0 commit comments

Comments
 (0)