@red-hat-developer-hub/e2e-test-utils 1.1.22 → 1.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,108 +1,61 @@
1
- /**
2
- * Represents parsed plugin metadata from a Package CRD file.
3
- */
4
1
  export interface PluginMetadata {
5
- /** The dynamic artifact path (e.g., ./dynamic-plugins/dist/plugin-name) */
6
2
  packagePath: string;
7
- /** The plugin configuration from appConfigExamples[0].content */
8
3
  pluginConfig: Record<string, unknown>;
9
- /** The package name (e.g., @backstage-community/plugin-tech-radar) */
10
4
  packageName: string;
11
- /** Source metadata file path */
12
5
  sourceFile: string;
13
6
  }
7
+ export interface PluginEntry {
8
+ package: string;
9
+ disabled?: boolean;
10
+ pluginConfig?: Record<string, unknown>;
11
+ [key: string]: unknown;
12
+ }
13
+ export interface DynamicPluginsConfig {
14
+ plugins?: PluginEntry[];
15
+ includes?: string[];
16
+ [key: string]: unknown;
17
+ }
14
18
  /**
15
- * Checks if plugin metadata handling should be enabled.
16
- * This controls both auto-generation and injection of plugin metadata.
19
+ * Detects if we're running in a nightly/periodic job context.
20
+ * Controls the entire nightly vs PR routing in deployment:
21
+ * - Nightly: uses metadata OCI refs (latest published versions), skips metadata injection
22
+ * - PR/local: uses metadata + OCI URL replacement
17
23
  *
18
- * Default: ENABLED (for local dev and PR builds)
19
- * Disabled when:
20
- * - RHDH_SKIP_PLUGIN_METADATA_INJECTION is set, OR
21
- * - JOB_NAME contains "periodic-" (nightly/periodic builds)
24
+ * Returns true when:
25
+ * - JOB_NAME contains "periodic-" (OpenShift CI nightly/periodic jobs), OR
26
+ * - E2E_NIGHTLY_MODE is set (manual override for local testing)
22
27
  */
23
- export declare function shouldInjectPluginMetadata(): boolean;
28
+ export declare function isNightlyJob(): boolean;
24
29
  /**
25
30
  * Extracts the plugin name from a package path or OCI reference.
26
31
  *
27
32
  * Handles various formats:
28
33
  * - Local path: ./dynamic-plugins/dist/backstage-community-plugin-tech-radar
29
- * - OCI with integrity: oci://quay.io/rhdh/plugin@sha256:...!backstage-community-plugin-tech-radar
30
- * - OCI without integrity: oci://quay.io/rhdh/backstage-community-plugin-tech-radar:tag
31
- *
32
- * @param packageRef The package reference string
33
- * @returns The extracted plugin name
34
+ * - OCI with alias: oci://quay.io/rhdh/plugin@sha256:...!backstage-community-plugin-tech-radar
35
+ * - OCI without alias: oci://quay.io/rhdh/backstage-community-plugin-tech-radar:tag
34
36
  */
35
37
  export declare function extractPluginName(packageRef: string): string;
38
+ export declare const DEFAULT_METADATA_PATH = "../metadata";
39
+ export declare function getMetadataDirectory(metadataPath?: string): string | null;
40
+ export declare function parseMetadataFile(filePath: string): Promise<PluginMetadata>;
41
+ export declare function parseAllMetadataFiles(metadataDir: string): Promise<Map<string, PluginMetadata>>;
42
+ /**
43
+ * Resolves plugin package references to their target OCI URLs where applicable.
44
+ *
45
+ * Resolution priority for each plugin:
46
+ * 1. PR OCI URL — if GIT_PR_NUMBER set and a PR image was published for this plugin
47
+ * 2. Metadata OCI ref — uses dynamicArtifact from metadata (latest published version)
48
+ * 3. Unchanged — local paths, npm packages, or other formats kept as-is
49
+ */
36
50
  /**
37
51
  * Returns a stable merge key for a plugin entry so OCI and local path for the same
38
52
  * logical plugin match when merging dynamic-plugins configs. Strips a trailing
39
53
  * "-dynamic" so e.g. backstage-community-plugin-catalog-backend-module-keycloak-dynamic
40
54
  * and ...-keycloak (from OCI) map to the same key.
41
- *
42
- * @param entry Plugin entry with optional package reference
43
- * @returns Normalized key for merge deduplication, or empty string if package is missing
44
55
  */
45
56
  export declare function getNormalizedPluginMergeKey(entry: {
46
57
  package?: string;
47
58
  }): string;
