-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vendor with go mod #3387
vendor with go mod #3387
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ | |
/man/man*/ | ||
/docs/yaml/gen/ | ||
profile.out | ||
/vndr.log | ||
|
||
# top-level go.mod is not meant to be checked in | ||
/go.mod |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Dockerfile* linguist-language=Dockerfile | ||
vendor.mod linguist-language=Go-Module | ||
vendor.sum linguist-language=Go-Checksums | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,11 +49,18 @@ dynbinary: ## build dynamically linked binary | |
plugins: ## build example CLI plugins | ||
./scripts/build/plugins | ||
|
||
vendor: vendor.conf ## check that vendor matches vendor.conf | ||
.PHONY: vendor | ||
vendor: ## update vendor with go modules | ||
rm -rf vendor | ||
bash -c 'vndr |& grep -v -i clone | tee ./vndr.log' | ||
scripts/validate/check-git-diff vendor | ||
scripts/validate/check-all-packages-vendored | ||
./scripts/vendor update | ||
|
||
.PHONY: validate-vendor | ||
validate-vendor: ## validate vendor | ||
./scripts/vendor validate | ||
|
||
.PHONY: mod-outdated | ||
mod-outdated: ## check outdated dependencies | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not yet in use, correct? (more of a "local dependabot check") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this is only intended for local check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sample output:
|
||
./scripts/vendor outdated | ||
|
||
.PHONY: authors | ||
authors: ## generate AUTHORS file from git history | ||
|
@@ -73,6 +80,5 @@ help: ## print this help | |
|
||
.PHONY: ci-validate | ||
ci-validate: | ||
time make -B vendor | ||
time make manpages | ||
time make yamldocs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# syntax=docker/dockerfile:1.3-labs | ||
|
||
ARG GO_VERSION=1.16.11 | ||
ARG MODOUTDATED_VERSION=v0.8.0 | ||
|
||
FROM golang:${GO_VERSION}-alpine AS base | ||
RUN apk add --no-cache bash git rsync | ||
WORKDIR /src | ||
|
||
FROM base AS vendored | ||
RUN --mount=target=/context \ | ||
--mount=target=.,type=tmpfs \ | ||
--mount=target=/go/pkg/mod,type=cache <<EOT | ||
set -e | ||
rsync -a /context/. . | ||
./scripts/vendor update | ||
mkdir /out | ||
cp -r vendor.mod vendor.sum vendor /out | ||
EOT | ||
|
||
FROM scratch AS update | ||
COPY --from=vendored /out /out | ||
|
||
FROM vendored AS validate | ||
RUN --mount=target=/context \ | ||
--mount=target=.,type=tmpfs <<EOT | ||
set -e | ||
rsync -a /context/. . | ||
git add -A | ||
rm -rf vendor | ||
cp -rf /out/* . | ||
./scripts/vendor validate | ||
EOT | ||
|
||
FROM psampaz/go-mod-outdated:${MODOUTDATED_VERSION} AS go-mod-outdated | ||
FROM base AS outdated | ||
ARG UUID | ||
RUN --mount=target=.,rw \ | ||
--mount=target=/go/pkg/mod,type=cache \ | ||
--mount=from=go-mod-outdated,source=/home/go-mod-outdated,target=/usr/bin/go-mod-outdated \ | ||
./scripts/vendor outdated |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
TYP=$1 | ||
|
||
usage() { | ||
echo "usage: ./scripts/vendor <update|validate|outdated>" | ||
exit 1 | ||
} | ||
|
||
if [ -z "$TYP" ]; then | ||
usage | ||
fi | ||
|
||
# create dummy go.mod, see comment in vendor.mod | ||
cat > go.mod <<EOL | ||
module github.com/docker/cli | ||
|
||
go 1.16 | ||
EOL | ||
|
||
update() { | ||
(set -x ; go mod vendor -modfile=vendor.mod) | ||
} | ||
|
||
validate() { | ||
(set -x ; go mod tidy -modfile=vendor.mod) | ||
diff=$(git status --porcelain -- vendor.mod vendor.sum vendor) | ||
if [ -n "$diff" ]; then | ||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make -f docker.Makefile vendor"' | ||
echo "$diff" | ||
exit 1 | ||
fi | ||
crazy-max marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
outdated() { | ||
if [ ! -x "$(command -v go-mod-outdated)" ]; then | ||
echo "go-mod-outdated not found. Install with 'go install github.com/psampaz/go-mod-outdated@v0.8.0'" | ||
exit 1 | ||
fi | ||
(set -x ; go list -mod=vendor -mod=readonly -modfile=vendor.mod -u -m -json all | go-mod-outdated -update -direct) | ||
} | ||
|
||
case $TYP in | ||
"update") | ||
update | ||
;; | ||
"validate") | ||
update | ||
validate | ||
;; | ||
"outdated") | ||
outdated | ||
;; | ||
*) | ||
echo >&2 "Unknown type $TYP" | ||
exit 1 | ||
;; | ||
esac |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@errordeveloper Just stylish stuff you can add to match the proper language using gitattributes:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!