This repository provides a small HTTP mock service to emulate selected OpenStack endpoints/behaviors for local development and testing. It uses existing kOps OpenStack test mock functions. The code is mostly glue code to expose these functions as a simple HTTP service.
|
Note
|
LLM disclaimer
IntelliJ Junie LLM created most of this codebase. |
-
Go 1.25+ (as specified in go.mod)
-
Make (optional but recommended)
Using Make (recommended):
make deps make build
The build creates the binary at:
-
bin/openstack-mock
Directly with Go (without Make):
go mod tidy go build -o bin/openstack-mock .
Using Make:
make run
Directly:
./bin/openstack-mock
The service listens on 127.0.0.1:19090 by default. You can change the bind address and port via flags:
-listen-
(default:
127.0.0.1) -port-
(default:
19090)
Example:
./bin/openstack-mock -listen 0.0.0.0 -port 19091
This repository provides a simple HTTP request collection in openstack.http (compatible with IntelliJ / GoLand / HTTP Client; standalone CLI: JetBrains HTTP Client CLI). You can use it to quickly test endpoints once the server is running.
-
Format, vet, and test:
make fmt make vet make test
-
Use a local kOps checkout via a
replaceingo.mod:# In go.mod, point k8s.io/kops to your local path replace k8s.io/kops => ../path/to/your/local/kopsTipYou can also use go mod edit to set this programmatically: go mod edit -replace=k8s.io/kops=../path/to/your/local/kops go mod tidy
A sample commented
replacealready exists in go.mod; adjust and uncomment it to match your local path.ImportantDo not check in the
replacedirective in go.mod. -
Clean build artifacts:
make clean
This repository includes a multi-stage Dockerfile and Makefile targets to build and publish a multi-platform container image (linux/amd64 and linux/arm64) for the service.
Build and push a multi-platform image (with tags: latest and current branch):
make docker-build
Optionally, overriding the image name/registry (will push a multi-arch manifest and images for amd64+arm64):
IMAGE=ghcr.io/your-org/openstack-mock make docker-build
Alternative alias (same as docker-build):
IMAGE=ghcr.io/your-org/openstack-mock make docker-push
Notes:
-
Platforms: The build creates images for
linux/amd64andlinux/arm64using Docker Buildx and pushed as a multi-arch manifest. -
Requirements: You need Docker Buildx enabled and a logged-in registry for pushing (e.g.,
docker login ghcr.io). -
Tagging: In addition to
latest, the build adds the current git branch name as a tag. It sanitizes the name to be a valid Docker tag (lowercased, slashes/spaces to-, others mapped to-). -
Runtime: The container runs as non-root in a minimal distroless image, and the app listens on port 19090, binding to 0.0.0.0 inside the container.
-
Run locally:
docker run --rm -p 19090:19090 ghcr.io/your-org/openstack-mock:latest
Then access the service at http://localhost:19090/