Allow non-current user to own the directory which is built by ko #1219
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Go is running some Git commands to determine version control information of the directory that it builds to attach them as metadata to the binary. This leads to BuildRun failures when the directory is not owned by the current user:
go version go1.19.6 linux/arm64 ko version 0.12.0 2023/02/25 11:42:10 Using base [registry.access.redhat.com/ubi9/ubi-minimal@sha256:085c5049f5bd0b3cb33c322306a528373f79dc6f1098ff8f5a5b28f2685c53f8](http://registry.access.redhat.com/ubi9/ubi-minimal@sha256:085c5049f5bd0b3cb33c322306a528373f79dc6f1098ff8f5a5b28f2685c53f8) for [github.com/shipwright-io/build/cmd/shipwright-build-controller](http://github.com/shipwright-io/build/cmd/shipwright-build-controller) 2023/02/25 11:42:10 Building [github.com/shipwright-io/build/cmd/shipwright-build-controller](http://github.com/shipwright-io/build/cmd/shipwright-build-controller) for linux/arm64 2023/02/25 11:42:11 Unexpected error running "go build": exit status 1 # cd /workspace/source; git status --porcelain fatal: detected dubious ownership in repository at '/workspace/source' To add an exception for this directory, call: git config --global --add [safe.directory](http://safe.directory/) /workspace/source error obtaining VCS status: exit status 128 Use -buildvcs=false to disable VCS stamping.
In Shipwright, it is more or less always the case that the user is not owning the directory. The reason is that
/workspace/source
is an emptyDir volume that root is owning.The error already contains the solution that I am using = adding it as a safe directory.
Submitter Checklist
Release Notes