48
- /**
49
- * Default metadata directory path relative to the e2e-tests directory.
50
- * Follows the same pattern as user config paths (e.g., tests/config/dynamic-plugins.yaml).
51
- */
52
- export declare const DEFAULT_METADATA_PATH = "../metadata";
53
- /**
54
- * Gets the metadata directory path.
55
- * Uses the provided path or falls back to DEFAULT_METADATA_PATH.
56
- *
57
- * @param metadataPath Optional custom path to metadata directory
58
- * @returns The metadata directory path, or null if it doesn't exist
59
- */
60
- export declare function getMetadataDirectory(metadataPath?: string): string | null;
61
- /**
62
- * Parses a single metadata YAML file and extracts plugin configuration.
63
- *
64
- * @param filePath Path to the metadata YAML file
65
- * @returns PluginMetadata if valid, null otherwise
66
- */
67
- export declare function parseMetadataFile(filePath: string): Promise<PluginMetadata>;
68
- /**
69
- * Parses all metadata files in a directory and builds a map of plugin name to config.
70
- * The plugin name is extracted from the dynamicArtifact path for flexible matching.
71
- *
72
- * @param metadataDir Path to the metadata directory
73
- * @returns Map of plugin name to plugin configuration
74
- */
75
- export declare function parseAllMetadataFiles(metadataDir: string): Promise<Map<string, PluginMetadata>>;
76
- /**
77
- * Plugin entry in dynamic-plugins.yaml
78
- */
79
- export interface PluginEntry {
80
- package: string;
81
- disabled?: boolean;
82
- pluginConfig?: Record<string, unknown>;
83
- [key: string]: unknown;
84
- }
85
- /**
86
- * Dynamic plugins configuration structure
87
- */
88
- export interface DynamicPluginsConfig {
89
- plugins?: PluginEntry[];
90
- includes?: string[];
91
- [key: string]: unknown;
92
- }
93
- /**
94
- * Injects plugin configurations from metadata into a dynamic plugins config.
95
- * Metadata config serves as the base, user-provided pluginConfig overrides it.
96
- *
97
- * Matching is done by extracting the plugin name from both the package reference
98
- * and the metadata's dynamicArtifact, allowing flexible matching across different
99
- * package formats (local paths, OCI references, etc.).
100
- *
101
- * @param dynamicPluginsConfig The dynamic plugins configuration to augment
102
- * @param metadataMap Map of plugin names to plugin metadata
103
- * @returns The augmented configuration with injected pluginConfigs
104
- */
105
- export declare function injectMetadataConfig(dynamicPluginsConfig: DynamicPluginsConfig, metadataMap: Map<string, PluginMetadata>): DynamicPluginsConfig;
106
59
  /**
107
60
  * Generates dynamic-plugins configuration for wrapper plugins
108
61
  * that need to be disabled. Each plugin entry contains:
@@ -114,25 +67,28 @@ export declare function injectMetadataConfig(dynamicPluginsConfig: DynamicPlugin
114
67
  */
115
68
  export declare function disablePluginWrappers(plugins: string[]): DynamicPluginsConfig;
116
69
  /**
117
- * Generates a complete dynamic-plugins configuration from metadata files.
118
- * Iterates through all metadata files and creates plugin entries with:
119
- * - package: the dynamicArtifact path
120
- * - disabled: false (enabled by default)
121
- * - pluginConfig: from appConfigExamples[0].content
70
+ * Auto-generates plugin entries from workspace metadata files.
71
+ * Creates raw entries with local paths and disabled: false.
72
+ * Does NOT include pluginConfig — that's handled by processPluginsForDeployment.
122
73
  *
123
- * @param metadataPath Optional custom path to metadata directory (default: ../metadata)
124
- * @returns Complete dynamic plugins configuration
125
- * @throws Error if metadata directory not found or no valid metadata files
74
+ * @param metadataPath Optional custom path to metadata directory
75
+ * @returns Plugin entries discovered from metadata
126
76
  */
127
- export declare function generateDynamicPluginsConfigFromMetadata(metadataPath?: string): Promise<DynamicPluginsConfig>;
77
+ export declare function generatePluginsFromMetadata(metadataPath?: string): Promise<DynamicPluginsConfig>;
128
78
  /**
129
- * Main function to load and inject plugin metadata for PR builds.
130
- * For non-PR builds (nightly), returns the config unchanged.
79
+ * Processes a dynamic plugins configuration for deployment.
80
+ * Single entry point for both PR and nightly flows.
81
+ *
82
+ * Operations (in order):
83
+ * 1. Inject appConfigExamples from metadata (PR mode only, unless RHDH_SKIP_PLUGIN_METADATA_INJECTION is set)
84
+ * 2. Resolve all packages to OCI references:
85
+ * - PR with GIT_PR_NUMBER: workspace plugins in PR build → pr_ tags, rest unchanged
86
+ * - PR without GIT_PR_NUMBER: OCI plugins with metadata → metadata refs, rest unchanged
87
+ * - Nightly: OCI plugins with metadata → metadata refs, rest unchanged
131
88
  *
132
- * @param dynamicPluginsConfig The dynamic plugins configuration
133
- * @param metadataPath Optional custom path to metadata directory (default: ../metadata)
134
- * @returns Augmented configuration with metadata (for PR) or unchanged (for nightly)
135
- * @throws Error if PR build but no metadata directory found
89
+ * @param config The merged dynamic plugins configuration
90
+ * @param metadataPath Optional custom path to metadata directory
91
+ * @returns Processed configuration ready for deployment
136
92
  */
137
- export declare function loadAndInjectPluginMetadata(dynamicPluginsConfig: DynamicPluginsConfig, metadataPath?: string): Promise<DynamicPluginsConfig>;
93
+ export declare function processPluginsForDeployment(config: DynamicPluginsConfig, metadataPath?: string): Promise<DynamicPluginsConfig>;
138
94
  //# sourceMappingURL=plugin-metadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-metadata.d.ts","sourceRoot":"","sources":["../../src/utils/plugin-metadata.ts"],"names":[],"mappings":"AA8HA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB;AAgBD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,IAAI,OAAO,CAmBpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAQ5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAMT;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,GAAE,MAA8B,GAC3C,MAAM,GAAG,IAAI,CAUf;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC,CA0BzB;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAwBtC;AAED;;GAEG;AACH,MAAM,W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