This document provides context and guidelines for AI coding assistants working on this codebase.
This is a template repository for creating OpenShift Console dynamic plugins. It's meant to be used via GitHub's "Use this template" feature, NOT forked. The template provides a minimal starting point for extending the OpenShift Console UI with custom pages and functionality.
⚠️ WARNING: This repository is used by multiple large-scale enterprise web applications. Please proceed with caution when making any changes to this codebase. Changes here can affect downstream projects that depend on this template.
Only make changes that should be standard practice for ALL plugins created from this template. If a change is specific to one plugin use case, it belongs in the instantiated plugin repository, not in this template.
Key Technologies:
Compatibility: Requires OpenShift 4.12+ (uses ConsolePlugin CRD v1 API)
This plugin uses webpack module federation to load at runtime into the OpenShift Console. Key files:
console-extensions.json: Declares what the plugin adds to console (routes, nav items, etc.)package.json consolePlugin section: Plugin metadata and exposed modules mappingwebpack.config.ts: Configures module federation and buildCritical: Any component referenced in console-extensions.json must have a corresponding entry in package.json under consolePlugin.exposedModules.
.tsx)IMPORTANT: The .stylelintrc.yaml enforces strict rules to prevent breaking console:
var(--pf-v6-global-palette--blue-500))table, div) - prevents overwriting console styles.pf- or .co- prefixed classes - these are reserved for PatternFly and consoleconsole-plugin-template__nice)Don't disable these rules without understanding they protect against layout breakage!
Namespace Convention: plugin__<plugin-name> (e.g., plugin__console-plugin-template)
const { t } = useTranslation('plugin__console-plugin-template');
return <h1>{t('Hello, World!')}</h1>;
"name": "%plugin__console-plugin-template~My Label%"
After adding/changing messages: Run yarn i18n to update locale files in /locales
src/
components/ # React components
ExamplePage.tsx # Example page component
*.css # Component styles (scoped with plugin prefix)
console-extensions.json # Plugin extension declarations
package.json # Plugin metadata in consolePlugin section
tsconfig.json # TypeScript config (strict: false currently)
webpack.config.ts # Module federation + build config
locales/ # i18n translation files
charts/ # Helm chart for deployment
integration-tests/ # Cypress e2e tests
yarn install - install dependenciesyarn start - starts webpack dev server on port 9001 with CORSyarn start-console - runs OpenShift console in container (requires cluster login)yarn lint - runs eslint, prettier, and stylelint (with --fix)yarn test-cypress - opens Cypress UIyarn test-cypress-headless - runs Cypress in CI modeCurrent config has strict: true and enforces:
noUnusedLocals: true.tsx extensionsrc/components/MyPage.tsxpackage.json exposedModules: "MyPage": "./components/MyPage"Add route in console-extensions.json:
{
"type": "console.page/route",
"properties": {
"path": "/my-page",
"component": { "$codeRef": "MyPage" }
}
}
Optional: Add nav item in console-extensions.json
Run yarn i18n if you added translatable strings
{
"type": "console.navigation/href",
"properties": {
"id": "my-nav-item",
"name": "%plugin__console-plugin-template~My Page%",
"href": "/my-page",
"perspective": "admin",
"section": "home"
}
}
When instantiating from template, update:
package.json - name and consolePlugin.namepackage.json - consolePlugin.displayName and descriptionplugin__<name>)docker build -t quay.io/my-repository/my-plugin:latest .
# For Apple Silicon: add --platform=linux/amd64
helm upgrade -i my-plugin charts/openshift-console-plugin \
-n my-namespace \
--create-namespace \
--set plugin.image=my-plugin-image-location
Note: OpenShift 4.10 requires --set plugin.securityContext.enabled=false
plugin__ prefixexposedModules must match $codeRef valuesconsole-extensions.json require restartSee Console Plugin SDK README for available extension types:
console.page/route - add new pagesconsole.navigation/href - add nav itemsconsole.navigation/section - add nav sectionsconsole.tab - add tabs to resource pagesconsole.action/provider - add actions to resourcesconsole.flag - feature flagsReact.FC or explicit return typesdata-test attributes for selectorsWhen should I...
t() function, run yarn i18n afteryarn start + yarn start-console, add Cypress tests