Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

Commit 8c54367

Browse files
dsimanskclaude
andcommitted
feat: add local GitHub Pages dev support
init.sh now generates plugin.yaml (via helm template) and copies pages/index.html into backend/static/ so the running Go backend serves the landing page locally. Also adds helm prerequisite check, extracts PLUGIN_NAME variable, simplifies README dev setup docs, and adds CRC host mapping for macOS containers. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2e57de3 commit 8c54367

6 files changed

Lines changed: 61 additions & 42 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@ install-state.gz
5353
# Built binaries
5454
/bin
5555
pages/plugin.yaml
56+
backend/static/index.html
57+
backend/static/plugin.yaml

‎README.md‎

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,63 +44,37 @@ Available image tags are listed in the [container registry](https://github.com/f
4444

4545
- [Node.js](https://nodejs.org/en/) (v18+)
4646
- [Yarn](https://yarnpkg.com) (v4)
47+
- [Go](https://go.dev/dl/) (v1.24+)
48+
- [Helm](https://helm.sh/docs/intro/install/)
4749
- [oc](https://console.redhat.com/openshift/downloads) CLI
4850
- [Docker](https://www.docker.com) or [podman 3.2.0+](https://podman.io)
4951
- An [OpenShift cluster](https://console.redhat.com/openshift/create)
5052
- Github [*Personal Access Token*](https://github.com/settings/personal-access-tokens) with *administration*, *content* and *workflow* write permissions in all repositories
5153
- [inotify-tools](https://github.com/inotify-tools/inotify-tools) (optional, enables Go backend auto-recompile on file changes)
5254

53-
### Option 1: Local
55+
### Setup
5456

55-
In one terminal window, run:
57+
1. `oc login` to your OpenShift cluster
58+
2. `yarn install`
59+
3. `./init.sh`
5660

57-
1. `yarn install`
58-
2. `yarn run start`
61+
This builds the pages assets (plugin.yaml, landing page), compiles the Go backend, starts the webpack dev server, and launches the OpenShift console in a container. Navigate to <http://localhost:9000> to see the running plugin.
5962

60-
In another terminal window, run:
63+
To stop the dev environment:
6164

62-
1. `oc login` (requires [oc](https://console.redhat.com/openshift/downloads) and an [OpenShift cluster](https://console.redhat.com/openshift/create))
63-
2. `yarn run start-console` (requires [Docker](https://www.docker.com) or [podman 3.2.0+](https://podman.io))
64-
65-
This will run the OpenShift console in a container connected to the cluster
66-
you've logged into. The plugin HTTP server runs on port 9001 with CORS enabled.
67-
Navigate to <http://localhost:9000/example> to see the running plugin.
68-
69-
#### Running start-console with Apple silicon and podman
70-
71-
If you are using podman on a Mac with Apple silicon, `yarn run start-console`
72-
might fail since it runs an amd64 image. You can workaround the problem with
73-
[qemu-user-static](https://github.com/multiarch/qemu-user-static) by running
74-
these commands:
75-
76-
```bash
77-
podman machine ssh
78-
sudo -i
79-
rpm-ostree install qemu-user-static
80-
systemctl reboot
65+
```shell
66+
./init.sh --stop
8167
```
8268

83-
### Option 2: Docker + VSCode Remote Container
69+
To use random ports (useful when defaults are already in use):
8470

85-
Make sure the
86-
[Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
87-
extension is installed. This method uses Docker Compose where one container is
88-
the OpenShift console and the second container is the plugin. It requires that
89-
you have access to an existing OpenShift cluster. After the initial build, the
90-
cached containers will help you start developing in seconds.
91-
92-
1. Create a `dev.env` file inside the `.devcontainer` folder with the correct values for your cluster:
93-
94-
```bash
95-
OC_PLUGIN_NAME=console-functions-plugin
96-
OC_URL=https://api.example.com:6443
97-
OC_USER=kubeadmin
98-
OC_PASS=<password>
71+
```shell
72+
./init.sh --randomize-ports
9973
```
10074

101-
2. `(Ctrl+Shift+P) => Remote Containers: Open Folder in Container...`
102-
3. `yarn run start`
103-
4. Navigate to <http://localhost:9000/example>
75+
### Viewing GitHub Pages locally
76+
77+
The landing page served at [functions-dev.github.io/ocp-console-plugin](https://functions-dev.github.io/ocp-console-plugin/) is built from `pages/index.html` and the Helm chart. The `init.sh` script generates these assets into `backend/static/` automatically, so the running backend serves them at <http://localhost:8080>.
10478

10579
## Docker image
10680

‎docs/claude-progress.txt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
# Claude Progress Log
22
# Newest entries first. Agents: append your entry at the top after the header.
33

4+
---
5+
## 2026-06-15 | Session: GitHub Pages local dev (SRVOCF-843)
6+
Worked on: Review and polish existing local pages dev implementation
7+
Completed:
8+
- Reviewed changes on pr/page-cmd branch (build_pages in init.sh, README simplification, CRC host mapping, .gitignore updates)
9+
- Ran pre-commit code review (idiomatic shell, DRY, SOLID, build verification)
10+
- Extracted PLUGIN_NAME variable in init.sh to replace 3 hardcoded "console-functions-plugin" strings in build_pages()
11+
- Added features.json entry for SRVOCF-843
12+
- Confirmed error handling already covered by set -euo pipefail
13+
- All 14 suites, 126 tests passing, webpack builds clean
14+
Left off: Changes committed on pr/page-cmd branch, not pushed. Feature passes field still false (needs manual verification).
15+
Blockers: None
16+
417
---
518
## 2026-05-21 | Session: Page co-location restructure (continued)
619
Worked on: Follow-up fixes from review, test cleanup, docs

‎docs/features.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,16 @@
180180
"All tests pass, no broken imports"
181181
],
182182
"passes": true
183+
},
184+
{
185+
"category": "technical",
186+
"description": "GitHub Pages local development: script to generate plugin.yaml and serve the pages site locally",
187+
"steps": [
188+
"Add a script (e.g. hack/pages-dev.sh) that runs helm template to generate plugin.yaml into pages/",
189+
"Script starts a local HTTP server (e.g. python -m http.server) to serve pages/ so fetch('plugin.yaml') works",
190+
"Add pages/plugin.yaml to .gitignore so the generated file is not committed",
191+
"Document usage in README or script header"
192+
],
193+
"passes": false
183194
}
184195
]

‎init.sh‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set -euo pipefail
44

55
LOG_DIR=".dev-logs"
6+
PLUGIN_NAME="console-functions-plugin"
67
CONSOLE_IMAGE="${CONSOLE_IMAGE:="quay.io/openshift/origin-console:latest"}"
78
BACKEND_PORT=8080
89
PLUGIN_PORT=9001
@@ -75,7 +76,17 @@ write_dev_env() {
7576
EOF
7677
}
7778

79+
build_pages() {
80+
echo "Building pages assets..."
81+
helm template "$PLUGIN_NAME" charts/openshift-console-plugin \
82+
-n "$PLUGIN_NAME" \
83+
--set "plugin.image=ghcr.io/functions-dev/${PLUGIN_NAME}:latest" \
84+
> backend/static/plugin.yaml
85+
cp pages/index.html backend/static/index.html
86+
}
87+
7888
start_backend() {
89+
build_pages
7990
echo "Building Go backend..."
8091
(cd backend && go build -buildvcs=false -o ../bin/backend .)
8192
(cd backend && go build -buildvcs=false -o ../bin/errserver ./cmd/errserver)
@@ -176,6 +187,11 @@ check_prerequisites() {
176187
echo "Error: not logged in to OpenShift. Run 'oc login' first."
177188
exit 1
178189
fi
190+
191+
if ! command -v helm &>/dev/null; then
192+
echo "Error: helm not found. Install from https://helm.sh/docs/intro/install/"
193+
exit 1
194+
fi
179195
}
180196

181197
install_dependencies() {

‎start-console.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ else
6363
PLUGIN_HOST="host.docker.internal"
6464
fi
6565
CONTAINER_NETWORK_OPTS="-p ${CONSOLE_PORT}:9000"
66+
if [[ "$(uname -s)" == "Darwin" ]]; then
67+
CONTAINER_NETWORK_OPTS="${CONTAINER_NETWORK_OPTS} --add-host api.crc.testing:host-gateway"
68+
fi
6669

6770
BRIDGE_PLUGINS="${PLUGIN_NAME}=http://${PLUGIN_HOST}:${PLUGIN_PORT}"
6871
BRIDGE_PLUGIN_PROXY='{"services":[{"consoleAPIPath":"/api/proxy/plugin/'"${PLUGIN_NAME}"'/backend/","endpoint":"http://'"${PLUGIN_HOST}"':'"${BACKEND_PORT}"'","authorize":false}]}'

0 commit comments

Comments
 (0)