-
Notifications
You must be signed in to change notification settings - Fork 13
[WIP] Upgrade plugin for OpenShift 4.19+ compatibility #113
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
Open
empovit
wants to merge
1
commit into
rh-ecosystem-edge:main
Choose a base branch
from
empovit:update-for-ocp-4.19-no-chart-changes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 was deleted.
Oops, something went wrong.
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,27 @@ | ||
| env: | ||
| browser: true | ||
| es2021: true | ||
| extends: | ||
| - eslint:recommended | ||
| - plugin:react/recommended | ||
| - plugin:@typescript-eslint/recommended | ||
| - prettier | ||
| parser: '@typescript-eslint/parser' | ||
| parserOptions: | ||
| ecmaFeatures: | ||
| jsx: true | ||
| ecmaVersion: latest | ||
| sourceType: module | ||
| plugins: | ||
| - prettier | ||
| - react | ||
| - '@typescript-eslint' | ||
| rules: | ||
| prettier/prettier: | ||
| - error | ||
| react/prop-types: off | ||
| settings: | ||
| react: | ||
| version: detect | ||
|
|
||
|
|
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,28 @@ | ||
| extends: | ||
| - stylelint-config-standard | ||
| rules: | ||
| # Disallow color names and hex colors as these don't work well with dark mode. | ||
| # Use PF global variables instead: | ||
| # https://patternfly-react-main.surge.sh/developer-resources/global-css-variables#global-css-variables | ||
| color-named: never | ||
| color-no-hex: true | ||
| # PatternFly CSS vars don't conform to stylelint's regex. Disable this rule. | ||
| custom-property-pattern: null | ||
| function-disallowed-list: | ||
| - rgb | ||
| # Disable the standard rule to allow BEM-style classnames with underscores. | ||
| selector-class-pattern: null | ||
| # Disallow CSS classnames prefixed with .pf- or .co- as these prefixes are | ||
| # reserved by PatternFly and OpenShift console. | ||
| selector-disallowed-list: | ||
| - "*" | ||
| - /\.(pf|co)-/ | ||
| # Plugins should avoid naked element selectors like `table` and `li` since | ||
| # this can impact layout of existing pages in console. | ||
| selector-max-type: | ||
| - 0 | ||
| - ignore: | ||
| - compounded | ||
| - descendant | ||
|
|
||
|
|
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 |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
|
|
||
| FROM registry.access.redhat.com/ubi8/nodejs-16:latest AS builder | ||
| FROM registry.access.redhat.com/ubi9/nodejs-20:latest AS build | ||
| USER root | ||
| RUN command -v yarn || npm i -g yarn | ||
|
|
||
| COPY . /opt/app-root/src | ||
| COPY . /usr/src/app | ||
| WORKDIR /usr/src/app | ||
| RUN yarn install --frozen-lockfile && yarn build | ||
|
|
||
| FROM registry.access.redhat.com/ubi9/nginx-120:latest | ||
| COPY default.conf "${NGINX_CONFIGURATION_PATH}" | ||
| COPY --from=builder /opt/app-root/src/dist . | ||
| COPY --from=build /usr/src/app/dist /opt/app-root/src | ||
| USER 1001 | ||
| CMD /usr/libexec/s2i/run |
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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| apiVersion: v2 | ||
| appVersion: latest | ||
| description: | | ||
| Red Hat OpenShift dynamic console plugin that leverages the NVIDIA GPU operator metrics and serves the respective console-extensions. Requires Red Hat OpenShift version 4.12+ | ||
| Red Hat OpenShift dynamic console plugin that leverages the NVIDIA GPU operator metrics and serves the respective console-extensions. Requires Red Hat OpenShift version 4.19+ | ||
| name: console-plugin-nvidia-gpu | ||
| sources: | ||
| - https://github.com/rh-ecosystem-edge/console-plugin-nvidia-gpu | ||
|
|
@@ -12,7 +12,7 @@ keywords: | |
| - nvidia | ||
| - gpu | ||
| type: application | ||
| version: 0.2.5 | ||
| version: 0.3.0 | ||
| maintainers: | ||
| - name: mresvanis | ||
| email: [email protected] | ||
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,7 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -exuo pipefail | ||
|
|
||
| FILE_PATTERN='src/**/*.{js,jsx,ts,tsx,json}' | ||
|
|
||
| i18next "${FILE_PATTERN}" -c "./i18next-parser.config.js" -o "locales/\$LOCALE/\$NAMESPACE.json" |
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,34 @@ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| module.exports = { | ||
| isDirectory(filePath) { | ||
| try { | ||
| const stat = fs.lstatSync(filePath); | ||
| return stat.isDirectory(); | ||
| } catch (e) { | ||
| // lstatSync throws an error if path doesn't exist | ||
| return false; | ||
| } | ||
| }, | ||
| parseFolder(directory, argFunction, packageDir) { | ||
| return (async () => { | ||
| try { | ||
| const files = await fs.promises.readdir(directory); | ||
| for (const file of files) { | ||
| const filePath = path.join(directory, file); | ||
| await argFunction(filePath, packageDir); | ||
| } | ||
| } catch (e) { | ||
| console.error(`Failed to parseFolder ${directory}:`, e); | ||
| } | ||
| })(); | ||
| }, | ||
| deleteFile(filePath) { | ||
| try { | ||
| fs.unlinkSync(filePath); | ||
| } catch (e) { | ||
| console.error(`Failed to delete file ${filePath}:`, e); | ||
| } | ||
| }, | ||
| }; |
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,30 @@ | ||
| const EventEmitter = require('events'); | ||
| const jsonc = require('comment-json'); | ||
|
|
||
| /** | ||
| * Custom JSON parser for localizing keys matching format: /%.+%/ | ||
| */ | ||
| module.exports.CustomJSONLexer = class extends EventEmitter { | ||
| extract(content, filename) { | ||
| let keys = []; | ||
| try { | ||
| jsonc.parse( | ||
| content, | ||
| (key, value) => { | ||
| if (typeof value === 'string') { | ||
| const match = value.match(/^%(.+)%$/); | ||
| if (match && match[1]) { | ||
| keys.push({ key: match[1] }); | ||
| } | ||
| } | ||
| return value; | ||
| }, | ||
| true, | ||
| ); | ||
| } catch (e) { | ||
| console.error('Failed to parse as JSON.', filename, e); | ||
| keys = []; | ||
| } | ||
| return keys; | ||
| } | ||
| }; |
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,76 @@ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const pluralize = require('pluralize'); | ||
| const common = require('./common.js'); | ||
|
|
||
| const publicDir = path.join(__dirname, './../locales/'); | ||
|
|
||
| function determineRule(key) { | ||
| if (key.includes('WithCount_plural')) { | ||
| return 0; | ||
| } | ||
| if (key.includes('WithCount')) { | ||
| return 1; | ||
| } | ||
| if (key.includes('_plural')) { | ||
| return 2; | ||
| } | ||
| return 3; | ||
| } | ||
|
|
||
| function updateFile(fileName) { | ||
| let file; | ||
| try { | ||
| file = require(fileName); | ||
| } catch (err) { | ||
| throw new Error(`Failed to load ${fileName}: ${err.message}`); | ||
| } | ||
|
|
||
| if (!file || typeof file !== 'object' || Array.isArray(file)) { | ||
| throw new Error(`Invalid file content in ${fileName}: expected an object`); | ||
| } | ||
|
|
||
| const updatedFile = {}; | ||
| const keys = Object.keys(file); | ||
| let originalKey; | ||
|
|
||
| for (let i = 0; i < keys.length; i++) { | ||
| if (file[keys[i]] === '') { | ||
| // follow i18next rules | ||
| // "key": "item", | ||
| // "key_plural": "items", | ||
| // "keyWithCount": "{{count}} item", | ||
| // "keyWithCount_plural": "{{count}} items" | ||
| switch (determineRule(keys[i])) { | ||
| case 0: | ||
| [originalKey] = keys[i].split('WithCount_plural'); | ||
| updatedFile[keys[i]] = `{{count}} ${pluralize(originalKey)}`; | ||
| break; | ||
| case 1: | ||
| [originalKey] = keys[i].split('WithCount'); | ||
| updatedFile[keys[i]] = `{{count}} ${originalKey}`; | ||
| break; | ||
| case 2: | ||
| [originalKey] = keys[i].split('_plural'); | ||
| updatedFile[keys[i]] = pluralize(originalKey); | ||
| break; | ||
| default: | ||
| updatedFile[keys[i]] = keys[i]; | ||
| } | ||
| } else { | ||
| updatedFile[keys[i]] = file[keys[i]]; | ||
| } | ||
| } | ||
|
|
||
| return fs.promises.writeFile(fileName, JSON.stringify(updatedFile, null, 2)); | ||
| } | ||
|
|
||
| async function processLocalesFolder(filePath) { | ||
| if (path.basename(filePath) === 'en') { | ||
| await common.parseFolder(filePath, updateFile); | ||
| } | ||
| } | ||
|
|
||
| (async () => { | ||
| await common.parseFolder(publicDir, processLocalesFolder); | ||
| })(); |
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 |
|---|---|---|
| @@ -1,9 +1,31 @@ | ||
| // eslint-disable-next-line @typescript-eslint/no-var-requires, no-undef | ||
| const { CustomJSONLexer } = require('./i18n-scripts/lexers'); | ||
|
|
||
| // eslint-disable-next-line no-undef | ||
| module.exports = { | ||
| sort: true, | ||
| createOldCatalogs: false, | ||
| keySeparator: false, | ||
| locales: ['en'], | ||
| namespaceSeparator: '~', | ||
| reactNamespace: false, | ||
| useKeysAsDefaultValue: true, | ||
| defaultNamespace: 'plugin__console-plugin-nvidia-gpu', | ||
| useKeysAsDefaultValue: true, | ||
|
|
||
| lexers: { | ||
| hbs: ['HandlebarsLexer'], | ||
| handlebars: ['HandlebarsLexer'], | ||
|
|
||
| htm: ['HTMLLexer'], | ||
| html: ['HTMLLexer'], | ||
|
|
||
| mjs: ['JavascriptLexer'], | ||
| js: ['JavascriptLexer'], | ||
| ts: ['JavascriptLexer'], | ||
| jsx: ['JsxLexer'], | ||
| tsx: ['JsxLexer'], | ||
| json: [CustomJSONLexer], | ||
|
|
||
| default: ['JavascriptLexer'], | ||
| }, | ||
| }; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: rh-ecosystem-edge/console-plugin-nvidia-gpu
Length of output: 418
🏁 Script executed:
Repository: rh-ecosystem-edge/console-plugin-nvidia-gpu
Length of output: 1632
Address version discrepancy and breaking change strategy.
Version 0.2.6 is documented in the README as supporting OpenShift 4.12–4.18, but does not exist in git history (no tags, commits, or Chart.yaml records). Simultaneously, Chart.yaml has been updated from 0.2.5 directly to 0.3.0 with a requirement for OpenShift 4.19+. This creates a problematic state: