From 22675cd84e646b889cc8f70170ab1aa646dc3998 Mon Sep 17 00:00:00 2001 From: Sascha Schwarze Date: Sat, 25 Feb 2023 12:53:27 +0100 Subject: [PATCH] Allow non-current user to own the directory which is built by ko --- samples/buildstrategy/ko/buildstrategy_ko_cr.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/samples/buildstrategy/ko/buildstrategy_ko_cr.yaml b/samples/buildstrategy/ko/buildstrategy_ko_cr.yaml index 9011c91aec..ab6a214aee 100644 --- a/samples/buildstrategy/ko/buildstrategy_ko_cr.yaml +++ b/samples/buildstrategy/ko/buildstrategy_ko_cr.yaml @@ -71,6 +71,8 @@ spec: value: $(params.shp-output-image) - name: PARAM_SOURCE_CONTEXT value: $(params.shp-source-context) + - name: PARAM_SOURCE_ROOT + value: $(params.shp-source-root) - name: PARAM_TARGET_PLATFORM value: $(params.target-platform) - name: PARAM_PACKAGE_DIRECTORY @@ -135,6 +137,11 @@ spec: go version echo "ko version $(/tmp/ko version)" + # Allow directory to be owned by other user which is normal for a volume-mounted directory. + # This allows Go to run git commands to access repository metadata. + # Documentation: https://git-scm.com/docs/git-config/2.39.0#Documentation/git-config.txt-safedirectory + git config --global --add safe.directory "${PARAM_SOURCE_ROOT}" + # Run ko export GOROOT="$(go env GOROOT)"