-
Notifications
You must be signed in to change notification settings - Fork 8
fix(deployment): de-duplicate plugin config #51
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
Merged
jrichter1
merged 1 commit into
redhat-developer:main
from
gashcrumb:deduplicate-plugin-refs
Mar 11, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,3 +29,6 @@ jobs: | |
|
|
||
| - name: Build | ||
| run: yarn build | ||
|
|
||
| - name: Run Tests | ||
| run: yarn test | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { describe, it } from "node:test"; | ||
| import assert from "node:assert"; | ||
| import { deepMerge } from "../../utils/merge-yamls.js"; | ||
| import { getNormalizedPluginMergeKey } from "../../utils/plugin-metadata.js"; | ||
|
|
||
| /** | ||
| * Tests the merge behavior used when user dynamic-plugins config does not exist: | ||
| * auth config (e.g. keycloak) is merged with metadata config using normalized plugin key. | ||
| * Result must have exactly one entry per logical plugin; metadata (source) wins so OCI URL is kept. | ||
| */ | ||
| describe("dynamic-plugins merge (no user config path)", () => { | ||
| it("yields one keycloak plugin with OCI package when auth has local path and metadata has OCI", () => { | ||
| const authPlugins: Record<string, unknown> = { | ||
| plugins: [ | ||
| { | ||
| package: | ||
| "./dynamic-plugins/dist/backstage-community-plugin-catalog-backend-module-keycloak-dynamic", | ||
| disabled: false, | ||
| pluginConfig: {}, | ||
| }, | ||
| ], | ||
| includes: ["dynamic-plugins.default.yaml"], | ||
| }; | ||
| const metadataConfig: Record<string, unknown> = { | ||
| plugins: [ | ||
| { | ||
| package: | ||
| "oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/backstage-community-plugin-catalog-backend-module-keycloak:pr_1980__3.16.0!backstage-community-plugin-catalog-backend-module-keycloak", | ||
| disabled: false, | ||
| pluginConfig: { catalog: { providers: { keycloakOrg: {} } } }, | ||
| }, | ||
| ], | ||
| }; | ||
| const merged = deepMerge(authPlugins, metadataConfig, { | ||
| arrayMergeStrategy: { | ||
| byKey: "package", | ||
| normalizeKey: (item) => | ||
| getNormalizedPluginMergeKey(item as Record<string, unknown>), | ||
| }, | ||
| }); | ||
| const plugins = merged.plugins as Array<{ package?: string }>; | ||
| assert.strictEqual( | ||
| plugins.length, | ||
| 1, | ||
| "merged config must have exactly one keycloak plugin", | ||
| ); | ||
| assert.ok( | ||
| plugins[0].package?.startsWith("oci://"), | ||
| "metadata (OCI) must win over auth local path", | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { describe, it } from "node:test"; | ||
| import assert from "node:assert"; | ||
| import { deepMerge } from "./merge-yamls.js"; | ||
| import { getNormalizedPluginMergeKey } from "./plugin-metadata.js"; | ||
|
|
||
| describe("deepMerge with arrayMergeStrategy byKey", () => { | ||
| it("keeps two plugin entries when package values differ and no normalizeKey", () => { | ||
| const target: Record<string, unknown> = { | ||
| plugins: [ | ||
| { | ||
| package: | ||
| "oci://ghcr.io/org/repo/backstage-community-plugin-catalog-backend-module-keycloak:tag!alias", | ||
| disabled: false, | ||
| }, | ||
| ], | ||
| }; | ||
| const source: Record<string, unknown> = { | ||
| plugins: [ | ||
| { | ||
| package: | ||
| "./dynamic-plugins/dist/backstage-community-plugin-catalog-backend-module-keycloak-dynamic", | ||
| disabled: false, | ||
| }, | ||
| ], | ||
| }; | ||
| const result = deepMerge(target, source, { | ||
| arrayMergeStrategy: { byKey: "package" }, | ||
| }); | ||
| const plugins = result.plugins as unknown[]; | ||
| assert.strictEqual( | ||
| plugins.length, | ||
| 2, | ||
| "without normalizeKey both entries are kept", | ||
| ); | ||
| }); | ||
|
|
||
| it("merges into one plugin when normalizeKey maps both to same key and source wins", () => { | ||
| const target: Record<string, unknown> = { | ||
| plugins: [ | ||
| { | ||
| package: | ||
| "./dynamic-plugins/dist/backstage-community-plugin-catalog-backend-module-keycloak-dynamic", | ||
| disabled: false, | ||
| }, | ||
| ], | ||
| }; | ||
| const source: Record<string, unknown> = { | ||
| plugins: [ | ||
| { | ||
| package: | ||
| "oci://ghcr.io/org/repo/backstage-community-plugin-catalog-backend-module-keycloak:pr_1__1.0!keycloak", | ||
| disabled: false, | ||
| }, | ||
| ], | ||
| }; | ||
| const normalizeKey = (item: unknown) => | ||
| getNormalizedPluginMergeKey(item as Record<string, unknown>); | ||
| const result = deepMerge(target, source, { | ||
| arrayMergeStrategy: { byKey: "package", normalizeKey }, | ||
| }); | ||
| const plugins = result.plugins as Array<{ package?: string }>; | ||
| assert.strictEqual( | ||
| plugins.length, | ||
| 1, | ||
| "same normalized key yields one entry", | ||
| ); | ||
| assert.ok( | ||
| plugins[0].package?.startsWith("oci://"), | ||
| "source (OCI) wins over target (local path)", | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.