Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmadigan authored Jun 27, 2024
0 parents commit f64b76e
Show file tree
Hide file tree
Showing 55 changed files with 10,468 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build_root_image:
name: nodejs-16
namespace: openshift
tag: latest
20 changes: 20 additions & 0 deletions .devcontainer/Dockerfile.console
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM quay.io/openshift/origin-console:latest
COPY --from=openshift/origin-cli:latest /usr/bin/oc /usr/local/bin/oc

ENV OC_URL=$OC_URL
ENV OC_PASS=$OC_PASS
ENV OC_USER=$OC_USER
ENV OC_PLUGIN_NAME=$OC_PLUGIN_NAME

USER root
CMD eval "oc login $OC_URL -u $OC_USER -p $OC_PASS --insecure-skip-tls-verify" && \
/opt/bridge/bin/bridge -public-dir=/opt/bridge/static \
-i18n-namespaces plugin__$OC_PLUGIN_NAME \
-plugins $OC_PLUGIN_NAME=http://localhost:9001 \
-k8s-mode-off-cluster-thanos=$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.thanosPublicURL}') \
-k8s-mode-off-cluster-endpoint=$(oc whoami --show-server) \
-k8s-mode-off-cluster-skip-verify-tls=true \
-k8s-auth-bearer-token=$(oc whoami --show-token) \
-k8s-auth="bearer-token" \
-user-auth="disabled" \
-k8s-mode="off-cluster"
2 changes: 2 additions & 0 deletions .devcontainer/Dockerfile.plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:16 as build
COPY --from=openshift/origin-cli:latest /usr/bin/oc /usr/local/bin/oc
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "Console + Plugin",
"dockerComposeFile": "docker-compose.yml",
"service": "plugin",
"workspaceFolder": "/workspace",

"initializeCommand": ".devcontainer/init.sh",
"postCreateCommand": "yarn && eval 'oc login $OC_URL -u $OC_USER -p $OC_PASS --insecure-skip-tls-verify'",
"forwardPorts": [9000, 9001],
"portsAttributes": {
"9000": {
"label": "Console"
},
"9001": {
"label": "Plugin static files",
"onAutoForward": "silent"
}
},
"features": {},
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"ms-azuretools.vscode-docker",
"ms-vscode.vscode-typescript-next",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
}
}
34 changes: 34 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3.8'
# create dev.env with the following values:
# OC_URL
# OC_USER
# OC_PASS
# OC_PLUGIN_NAME
services:
console:
build:
context: ..
dockerfile: .devcontainer/Dockerfile.console
env_file: dev.env
restart: unless-stopped
healthcheck:
test: oc whoami
interval: 1m30s
timeout: 10s
retries: 5

plugin:
build:
context: ..
dockerfile: .devcontainer/Dockerfile.plugin
env_file: dev.env
depends_on:
- console
network_mode: service:console
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
# Cache local workspace and copy shell history.
volumes:
- ..:/workspace:cached
- ~/.bash_history:/root/.bash_history
- ~/.zsh_history:/root/.zsh_history
35 changes: 35 additions & 0 deletions .devcontainer/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

if [[ ! -f .devcontainer/dev.env ]]
then
cat << EOF
env file 'dev.env' does not exist in .devcontainer, please create it and add the the correct values for your cluster.
OC_PLUGIN_NAME=my-plugin
OC_URL=https://api.example.com:6443
OC_USER=kubeadmin
OC_PASS=<password>
EOF
exit 2
else
echo 'found 'dev.env' in .devcontainer'
fi

# if one of the variables are missing, abort the build.
success=1
! grep -q OC_PLUGIN_NAME= ".devcontainer/dev.env" && success=0
! grep -q OC_URL= ".devcontainer/dev.env" && success=0
! grep -q OC_USER= ".devcontainer/dev.env" && success=0
! grep -q OC_PASS= ".devcontainer/dev.env" && success=0

if ((success)); then
echo 'dev.env is formatted correctly, proceeding.'
else
cat << EOF
dev.env is not formatted correctly, please add the the correct values for your cluster.
OC_PLUGIN_NAME=my-plugin
OC_URL=https://api.example.com:6443
OC_USER=kubeadmin
OC_PASS=<password>
EOF
exit 2
fi
24 changes: 24 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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: 2016
sourceType: module
plugins:
- prettier
- react
- '@typescript-eslint'
rules:
prettier/prettier:
- error
settings:
react:
version: detect
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/node_modules
**/dist
**/.DS_Store
.devcontainer/dev.env
integration-tests/videos
integration-tests/screenshots
4 changes: 4 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
arrowParens: always
printWidth: 100
singleQuote: true
trailingComma: all
26 changes: 26 additions & 0 deletions .stylelintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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
18 changes: 18 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"typescript.tsdk": "./node_modules/typescript/lib",
"search.exclude": {
"**/node_modules": true
},
"files.watcherExclude": {
"**/node_modules/**": true
},
"files.associations": {
"**/console-extensions.json": "jsonc"
},
"json.schemas": [
{
"fileMatch": ["**/console-extensions.json"],
"url": "./node_modules/@openshift-console/dynamic-plugin-sdk-webpack/schema/console-extensions.json"
}
]
}
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM registry.access.redhat.com/ubi8/nodejs-16:latest AS build
USER root
RUN command -v yarn || npm i -g yarn

ADD . /usr/src/app
WORKDIR /usr/src/app
RUN yarn install && yarn build

FROM registry.access.redhat.com/ubi8/nginx-120:latest

COPY --from=build /usr/src/app/dist /usr/share/nginx/html
USER 1001

ENTRYPOINT ["nginx", "-g", "daemon off;"]
Loading

0 comments on commit f64b76e

Please sign in to comment.