Skip to content

Commit

Permalink
add new repo on redhat-best-practices-for-k8s for the plugin of the c…
Browse files Browse the repository at this point in the history
…nfcert operator
  • Loading branch information
aabughosh committed Aug 12, 2024
0 parents commit 4baa244
Show file tree
Hide file tree
Showing 55 changed files with 30,466 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=cnf-certsuite-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=cnf-certsuite-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
61 changes: 61 additions & 0 deletions .github/workflows/pre-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Test Incoming Changes

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
CM_URL_LINUX: https://github.com/mrtazz/checkmake/releases/download/0.2.2/checkmake-0.2.2.linux.amd64 # yamllint disable-line

jobs:
lint:
name: Run Linters
runs-on: ubuntu-22.04
env:
SHELL: /bin/bash

steps:
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: 1.22.5

- name: Disable default go problem matcher
run: echo "::remove-matcher owner=go::"

- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}

- name: Extract dependent Pull Requests
uses: depends-on/depends-on-action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Shfmt
uses: mfinelli/setup-shfmt@v3

- name: Hadolint
uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
recursive: true

- name: Shfmt
run: shfmt -d *.sh

- name: Markdownlint
uses: nosborn/[email protected]
with:
files: .

- name: Typos
uses: crate-ci/typos@master

- name: Yamllint
uses: ibiqlik/action-yamllint@v3
with:
config_file: .yamllint.yml
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"
}
]
}
15 changes: 15 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extends: default
rules:
line-length:
max: 180
level: warning
trailing-spaces:
level: warning
brackets:
level: warning
empty-lines:
level: warning
no_warnings: true
ignore:
- config
- bundle
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM registry.access.redhat.com/ubi8/nodejs-20:1-50 AS build
USER root
RUN command -v yarn || npm i -g yarn

COPY . /usr/src/app
WORKDIR /usr/src/app
RUN yarn install && yarn build
USER 1001

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

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

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

0 comments on commit 4baa244

Please sign in to comment.