Compare commits
41 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
0822dc2dc9 | ||
|
49ce78ba79 | ||
|
696a87c7a7 | ||
|
9285c36f88 | ||
|
9caa24db3b | ||
|
d162b6a2ba | ||
|
c8409dd662 | ||
|
eca3d1768e | ||
|
4e2759e69f | ||
|
0837c80915 | ||
|
34637ebe9d | ||
|
864701dea1 | ||
|
2d868b4e26 | ||
|
9de64c0d8d | ||
|
513e50f7f5 | ||
|
3cd63129a6 | ||
|
a4d54bc847 | ||
|
00c4725d2a | ||
|
92437761df | ||
|
9c4535cb52 | ||
|
e690d870fb | ||
|
e9b53b32ae | ||
|
d4916fc30d | ||
|
68959a741a | ||
|
c327898faa | ||
|
6768e02d91 | ||
|
656e7b2fc1 | ||
|
9624b2b9ad | ||
|
48d1cf9ff8 | ||
|
52d4a68d86 | ||
|
e08d238243 | ||
|
92e846002e | ||
|
708a07fec6 | ||
|
db43a4e741 | ||
|
7a37ec05c4 | ||
|
0868adad0a | ||
|
5a917d7c6f | ||
|
c2825d2276 | ||
|
d4aafd60cf | ||
|
c7f7535da8 | ||
|
2bf79f79ab |
3
.gitignore
vendored
3
.gitignore
vendored
@ -15,3 +15,6 @@
|
|||||||
# Misc
|
# Misc
|
||||||
_gopath
|
_gopath
|
||||||
_gocache
|
_gocache
|
||||||
|
|
||||||
|
dist/
|
||||||
|
.idea/
|
20
.gitlab-ci.yml
Normal file
20
.gitlab-ci.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
variables:
|
||||||
|
CI_REGISTRY: registry.connectone.pro
|
||||||
|
CONTAINER_IMAGE: ${CI_REGISTRY}/${CI_PROJECT_PATH}:${CI_BUILD_REF_NAME}_${CI_BUILD_REF}
|
||||||
|
CONTAINER_IMAGE_LATEST: ${CI_REGISTRY}/${CI_PROJECT_PATH}:latest
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- release
|
||||||
|
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
image: docker:latest
|
||||||
|
before_script:
|
||||||
|
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
|
||||||
|
script:
|
||||||
|
- docker build -t ${CONTAINER_IMAGE_LATEST} .
|
||||||
|
- docker tag ${CONTAINER_IMAGE_LATEST} ${CONTAINER_IMAGE}
|
||||||
|
- docker push ${CONTAINER_IMAGE}
|
||||||
|
- docker push ${CONTAINER_IMAGE_LATEST}
|
||||||
|
only:
|
||||||
|
- master
|
39
.goreleaser.yaml
Normal file
39
.goreleaser.yaml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# This is an example .goreleaser.yml file with some sensible defaults.
|
||||||
|
# Make sure to check the documentation at https://goreleaser.com
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
# You may remove this if you don't use go modules.
|
||||||
|
- go mod tidy
|
||||||
|
# you may remove this if you don't need go generate
|
||||||
|
- go generate ./...
|
||||||
|
builds:
|
||||||
|
- env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
- darwin
|
||||||
|
goarch:
|
||||||
|
- arm64
|
||||||
|
- amd64
|
||||||
|
- 386
|
||||||
|
main: ./cmd/gomodproxy/main.go
|
||||||
|
archives:
|
||||||
|
- replacements:
|
||||||
|
darwin: Darwin
|
||||||
|
linux: Linux
|
||||||
|
windows: Windows
|
||||||
|
386: i386
|
||||||
|
amd64: x86_64
|
||||||
|
arm64: Arm64
|
||||||
|
checksum:
|
||||||
|
name_template: 'checksums.txt'
|
||||||
|
snapshot:
|
||||||
|
name_template: "{{ incpatch .Version }}-next"
|
||||||
|
universal_binaries:
|
||||||
|
- name_template: "{{.ProjectName}}_MacOS_{{.Version}}"
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- '^docs:'
|
||||||
|
- '^test:'
|
@ -12,7 +12,8 @@ script:
|
|||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- printf 'FROM scratch\nADD gomodproxy /\nCMD ["/gomodproxy"]' > Dockerfile
|
- mkdir gomods
|
||||||
|
- printf 'FROM scratch\nADD gomodproxy /\nADD gomods /\nCMD ["/gomodproxy"]' > Dockerfile
|
||||||
- docker build -t "sixtlabs/gomodproxy-slim:latest" .
|
- docker build -t "sixtlabs/gomodproxy-slim:latest" .
|
||||||
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||||
- docker push "sixtlabs/gomodproxy-slim:latest"
|
- docker push "sixtlabs/gomodproxy-slim:latest"
|
||||||
@ -21,7 +22,7 @@ after_success:
|
|||||||
docker tag sixtlabs/gomodproxy-slim:latest sixtlabs/gomodproxy-slim:$TAG;
|
docker tag sixtlabs/gomodproxy-slim:latest sixtlabs/gomodproxy-slim:$TAG;
|
||||||
docker push sixtlabs/gomodproxy-slim:$TAG;
|
docker push sixtlabs/gomodproxy-slim:$TAG;
|
||||||
fi
|
fi
|
||||||
- printf 'FROM golang\nADD gomodproxy /\nCMD ["/gomodproxy"]' > Dockerfile
|
- printf 'FROM golang\nADD gomodproxy /\nADD gomods /\nCMD ["/gomodproxy"]' > Dockerfile
|
||||||
- docker build -t "sixtlabs/gomodproxy:latest" .
|
- docker build -t "sixtlabs/gomodproxy:latest" .
|
||||||
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||||
- docker push "sixtlabs/gomodproxy:latest"
|
- docker push "sixtlabs/gomodproxy:latest"
|
||||||
|
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
FROM golang:1.20.1-alpine3.17 as build
|
||||||
|
WORKDIR /build
|
||||||
|
RUN apk add --no-cache git gcc musl-dev
|
||||||
|
ADD go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
ADD . .
|
||||||
|
RUN go build -o gomodproxy cmd/gomodproxy/main.go && \
|
||||||
|
chmod a+x gomodproxy
|
||||||
|
|
||||||
|
FROM golang:1.20.1-alpine3.17
|
||||||
|
ENV GONOSUMDB=gitlab.connectone.pro/*
|
||||||
|
WORKDIR /opt/app
|
||||||
|
RUN apk add --no-cache tzdata ca-certificates git openssh
|
||||||
|
COPY --from=build /build/gomodproxy ./
|
||||||
|
ADD entrypoint.sh .
|
||||||
|
RUN chmod a+x *.sh
|
||||||
|
ENTRYPOINT ["/opt/app/entrypoint.sh"]
|
||||||
|
CMD ["/opt/app/gomodproxy", "--addr", ":8080"]
|
@ -8,6 +8,10 @@ gomodproxy is a caching proxy for [Go modules].
|
|||||||
|
|
||||||
Go 1.11 has introduced optional proxy support via GOPROXY environment variable. It is essential for use cases where you want to have better control over your dependencies and handle scenarios when GitHub is down or some open-source dependency has been removed.
|
Go 1.11 has introduced optional proxy support via GOPROXY environment variable. It is essential for use cases where you want to have better control over your dependencies and handle scenarios when GitHub is down or some open-source dependency has been removed.
|
||||||
|
|
||||||
|
## Releasing
|
||||||
|
|
||||||
|
See https://goreleaser.com/quick-start/
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
gomodproxy requires Go 1.11 or newer. There are no plans to support `vgo` or Go 1.11 beta versions.
|
gomodproxy requires Go 1.11 or newer. There are no plans to support `vgo` or Go 1.11 beta versions.
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/sixt/gomodproxy/pkg/api"
|
"gitlab.connectone.pro/github/gomodproxy/pkg/api"
|
||||||
|
|
||||||
"expvar"
|
"expvar"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
@ -103,7 +103,7 @@ func main() {
|
|||||||
verbose := flag.Bool("v", false, "verbose logging")
|
verbose := flag.Bool("v", false, "verbose logging")
|
||||||
prometheus := flag.String("prometheus", "", "prometheus address")
|
prometheus := flag.String("prometheus", "", "prometheus address")
|
||||||
debug := flag.Bool("debug", false, "enable debug HTTP API (pprof/expvar)")
|
debug := flag.Bool("debug", false, "enable debug HTTP API (pprof/expvar)")
|
||||||
json := flag.Bool("json", false, "json structured logging")
|
useJsonLog := flag.Bool("json", false, "json structured logging")
|
||||||
dir := flag.String("dir", filepath.Join(os.Getenv("HOME"), ".gomodproxy/cache"), "modules cache directory")
|
dir := flag.String("dir", filepath.Join(os.Getenv("HOME"), ".gomodproxy/cache"), "modules cache directory")
|
||||||
gitdir := flag.String("gitdir", filepath.Join(os.Getenv("HOME"), ".gomodproxy/git"), "git cache directory")
|
gitdir := flag.String("gitdir", filepath.Join(os.Getenv("HOME"), ".gomodproxy/git"), "git cache directory")
|
||||||
memLimit := flag.Int64("mem", 256, "in-memory cache size in MB")
|
memLimit := flag.Int64("mem", 256, "in-memory cache size in MB")
|
||||||
@ -123,8 +123,8 @@ func main() {
|
|||||||
|
|
||||||
options := []api.Option{}
|
options := []api.Option{}
|
||||||
logger := func(...interface{}) {}
|
logger := func(...interface{}) {}
|
||||||
if *verbose || *json {
|
if *verbose || *useJsonLog {
|
||||||
if *json {
|
if *useJsonLog {
|
||||||
logger = jsonLog
|
logger = jsonLog
|
||||||
} else {
|
} else {
|
||||||
logger = prettyLog
|
logger = prettyLog
|
||||||
@ -132,6 +132,15 @@ func main() {
|
|||||||
}
|
}
|
||||||
options = append(options, api.Log(logger))
|
options = append(options, api.Log(logger))
|
||||||
|
|
||||||
|
for _, path := range gitPaths {
|
||||||
|
kv := strings.SplitN(path, ":", 2)
|
||||||
|
if len(kv) != 2 {
|
||||||
|
log.Fatal("bad git path:", path)
|
||||||
|
}
|
||||||
|
password := os.Getenv("SSH_PASSPHRASE")
|
||||||
|
options = append(options, api.GitWithEphemeralTags(kv[0], kv[1], password))
|
||||||
|
}
|
||||||
|
|
||||||
for _, path := range vcsPaths {
|
for _, path := range vcsPaths {
|
||||||
kv := strings.SplitN(path, ":", 2)
|
kv := strings.SplitN(path, ":", 2)
|
||||||
if len(kv) != 2 {
|
if len(kv) != 2 {
|
||||||
@ -140,14 +149,6 @@ func main() {
|
|||||||
options = append(options, api.CustomVCS(kv[0], kv[1]))
|
options = append(options, api.CustomVCS(kv[0], kv[1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range gitPaths {
|
|
||||||
kv := strings.SplitN(path, ":", 2)
|
|
||||||
if len(kv) != 2 {
|
|
||||||
log.Fatal("bad git path:", path)
|
|
||||||
}
|
|
||||||
options = append(options, api.Git(kv[0], kv[1]))
|
|
||||||
}
|
|
||||||
|
|
||||||
options = append(options,
|
options = append(options,
|
||||||
api.VCSWorkers(*workers),
|
api.VCSWorkers(*workers),
|
||||||
api.GitDir(*gitdir),
|
api.GitDir(*gitdir),
|
||||||
|
32
docker-compose.yml
Normal file
32
docker-compose.yml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
version: '3.2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
gomodproxy:
|
||||||
|
image: registry.connectone.pro/github/gomodproxy:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "9030:8080"
|
||||||
|
volumes:
|
||||||
|
- type: bind
|
||||||
|
source: ./cache
|
||||||
|
target: /cache
|
||||||
|
bind:
|
||||||
|
propagation: shared
|
||||||
|
- type: bind
|
||||||
|
source: ./keys
|
||||||
|
target: /root/.ssh
|
||||||
|
bind:
|
||||||
|
propagation: shared
|
||||||
|
environment:
|
||||||
|
GIT_USER: ${GIT_USER}
|
||||||
|
GIT_PASS: ${GIT_PASS}
|
||||||
|
command:
|
||||||
|
- /opt/app/gomodproxy
|
||||||
|
- --dir
|
||||||
|
- /cache
|
||||||
|
- --addr
|
||||||
|
- :8080
|
||||||
|
- -git
|
||||||
|
- gitlab.connectone.pro:/root/.ssh/id_rsa
|
||||||
|
- -git
|
||||||
|
- https://gitlab.connectone.pro:${GIT_USER}:${GIT_PASS}
|
3
entrypoint.sh
Normal file
3
entrypoint.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
git config --global url."https://${GIT_USER}:${GIT_PASS}@gitlab.connectone.pro".insteadOf "https://gitlab.connectone.pro"
|
||||||
|
exec "$@"
|
33
go.mod
33
go.mod
@ -1,13 +1,26 @@
|
|||||||
module github.com/sixt/gomodproxy
|
module gitlab.connectone.pro/github/gomodproxy
|
||||||
|
|
||||||
|
go 1.20
|
||||||
|
|
||||||
|
require github.com/go-git/go-git/v5 v5.5.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/emirpasic/gods v1.12.0 // indirect
|
github.com/Microsoft/go-winio v0.5.2 // indirect
|
||||||
github.com/pkg/errors v0.8.1 // indirect
|
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4 // indirect
|
||||||
github.com/stretchr/testify v1.3.0 // indirect
|
github.com/acomagu/bufpipe v1.0.3 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc // indirect
|
github.com/cloudflare/circl v1.1.0 // indirect
|
||||||
golang.org/x/net v0.0.0-20190110200230-915654e7eabc // indirect
|
github.com/emirpasic/gods v1.18.1 // indirect
|
||||||
golang.org/x/sys v0.0.0-20190109145017-48ac38b7c8cb // indirect
|
github.com/go-git/gcfg v1.5.0 // indirect
|
||||||
gopkg.in/src-d/go-billy.v4 v4.3.0 // indirect
|
github.com/go-git/go-billy/v5 v5.4.0 // indirect
|
||||||
gopkg.in/src-d/go-git-fixtures.v3 v3.3.0 // indirect
|
github.com/imdario/mergo v0.3.13 // indirect
|
||||||
gopkg.in/src-d/go-git.v4 v4.8.1
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||||
|
github.com/kevinburke/ssh_config v1.2.0 // indirect
|
||||||
|
github.com/pjbgf/sha1cd v0.2.3 // indirect
|
||||||
|
github.com/sergi/go-diff v1.1.0 // indirect
|
||||||
|
github.com/skeema/knownhosts v1.1.0 // indirect
|
||||||
|
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
||||||
|
golang.org/x/crypto v0.3.0 // indirect
|
||||||
|
golang.org/x/net v0.2.0 // indirect
|
||||||
|
golang.org/x/sys v0.3.0 // indirect
|
||||||
|
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||||
)
|
)
|
||||||
|
167
go.sum
167
go.sum
@ -1,68 +1,129 @@
|
|||||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
|
github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
|
||||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
|
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
|
||||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
|
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4 h1:ra2OtmuW0AE5csawV4YXMNGNQQXvLRps3z2Z59OPO+I=
|
||||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4/go.mod h1:UBYPn8k0D56RtnR8RFQMjmh4KrZzWJ5o7Z9SYjossQ8=
|
||||||
|
github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
|
||||||
|
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
|
||||||
|
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
|
||||||
|
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
|
||||||
|
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
|
||||||
|
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||||
|
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
|
||||||
|
github.com/cloudflare/circl v1.1.0 h1:bZgT/A+cikZnKIwn7xL2OBj012Bmvho/o6RpRvv3GKY=
|
||||||
|
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
|
||||||
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/emirpasic/gods v1.9.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
||||||
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
|
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
|
||||||
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
|
||||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
|
github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4=
|
||||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
|
||||||
github.com/gliderlabs/ssh v0.1.1 h1:j3L6gSLQalDETeEg/Jg0mGY0/y/N6zI2xX1978P0Uqw=
|
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
|
||||||
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
|
||||||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
github.com/go-git/go-billy/v5 v5.4.0 h1:Vaw7LaSTRJOUric7pe4vnzBSgyuf2KrLsu2Y4ZpQBDE=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/go-git/go-billy/v5 v5.4.0/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg=
|
||||||
|
github.com/go-git/go-git-fixtures/v4 v4.3.1 h1:y5z6dd3qi8Hl+stezc8p3JxDkoTRqMAlKnXHuzrfjTQ=
|
||||||
|
github.com/go-git/go-git-fixtures/v4 v4.3.1/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo=
|
||||||
|
github.com/go-git/go-git/v5 v5.5.2 h1:v8lgZa5k9ylUw+OR/roJHTxR4QItsNFI5nKtAXFuynw=
|
||||||
|
github.com/go-git/go-git/v5 v5.5.2/go.mod h1:BE5hUJ5yaV2YMxhmaP4l6RBQ08kMxKSPD4BlxtH7OjI=
|
||||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
|
||||||
|
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
||||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
|
||||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
|
||||||
github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e h1:RgQk53JHp/Cjunrr1WlsXSZpqXn+uREuHvUVcK82CV8=
|
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
|
||||||
github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||||
|
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/pelletier/go-buffruneio v0.2.0 h1:U4t4R6YkofJ5xHm3dJzuRpPZ0mr5MMCoAWooScCR7aA=
|
github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
|
||||||
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
|
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
github.com/pjbgf/sha1cd v0.2.3 h1:uKQP/7QOzNtKYH7UTohZLcjF5/55EnTw0jO/Ru4jZwI=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pjbgf/sha1cd v0.2.3/go.mod h1:HOK9QrgzdHpbc2Kzip0Q1yi3M2MFGPADtR6HjG65m5M=
|
||||||
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||||
github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
|
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
|
github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0=
|
||||||
|
github.com/skeema/knownhosts v1.1.0/go.mod h1:sKFq3RD6/TKZkSWn8boUbDC7Qkgcv+8XXijpFO6roag=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/xanzy/ssh-agent v0.2.0 h1:Adglfbi5p9Z0BmK2oKU9nTG+zKfniSfnaMYB+ULd+Ro=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/xanzy/ssh-agent v0.2.0/go.mod h1:0NyE30eGUDliuLEHJgYte/zncp2zdTStcOnWhgSqHD8=
|
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
|
||||||
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc h1:F5tKCVGp+MUAHhKp5MZtGqAlGX3+oCsiL1Q629FL90M=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/net v0.0.0-20190110200230-915654e7eabc h1:Yx9JGxI1SBhVLFjpAkWMaO1TF+xyqtHLjZpvQboJGiM=
|
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/net v0.0.0-20190110200230-915654e7eabc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/sys v0.0.0-20190109145017-48ac38b7c8cb h1:1w588/yEchbPNpa9sEvOcMZYbWHedwJjg4VOAdDHWHk=
|
golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
|
||||||
golang.org/x/sys v0.0.0-20190109145017-48ac38b7c8cb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
|
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
|
||||||
|
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||||
|
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM=
|
||||||
|
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
gopkg.in/src-d/go-billy.v4 v4.2.1/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
gopkg.in/src-d/go-billy.v4 v4.3.0 h1:KtlZ4c1OWbIs4jCv5ZXrTqG8EQocr0g/d4DjNg70aek=
|
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
|
||||||
gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
|
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
gopkg.in/src-d/go-git-fixtures.v3 v3.1.1/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
gopkg.in/src-d/go-git-fixtures.v3 v3.3.0 h1:AxUOwLW3at53ysFqs0Lg+H+8KSQXl7AEHBvWj8wEsT8=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
gopkg.in/src-d/go-git-fixtures.v3 v3.3.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
gopkg.in/src-d/go-git.v4 v4.8.1 h1:aAyBmkdE1QUUEHcP4YFCGKmsMQRAuRmUcPEQR7lOAa0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
gopkg.in/src-d/go-git.v4 v4.8.1/go.mod h1:Vtut8izDyrM8BUVQnzJ+YvmNcem2J89EmfZYCkLokZk=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
||||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
111
pkg/api/api.go
111
pkg/api/api.go
@ -15,8 +15,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/sixt/gomodproxy/pkg/store"
|
"gitlab.connectone.pro/github/gomodproxy/pkg/store"
|
||||||
"github.com/sixt/gomodproxy/pkg/vcs"
|
"gitlab.connectone.pro/github/gomodproxy/pkg/vcs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type logger = func(v ...interface{})
|
type logger = func(v ...interface{})
|
||||||
@ -27,6 +27,8 @@ type api struct {
|
|||||||
vcsPaths []vcsPath
|
vcsPaths []vcsPath
|
||||||
stores []store.Store
|
stores []store.Store
|
||||||
semc chan struct{}
|
semc chan struct{}
|
||||||
|
|
||||||
|
ephemeralTagStorage *vcs.EphemeralTagStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
type vcsPath struct {
|
type vcsPath struct {
|
||||||
@ -42,6 +44,7 @@ var (
|
|||||||
apiInfo = regexp.MustCompile(`^/(?P<module>.*)/@v/(?P<version>.*).info$`)
|
apiInfo = regexp.MustCompile(`^/(?P<module>.*)/@v/(?P<version>.*).info$`)
|
||||||
apiMod = regexp.MustCompile(`^/(?P<module>.*)/@v/(?P<version>.*).mod$`)
|
apiMod = regexp.MustCompile(`^/(?P<module>.*)/@v/(?P<version>.*).mod$`)
|
||||||
apiZip = regexp.MustCompile(`^/(?P<module>.*)/@v/(?P<version>.*).zip$`)
|
apiZip = regexp.MustCompile(`^/(?P<module>.*)/@v/(?P<version>.*).zip$`)
|
||||||
|
apiTag = regexp.MustCompile(`^/tags/(?P<module>.*)/@v/(?P<version>.*)$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -71,9 +74,9 @@ func GitDir(dir string) Option { return func(api *api) { api.gitdir = dir } }
|
|||||||
// Git configures API to use a specific git client when trying to download a
|
// Git configures API to use a specific git client when trying to download a
|
||||||
// repository with the given prefix. Auth string can be a path to the SSK key,
|
// repository with the given prefix. Auth string can be a path to the SSK key,
|
||||||
// or a colon-separated username:password string.
|
// or a colon-separated username:password string.
|
||||||
func Git(prefix string, auth string) Option {
|
func Git(prefix, key, password string) Option {
|
||||||
a := vcs.Key(auth)
|
a := vcs.Key(key, password)
|
||||||
if creds := strings.SplitN(auth, ":", 2); len(creds) == 2 {
|
if creds := strings.SplitN(key, ":", 2); len(creds) == 2 {
|
||||||
a = vcs.Password(creds[0], creds[1])
|
a = vcs.Password(creds[0], creds[1])
|
||||||
}
|
}
|
||||||
return func(api *api) {
|
return func(api *api) {
|
||||||
@ -86,6 +89,29 @@ func Git(prefix string, auth string) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GitWithEphemeralTags configures API to use a specific git client when trying
|
||||||
|
// to download a repository with the given prefix. Auth string can be a path to
|
||||||
|
// the SSK key, or a colon-separated username:password string.
|
||||||
|
func GitWithEphemeralTags(prefix, key, password string) Option {
|
||||||
|
// TODO(bilus): Ugly but we don't want to mess with the : encoding so
|
||||||
|
// we'll work around the issue of having to pass a passphrase
|
||||||
|
// to decrypt a key.
|
||||||
|
storage := vcs.NewEphemeralTagStorage()
|
||||||
|
a := vcs.Key(key, password)
|
||||||
|
if creds := strings.SplitN(key, ":", 2); len(creds) == 2 {
|
||||||
|
a = vcs.Password(creds[0], creds[1])
|
||||||
|
}
|
||||||
|
return func(api *api) {
|
||||||
|
api.ephemeralTagStorage = storage
|
||||||
|
api.vcsPaths = append(api.vcsPaths, vcsPath{
|
||||||
|
prefix: prefix,
|
||||||
|
vcs: func(module string) vcs.VCS {
|
||||||
|
return vcs.NewGitWithEphemeralTags(api.log, api.gitdir, module, a, storage)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func CustomVCS(prefix string, cmd string) Option {
|
func CustomVCS(prefix string, cmd string) Option {
|
||||||
return func(api *api) {
|
return func(api *api) {
|
||||||
api.vcsPaths = append(api.vcsPaths, vcsPath{
|
api.vcsPaths = append(api.vcsPaths, vcsPath{
|
||||||
@ -151,6 +177,7 @@ func (api *api) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
{"info", apiInfo, api.info},
|
{"info", apiInfo, api.info},
|
||||||
{"api", apiMod, api.mod},
|
{"api", apiMod, api.mod},
|
||||||
{"zip", apiZip, api.zip},
|
{"zip", apiZip, api.zip},
|
||||||
|
{"tag", apiTag, api.tag},
|
||||||
} {
|
} {
|
||||||
if m := route.regexp.FindStringSubmatch(r.URL.Path); m != nil {
|
if m := route.regexp.FindStringSubmatch(r.URL.Path); m != nil {
|
||||||
module, version := m[1], ""
|
module, version := m[1], ""
|
||||||
@ -158,6 +185,10 @@ func (api *api) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
version = m[2]
|
version = m[2]
|
||||||
}
|
}
|
||||||
module = decodeBangs(module)
|
module = decodeBangs(module)
|
||||||
|
if r.Method == http.MethodDelete && version != "" {
|
||||||
|
api.delete(w, r, module, version)
|
||||||
|
return
|
||||||
|
}
|
||||||
httpRequests.Add(route.id, 1)
|
httpRequests.Add(route.id, 1)
|
||||||
defer func() {
|
defer func() {
|
||||||
v := &expvar.Float{}
|
v := &expvar.Float{}
|
||||||
@ -179,7 +210,7 @@ func (api *api) vcs(ctx context.Context, module string) vcs.VCS {
|
|||||||
return path.vcs(module)
|
return path.vcs(module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return vcs.NewGit(api.log, api.gitdir, module, vcs.NoAuth())
|
return vcs.NewGoMod(api.log, module)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *api) module(ctx context.Context, module string, version vcs.Version) ([]byte, time.Time, error) {
|
func (api *api) module(ctx context.Context, module string, version vcs.Version) ([]byte, time.Time, error) {
|
||||||
@ -195,6 +226,12 @@ func (api *api) module(ctx context.Context, module string, version vcs.Version)
|
|||||||
api.semc <- struct{}{}
|
api.semc <- struct{}{}
|
||||||
defer func() { <-api.semc }()
|
defer func() { <-api.semc }()
|
||||||
|
|
||||||
|
return api.store(ctx, module, version)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *api) store(ctx context.Context, module string, version vcs.Version) ([]byte, time.Time, error) {
|
||||||
|
api.log("api.store", "module", module, "version", version.String())
|
||||||
|
|
||||||
timestamp, err := api.vcs(ctx, module).Timestamp(ctx, version)
|
timestamp, err := api.vcs(ctx, module).Timestamp(ctx, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, time.Time{}, err
|
return nil, time.Time{}, err
|
||||||
@ -232,7 +269,7 @@ func (api *api) list(w http.ResponseWriter, r *http.Request, module, version str
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
api.log("api.list", "module", module, "error", err)
|
api.log("api.list", "module", module, "error", err)
|
||||||
httpErrors.Add(module, 1)
|
httpErrors.Add(module, 1)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +285,7 @@ func (api *api) info(w http.ResponseWriter, r *http.Request, module, version str
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
api.log("api.info", "module", module, "version", version, "error", err)
|
api.log("api.info", "module", module, "version", version, "error", err)
|
||||||
httpErrors.Add(module, 1)
|
httpErrors.Add(module, 1)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,9 +309,11 @@ func (api *api) mod(w http.ResponseWriter, r *http.Request, module, version stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
w.Write([]byte(fmt.Sprintf("module %s\n", module)))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.Write([]byte(fmt.Sprintf("module %s\n", module)))
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *api) zip(w http.ResponseWriter, r *http.Request, module, version string) {
|
func (api *api) zip(w http.ResponseWriter, r *http.Request, module, version string) {
|
||||||
@ -283,8 +322,60 @@ func (api *api) zip(w http.ResponseWriter, r *http.Request, module, version stri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
api.log("api.zip", "module", module, "version", version, "error", err)
|
api.log("api.zip", "module", module, "version", version, "error", err)
|
||||||
httpErrors.Add(module, 1)
|
httpErrors.Add(module, 1)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
io.Copy(w, bytes.NewReader(b))
|
io.Copy(w, bytes.NewReader(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *api) delete(w http.ResponseWriter, r *http.Request, module, version string) {
|
||||||
|
for _, store := range api.stores {
|
||||||
|
if err := store.Del(r.Context(), module, vcs.Version(version)); err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *api) tag(w http.ResponseWriter, r *http.Request, module, version string) {
|
||||||
|
api.log("api.tag", "module", module, "version", version)
|
||||||
|
|
||||||
|
taggable, ok := api.vcs(r.Context(), module).(vcs.Taggable)
|
||||||
|
if !ok {
|
||||||
|
err := fmt.Errorf("repository for module %v is not taggable", module)
|
||||||
|
api.log("api.tag", "module", module, "version", version, "error", err)
|
||||||
|
httpErrors.Add(module, 1)
|
||||||
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer r.Body.Close()
|
||||||
|
|
||||||
|
req := struct {
|
||||||
|
Short string `json:"short"`
|
||||||
|
}{}
|
||||||
|
err := json.NewDecoder(r.Body).Decode(&req)
|
||||||
|
if err != nil {
|
||||||
|
api.log("api.tag", "module", module, "version", version, "error", err)
|
||||||
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for semaphore
|
||||||
|
api.semc <- struct{}{}
|
||||||
|
defer func() { <-api.semc }()
|
||||||
|
|
||||||
|
err = taggable.Tag(r.Context(), vcs.Version(version), req.Short)
|
||||||
|
if err != nil {
|
||||||
|
api.log("api.tag", "module", module, "version", version, "error", err)
|
||||||
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, err = api.store(r.Context(), module, vcs.Version(version))
|
||||||
|
if err != nil {
|
||||||
|
api.log("api.tag", "module", module, "version", version, "error", err)
|
||||||
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/sixt/gomodproxy/pkg/vcs"
|
"gitlab.connectone.pro/github/gomodproxy/pkg/vcs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type disk string
|
type disk string
|
||||||
@ -47,4 +47,15 @@ func (d disk) Get(ctx context.Context, module string, version vcs.Version) (Snap
|
|||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d disk) Del(ctx context.Context, module string, version vcs.Version) error {
|
||||||
|
dir := string(d)
|
||||||
|
s := Snapshot{Module: module, Version: version}
|
||||||
|
err := os.Remove(filepath.Join(dir, s.Key()+".time"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = os.Remove(filepath.Join(dir, s.Key()+".zip"))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (d disk) Close() error { return nil }
|
func (d disk) Close() error { return nil }
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/sixt/gomodproxy/pkg/vcs"
|
"gitlab.connectone.pro/github/gomodproxy/pkg/vcs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type memory struct {
|
type memory struct {
|
||||||
@ -45,17 +45,41 @@ func (m *memory) Put(ctx context.Context, snapshot Snapshot) error {
|
|||||||
func (m *memory) Get(ctx context.Context, module string, version vcs.Version) (Snapshot, error) {
|
func (m *memory) Get(ctx context.Context, module string, version vcs.Version) (Snapshot, error) {
|
||||||
m.Lock()
|
m.Lock()
|
||||||
defer m.Unlock()
|
defer m.Unlock()
|
||||||
return m.lookup(module, version)
|
item, err := m.lookup(module, version)
|
||||||
|
if err != nil {
|
||||||
|
return Snapshot{}, err
|
||||||
|
}
|
||||||
|
return item.Snapshot, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *memory) lookup(module string, version vcs.Version) (Snapshot, error) {
|
func (m *memory) Del(ctx context.Context, module string, version vcs.Version) error {
|
||||||
|
m.Lock()
|
||||||
|
defer m.Unlock()
|
||||||
|
item, err := m.lookup(module, version)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if item.prev == nil {
|
||||||
|
m.head = item.next
|
||||||
|
} else {
|
||||||
|
item.prev.next = item.next
|
||||||
|
}
|
||||||
|
if item.next == nil {
|
||||||
|
m.tail = item.prev
|
||||||
|
} else {
|
||||||
|
item.next.prev = item.prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *memory) lookup(module string, version vcs.Version) (*lruItem, error) {
|
||||||
for item := m.head; item != nil; item = item.next {
|
for item := m.head; item != nil; item = item.next {
|
||||||
if item.Module == module && item.Version == version {
|
if item.Module == module && item.Version == version {
|
||||||
m.update(item)
|
m.update(item)
|
||||||
return item.Snapshot, nil
|
return item, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Snapshot{}, errors.New("not found")
|
return nil, errors.New("not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *memory) insert(item *lruItem) {
|
func (m *memory) insert(item *lruItem) {
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sixt/gomodproxy/pkg/vcs"
|
"gitlab.connectone.pro/github/gomodproxy/pkg/vcs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type logger = func(...interface{})
|
type logger = func(...interface{})
|
||||||
@ -14,6 +14,7 @@ type logger = func(...interface{})
|
|||||||
type Store interface {
|
type Store interface {
|
||||||
Put(ctx context.Context, snapshot Snapshot) error
|
Put(ctx context.Context, snapshot Snapshot) error
|
||||||
Get(ctx context.Context, module string, version vcs.Version) (Snapshot, error)
|
Get(ctx context.Context, module string, version vcs.Version) (Snapshot, error)
|
||||||
|
Del(ctx context.Context, module string, version vcs.Version) error
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,17 +15,37 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type cmdVCS struct {
|
type cmdVCS struct {
|
||||||
log logger
|
log logger
|
||||||
module string
|
module string
|
||||||
cmd string
|
moduleEncoded string
|
||||||
|
cmd string
|
||||||
|
}
|
||||||
|
|
||||||
|
func encodeBangs(s string) string {
|
||||||
|
buf := []byte{}
|
||||||
|
for _, r := range s {
|
||||||
|
if 'A' <= r && r <= 'Z' {
|
||||||
|
buf = append(buf, '!', byte(r+'a'-'A'))
|
||||||
|
} else {
|
||||||
|
buf = append(buf, byte(r))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCommand(l logger, cmd string, module string) VCS {
|
func NewCommand(l logger, cmd string, module string) VCS {
|
||||||
return &cmdVCS{log: l, cmd: cmd, module: module}
|
return &cmdVCS{log: l, cmd: cmd, module: module, moduleEncoded: encodeBangs(module)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmdVCS) List(ctx context.Context) ([]Version, error) {
|
func (c *cmdVCS) List(ctx context.Context) ([]Version, error) {
|
||||||
b, err := c.exec(ctx, "MODULE="+c.module, "ACTION=list", "VERSION=latest", "FILEPATH="+c.module+"/@v/list")
|
b, err := c.exec(ctx,
|
||||||
|
"MODULE="+c.module,
|
||||||
|
"MODULE_ENCODED="+c.moduleEncoded,
|
||||||
|
"ACTION=list",
|
||||||
|
"VERSION=latest",
|
||||||
|
"FILEPATH="+c.module+"/@v/list",
|
||||||
|
"FILEPATH_ENCODED="+c.moduleEncoded+"/@v/list",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -37,8 +57,14 @@ func (c *cmdVCS) List(ctx context.Context) ([]Version, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmdVCS) Timestamp(ctx context.Context, version Version) (time.Time, error) {
|
func (c *cmdVCS) Timestamp(ctx context.Context, version Version) (time.Time, error) {
|
||||||
b, err := c.exec(ctx, "MODULE="+c.module, "ACTION=timestamp", "VERSION="+version.String(),
|
b, err := c.exec(ctx,
|
||||||
"FILEPATH="+c.module+"/@v/"+version.String()+".info")
|
"MODULE="+c.module,
|
||||||
|
"MODULE_ENCODED="+c.moduleEncoded,
|
||||||
|
"ACTION=timestamp",
|
||||||
|
"VERSION="+version.String(),
|
||||||
|
"FILEPATH="+c.module+"/@v/"+version.String()+".info",
|
||||||
|
"FILEPATH_ENCODED="+c.moduleEncoded+"/@v/"+version.String()+".info",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return time.Time{}, err
|
return time.Time{}, err
|
||||||
}
|
}
|
||||||
@ -59,8 +85,14 @@ func (c *cmdVCS) Timestamp(ctx context.Context, version Version) (time.Time, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmdVCS) Zip(ctx context.Context, version Version) (io.ReadCloser, error) {
|
func (c *cmdVCS) Zip(ctx context.Context, version Version) (io.ReadCloser, error) {
|
||||||
b, err := c.exec(ctx, "MODULE="+c.module, "ACTION=zip", "VERSION="+version.String(),
|
b, err := c.exec(ctx,
|
||||||
"FILEPATH="+c.module+"/@v/"+version.String()+".zip")
|
"MODULE="+c.module,
|
||||||
|
"MODULE_ENCODED="+c.moduleEncoded,
|
||||||
|
"ACTION=zip",
|
||||||
|
"VERSION="+version.String(),
|
||||||
|
"FILEPATH="+c.module+"/@v/"+version.String()+".zip",
|
||||||
|
"FILEPATH_ENCODED="+c.moduleEncoded+"/@v/"+version.String()+".zip",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,14 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/go-git/go-git/v5"
|
||||||
|
"github.com/go-git/go-git/v5/config"
|
||||||
|
"github.com/go-git/go-git/v5/plumbing"
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/object"
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
|
||||||
|
"github.com/go-git/go-git/v5/storage/memory"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -13,15 +21,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/src-d/go-git.v4"
|
|
||||||
"gopkg.in/src-d/go-git.v4/config"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/transport"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/transport/http"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
|
|
||||||
"gopkg.in/src-d/go-git.v4/storage/memory"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const remoteName = "origin"
|
const remoteName = "origin"
|
||||||
@ -34,6 +33,8 @@ type gitVCS struct {
|
|||||||
auth Auth
|
auth Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ErrNoMatchingVersion = errors.New("no matching versions")
|
||||||
|
|
||||||
// NewGit return a go-git VCS client implementation that provides information
|
// NewGit return a go-git VCS client implementation that provides information
|
||||||
// about the specific module using the pgiven authentication mechanism.
|
// about the specific module using the pgiven authentication mechanism.
|
||||||
func NewGit(l logger, dir string, module string, auth Auth) VCS {
|
func NewGit(l logger, dir string, module string, auth Auth) VCS {
|
||||||
@ -61,7 +62,6 @@ func (g *gitVCS) List(ctx context.Context) ([]Version, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
list := []Version{}
|
list := []Version{}
|
||||||
masterHash := ""
|
masterHash := ""
|
||||||
tagPrefix := ""
|
tagPrefix := ""
|
||||||
@ -81,18 +81,55 @@ func (g *gitVCS) List(ctx context.Context) ([]Version, error) {
|
|||||||
if masterHash == "" {
|
if masterHash == "" {
|
||||||
return nil, errors.New("no tags and no master branch found")
|
return nil, errors.New("no tags and no master branch found")
|
||||||
}
|
}
|
||||||
|
|
||||||
short := masterHash[:12]
|
short := masterHash[:12]
|
||||||
t, err := g.Timestamp(ctx, Version("v0.0.0-20060102150405-"+short))
|
version, err := g.versionFromHash(ctx, short)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
list = []Version{Version(fmt.Sprintf("v0.0.0-%s-%s", t.Format("20060102150405"), short))}
|
|
||||||
|
masterCommit, err := g.commit(ctx, version)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
tree, err := masterCommit.Tree()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// No tags while it's a module.
|
||||||
|
if g.isModule(tree) {
|
||||||
|
return nil, ErrNoMatchingVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
list = []Version{version}
|
||||||
}
|
}
|
||||||
|
|
||||||
g.log("gitVCS.List", "module", g.module, "list", list)
|
g.log("gitVCS.List", "module", g.module, "list", list)
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *gitVCS) versionFromHash(ctx context.Context, hash string) (Version, error) {
|
||||||
|
t, err := g.Timestamp(ctx, Version("v0.0.0-20060102150405-"+hash))
|
||||||
|
if err != nil {
|
||||||
|
return Version(""), err
|
||||||
|
}
|
||||||
|
v := Version(fmt.Sprintf("v0.0.0-%s-%s", t.Format("20060102150405"), hash))
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *gitVCS) isModule(tree *object.Tree) bool {
|
||||||
|
mod := "go.mod"
|
||||||
|
for path := g.prefix; path != "."; path = filepath.Dir(path) {
|
||||||
|
_, err := tree.FindEntry(filepath.Join(path, mod))
|
||||||
|
if err == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (g *gitVCS) Timestamp(ctx context.Context, version Version) (time.Time, error) {
|
func (g *gitVCS) Timestamp(ctx context.Context, version Version) (time.Time, error) {
|
||||||
g.log("gitVCS.Timestamp", "module", g.module, "version", version)
|
g.log("gitVCS.Timestamp", "module", g.module, "version", version)
|
||||||
ci, err := g.commit(ctx, version)
|
ci, err := g.commit(ctx, version)
|
||||||
@ -116,6 +153,11 @@ func isVendoredPackage(name string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *gitVCS) Zip(ctx context.Context, version Version) (io.ReadCloser, error) {
|
func (g *gitVCS) Zip(ctx context.Context, version Version) (io.ReadCloser, error) {
|
||||||
|
dirName := g.module + "@" + string(version)
|
||||||
|
return g.zipAs(ctx, version, dirName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *gitVCS) zipAs(ctx context.Context, version Version, dirName string) (io.ReadCloser, error) {
|
||||||
g.log("gitVCS.Zip", "module", g.module, "version", version)
|
g.log("gitVCS.Zip", "module", g.module, "version", version)
|
||||||
ci, err := g.commit(ctx, version)
|
ci, err := g.commit(ctx, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -163,7 +205,11 @@ func (g *gitVCS) Zip(ctx context.Context, version Version) (io.ReadCloser, error
|
|||||||
if submodule(f.Name) {
|
if submodule(f.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !f.Mode.IsRegular() {
|
mode, err := f.Mode.ToOSFileMode()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !mode.IsRegular() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
name := f.Name
|
name := f.Name
|
||||||
@ -172,7 +218,7 @@ func (g *gitVCS) Zip(ctx context.Context, version Version) (io.ReadCloser, error
|
|||||||
} else {
|
} else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
w, err := zw.Create(filepath.Join(g.module+"@"+string(version), name))
|
w, err := zw.Create(filepath.Join(dirName, name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -231,10 +277,15 @@ func (g *gitVCS) commit(ctx context.Context, version Version) (*object.Commit, e
|
|||||||
err = repo.FetchContext(ctx, &git.FetchOptions{
|
err = repo.FetchContext(ctx, &git.FetchOptions{
|
||||||
RemoteName: remoteName,
|
RemoteName: remoteName,
|
||||||
Auth: auth,
|
Auth: auth,
|
||||||
|
Tags: git.AllTags,
|
||||||
})
|
})
|
||||||
if err != nil && err != git.NoErrAlreadyUpToDate {
|
if err != nil && err != git.NoErrAlreadyUpToDate {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
tagPrefix := ""
|
||||||
|
if g.prefix != "" {
|
||||||
|
tagPrefix = g.prefix + "/"
|
||||||
|
}
|
||||||
|
|
||||||
version = Version(strings.TrimSuffix(string(version), "+incompatible"))
|
version = Version(strings.TrimSuffix(string(version), "+incompatible"))
|
||||||
hash := version.Hash()
|
hash := version.Hash()
|
||||||
@ -244,7 +295,7 @@ func (g *gitVCS) commit(ctx context.Context, version Version) (*object.Commit, e
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
tags.ForEach(func(t *plumbing.Reference) error {
|
tags.ForEach(func(t *plumbing.Reference) error {
|
||||||
if t.Name().String() == "refs/tags/"+string(version) {
|
if t.Name().String() == path.Join("refs/tags", tagPrefix, string(version)) {
|
||||||
hash = t.Hash().String()
|
hash = t.Hash().String()
|
||||||
annotated, err := repo.TagObject(t.Hash())
|
annotated, err := repo.TagObject(t.Hash())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -272,7 +323,7 @@ func (g *gitVCS) commit(ctx context.Context, version Version) (*object.Commit, e
|
|||||||
|
|
||||||
func (g *gitVCS) authMethod() (transport.AuthMethod, error) {
|
func (g *gitVCS) authMethod() (transport.AuthMethod, error) {
|
||||||
if g.auth.Key != "" {
|
if g.auth.Key != "" {
|
||||||
return ssh.NewPublicKeysFromFile("git", g.auth.Key, "")
|
return ssh.NewPublicKeysFromFile("git", g.auth.Key, g.auth.Password)
|
||||||
} else if g.auth.Username != "" {
|
} else if g.auth.Username != "" {
|
||||||
return &http.BasicAuth{Username: g.auth.Username, Password: g.auth.Password}, nil
|
return &http.BasicAuth{Username: g.auth.Username, Password: g.auth.Password}, nil
|
||||||
}
|
}
|
||||||
|
87
pkg/vcs/gomod.go
Normal file
87
pkg/vcs/gomod.go
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
package vcs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type goVCS struct {
|
||||||
|
dir string
|
||||||
|
log logger
|
||||||
|
module string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGoMod(l logger, module string) VCS {
|
||||||
|
return &goVCS{log: l, module: module, dir: "/tmp/_go"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *goVCS) List(ctx context.Context) ([]Version, error) {
|
||||||
|
if err := g.download(ctx, "latest"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b, err := g.file("list")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
versions := []Version{}
|
||||||
|
for _, line := range strings.Split(string(b), "\n") {
|
||||||
|
versions = append(versions, Version(line))
|
||||||
|
}
|
||||||
|
return versions, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *goVCS) Timestamp(ctx context.Context, version Version) (time.Time, error) {
|
||||||
|
if err := g.download(ctx, version.String()); err != nil {
|
||||||
|
return time.Time{}, err
|
||||||
|
}
|
||||||
|
b, err := g.file(version.String() + ".info")
|
||||||
|
if err != nil {
|
||||||
|
return time.Time{}, err
|
||||||
|
}
|
||||||
|
info := struct {
|
||||||
|
Version string
|
||||||
|
Time time.Time
|
||||||
|
}{}
|
||||||
|
if json.Unmarshal(b, &info) == nil {
|
||||||
|
return info.Time, nil
|
||||||
|
}
|
||||||
|
if t, err := time.Parse(time.RFC3339, string(b)); err == nil {
|
||||||
|
return t, nil
|
||||||
|
}
|
||||||
|
if sec, err := strconv.ParseInt(string(b), 10, 64); err == nil {
|
||||||
|
return time.Unix(sec, 0), nil
|
||||||
|
}
|
||||||
|
return time.Time{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *goVCS) Zip(ctx context.Context, version Version) (io.ReadCloser, error) {
|
||||||
|
if err := g.download(ctx, version.String()); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b, err := g.file(version.String() + ".zip")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ioutil.NopCloser(bytes.NewReader(b)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *goVCS) download(ctx context.Context, version string) error {
|
||||||
|
cmd := exec.Command("go", "mod", "download", g.module+"@"+version)
|
||||||
|
cmd.Env = append(os.Environ(), "GOPATH="+g.dir)
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
return cmd.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *goVCS) file(name string) ([]byte, error) {
|
||||||
|
path := filepath.Join(g.dir, "pkg", "mod", "cache", "download", encodeBangs(g.module), "@v", name)
|
||||||
|
return ioutil.ReadFile(path)
|
||||||
|
}
|
146
pkg/vcs/tags.go
Normal file
146
pkg/vcs/tags.go
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
package vcs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ephemeralTag struct {
|
||||||
|
semVer Version
|
||||||
|
short string
|
||||||
|
}
|
||||||
|
|
||||||
|
type EphemeralTagStorage struct {
|
||||||
|
tagsByModule map[moduleName][]ephemeralTag
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewEphemeralTagStorage() *EphemeralTagStorage {
|
||||||
|
return &EphemeralTagStorage{
|
||||||
|
tagsByModule: make(map[moduleName][]ephemeralTag),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *EphemeralTagStorage) Tag(module string, semVer Version, short string) error {
|
||||||
|
tags := s.tagsByModule[module]
|
||||||
|
tmp := tags[:0]
|
||||||
|
for _, t := range tags {
|
||||||
|
if t.semVer != semVer {
|
||||||
|
tmp = append(tmp, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.tagsByModule[module] = append(tmp, ephemeralTag{semVer, short})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *EphemeralTagStorage) tags(module string) []ephemeralTag {
|
||||||
|
return s.tagsByModule[module]
|
||||||
|
}
|
||||||
|
|
||||||
|
type moduleName = string
|
||||||
|
|
||||||
|
type taggableVCS struct {
|
||||||
|
wrapped *gitVCS
|
||||||
|
module string
|
||||||
|
storage *EphemeralTagStorage
|
||||||
|
}
|
||||||
|
|
||||||
|
type Taggable interface {
|
||||||
|
Tag(ctx context.Context, semVer Version, short string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGitWithEphemeralTags return a go-git VCS client implementation that
|
||||||
|
// provides information about the specific module using the given
|
||||||
|
// authentication mechanism while adding support to ephemeral tags.
|
||||||
|
func NewGitWithEphemeralTags(l logger, dir string, module string, auth Auth, storage *EphemeralTagStorage) VCS {
|
||||||
|
git := NewGit(l, dir, module, auth).(*gitVCS)
|
||||||
|
return &taggableVCS{
|
||||||
|
wrapped: git,
|
||||||
|
module: module,
|
||||||
|
storage: storage,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *taggableVCS) safeList(ctx context.Context) ([]Version, error) {
|
||||||
|
remoteVersions, err := v.wrapped.List(ctx)
|
||||||
|
if err != nil {
|
||||||
|
// Ignore this error, we can still count on ephemeral tags.
|
||||||
|
if err != ErrNoMatchingVersion {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
v.wrapped.log("No remote version tags yet:", err)
|
||||||
|
}
|
||||||
|
return remoteVersions, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *taggableVCS) Tag(ctx context.Context, semVer Version, short string) error {
|
||||||
|
remoteVersions, err := v.safeList(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if versionExists(remoteVersions, semVer) {
|
||||||
|
return fmt.Errorf("remote version %s already exists for module %s", semVer, v.module)
|
||||||
|
}
|
||||||
|
v.wrapped.log("taggableVCS.Tag", "version", semVer, "short", short)
|
||||||
|
return v.storage.Tag(v.module, semVer, short)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *taggableVCS) List(ctx context.Context) ([]Version, error) {
|
||||||
|
remoteVersions, err := v.safeList(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tags := v.storage.tags(v.module)
|
||||||
|
// Remote versions win.
|
||||||
|
allVersions := appendEphemeralVersion(remoteVersions, tags...)
|
||||||
|
// TODO(bilus): BUG - tag version 1.0.0 and then 0.1.0 - 0.1.0 is the "latest".
|
||||||
|
// sort.Slice(allVersions, func(i, j) bool { return allVersions[i].Before(allVersions[j]) })
|
||||||
|
return allVersions, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendEphemeralVersion(versions []Version, tags ...ephemeralTag) []Version {
|
||||||
|
ephemeral := make([]Version, 0)
|
||||||
|
for _, tag := range tags {
|
||||||
|
if !versionExists(versions, tag.semVer) {
|
||||||
|
ephemeral = append(ephemeral, tag.semVer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return append(versions, ephemeral...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func versionExists(versions []Version, v Version) bool {
|
||||||
|
for _, v2 := range versions {
|
||||||
|
if v == v2 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *taggableVCS) Timestamp(ctx context.Context, version Version) (time.Time, error) {
|
||||||
|
version2, err := v.resolveVersion(ctx, version)
|
||||||
|
if err != nil {
|
||||||
|
return time.Time{}, err
|
||||||
|
}
|
||||||
|
return v.wrapped.Timestamp(ctx, version2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *taggableVCS) Zip(ctx context.Context, version Version) (io.ReadCloser, error) {
|
||||||
|
version2, err := v.resolveVersion(ctx, version)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// Zip must contain the ephemeral version.
|
||||||
|
dirName := v.module + "@" + string(version)
|
||||||
|
return v.wrapped.zipAs(ctx, version2, dirName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *taggableVCS) resolveVersion(ctx context.Context, version Version) (Version, error) {
|
||||||
|
for _, tag := range v.storage.tags(v.module) {
|
||||||
|
if tag.semVer == version {
|
||||||
|
return v.wrapped.versionFromHash(ctx, tag.short)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return version, nil
|
||||||
|
}
|
@ -61,4 +61,4 @@ func NoAuth() Auth { return Auth{} }
|
|||||||
func Password(username, password string) Auth { return Auth{Username: username, Password: password} }
|
func Password(username, password string) Auth { return Auth{Username: username, Password: password} }
|
||||||
|
|
||||||
// Key returns an Auth implementation that uses key file authentication mechanism.
|
// Key returns an Auth implementation that uses key file authentication mechanism.
|
||||||
func Key(key string) Auth { return Auth{Key: key} }
|
func Key(key, password string) Auth { return Auth{Key: key, Password: password} }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user