Skip to content

Commit

Permalink
Support local Go modules
Browse files Browse the repository at this point in the history
Support using local Go modules inside the Shipyard container by
specifying one or more (colon separated) paths with `LOCAL_MODULES`.

The corresponding Submariner modules will be used from the local
file system instead of being pulled from GitHub.

Signed-off-by: Mike Kolesnik <[email protected]>
  • Loading branch information
mkolesnik committed Jan 22, 2023
1 parent 124ee0a commit 10a2aff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
17 changes: 14 additions & 3 deletions .dapper
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
# Pass credential file as read-only, so that the container can use it if necessary
function pass_credentials() {
local credentials=$1
local suffix=$suffix
local mountpoint=${credentials/$HOME//root}
mount_volume "$credentials" "$mountpoint"
}

function mount_volume() {
local volume="$1"
local mountpoint="$2"
local suffix="$suffix"

[ -r "$credentials" ] || return 0
[ -z "${suffix}" ] && suffix=':ro' || suffix+=',ro'
dockerargs+=" -v ${credentials}:${mountpoint}${suffix}"
[ -r "$volume" ] || return 0
dockerargs+=" -v $(realpath -s ${volume}):${mountpoint}${suffix}"
}

file=Dockerfile.dapper
Expand Down Expand Up @@ -116,6 +122,11 @@ pass_credentials "${HOME}/.aws/credentials"
# Pass through ~/.gcp/osServiceAccount.json so that the container can operate on GCP (if needed).
pass_credentials "${HOME}/.gcp/osServiceAccount.json"

# Attempt to mount any local replaces specified in `go.mod`.
while read -a replace; do
mount_volume "${replace[3]}" "${DAPPER_SOURCE}/${replace[3]}"
done < <(sed -n -e '/\breplace\b/p' go.mod)

# seccomp is unconfined to avoid problems with clone3 in Fedora 35
# See https://pascalroeleven.nl/2021/09/09/ubuntu-21-10-and-fedora-35-in-docker/
# Remove "--security-opt seccomp=unconfined" once all supported container runtimes
Expand Down
2 changes: 1 addition & 1 deletion Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ gitlint:
fi

# List of vendor/modules.txt files we might encounter
VENDOR_MODULES := $(shell find . -name vendor -prune -o -name go.mod -printf "%h/vendor/modules.txt\n")
VENDOR_MODULES := $(shell find . -name vendor -prune -o -writable -name go.mod -printf "%h/vendor/modules.txt\n")

# [golangci-lint] validates Go code in the project
golangci-lint:
Expand Down
4 changes: 2 additions & 2 deletions scripts/shared/entry
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -e

source "${SCRIPTS_DIR}/lib/debug_functions"

# shellcheck disable=SC2064 # We want the current values
trap "chown -R $DAPPER_UID:$DAPPER_GID ." exit
# Change ownership of files created inside the container
trap 'find . -writable -newercc /proc -execdir chown $DAPPER_UID:$DAPPER_GID {} +' exit

mkdir -p bin dist output

Expand Down

0 comments on commit 10a2aff

Please sign in to comment.