Ensure pkgproxy.yaml is properly shipped and loaded from image#130
Ensure pkgproxy.yaml is properly shipped and loaded from image#130
Conversation
When invoked with no arguments (e.g. `podman run ghcr.io/ganto/pkgproxy`), the binary now dispatches the `serve` subcommand automatically. The config file search order is extended to fall back to `$KO_DATA_PATH/pkgproxy.yaml` when `./pkgproxy.yaml` is absent, enabling the published container image to start out of the box without any explicit flags or bind mounts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the CLI so the container image can start a server by default and discover the bundled pkgproxy.yaml via $KO_DATA_PATH, with accompanying specs/tests and documentation updates.
Changes:
- Add a pre-Cobra argv shim that injects
servewhen invoked with no user args. - Extend config discovery to fall back to
$KO_DATA_PATH/pkgproxy.yamlwhen no explicit config path is provided. - Add unit tests and update README/CHANGELOG plus openspec design/spec artifacts.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
cmd/root.go |
Adds injectServeDefault() and resolveConfigPath(); updates initConfig() precedence logic. |
cmd/root_test.go |
Unit tests for the argv shim behavior. |
cmd/config_test.go |
Unit tests for resolveConfigPath() discovery order. |
README.md |
Simplifies container run examples by removing explicit --config usage. |
CHANGELOG.md |
Adds an Unreleased entry describing the new container behavior. |
openspec/changes/container-default-config/* |
Adds proposal/design/specs/tasks and openspec metadata documenting the change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Run the application via a container engine (e.g. [Podman](https://podman.io/)): | ||
|
|
||
| - Using the default repository configuration: | ||
| ```shell | ||
| podman run --rm -p 8080:8080 --volume ./cache:/ko-app/cache:z ghcr.io/ganto/pkgproxy serve --host 0.0.0.0 --config /var/run/ko/pkgproxy.yaml | ||
| podman run --rm -p 8080:8080 --volume ./cache:/ko-app/cache:z ghcr.io/ganto/pkgproxy serve --host 0.0.0.0 | ||
| ``` | ||
| - Mounting your own local `pkgproxy.yaml`: | ||
|
|
||
| To use a custom `pkgproxy.yaml`, bind-mount it into the container: | ||
| ```shell | ||
| podman run --rm -p 8080:8080 --volume ./cache:/ko-app/cache:z --volume ./pkgproxy.yaml:/ko-app/pkgproxy.yaml ghcr.io/ganto/pkgproxy serve --host 0.0.0.0 --config /ko-app/pkgproxy.yaml | ||
| podman run --rm -p 8080:8080 --volume ./cache:/ko-app/cache:z --volume ./pkgproxy.yaml:/ko-app/pkgproxy.yaml ghcr.io/ganto/pkgproxy serve --host 0.0.0.0 |
There was a problem hiding this comment.
The container examples still invoke serve --host 0.0.0.0 explicitly, so the README doesn't demonstrate the new "default subcommand" behavior described elsewhere in this change set (and in the PR title). If the intent is that podman run ... ghcr.io/ganto/pkgproxy works without args, the docs and/or serve defaults should be updated accordingly; otherwise, consider adding a brief note explaining why serve is still shown (e.g., because --host is a serve flag and the default bind address is localhost).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ment serve defaults to localhost, which is unreachable via container port mapping. Update the proposal's goal invocation and task 3.1 description to match the README; note that changing the listen default is out of scope. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Change resolveConfigPath to return (string, error): propagate non-ErrNotExist stat errors instead of silently falling through - Add Mode().IsRegular() check so a directory named pkgproxy.yaml falls through to the KO_DATA_PATH fallback - Use filepath.Join for the ko fallback path construction - Add TestInitConfig covering all three precedence scenarios: explicit --config bypasses env var and lookup; PKGPROXY_CONFIG bypasses ordered lookup; ordered lookup runs when both unset Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
No description provided.