Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c2825d2276 | ||
|
d4aafd60cf | ||
|
c7f7535da8 | ||
|
2bf79f79ab | ||
|
4b37c90d04 |
12
.travis.yml
12
.travis.yml
@@ -12,7 +12,17 @@ script:
|
||||
- go test -v ./...
|
||||
|
||||
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" .
|
||||
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
- docker push "sixtlabs/gomodproxy-slim:latest"
|
||||
- if [ ! -z $TRAVIS_TAG ] ; then
|
||||
TAG=$(echo $TRAVIS_TAG | sed 's/^v//');
|
||||
docker tag sixtlabs/gomodproxy-slim:latest sixtlabs/gomodproxy-slim:$TAG;
|
||||
docker push sixtlabs/gomodproxy-slim:$TAG;
|
||||
fi
|
||||
- printf 'FROM golang\nADD gomodproxy /\nADD gomods /\nCMD ["/gomodproxy"]' > Dockerfile
|
||||
- docker build -t "sixtlabs/gomodproxy:latest" .
|
||||
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
- docker push "sixtlabs/gomodproxy:latest"
|
||||
|
@@ -132,14 +132,6 @@ func main() {
|
||||
}
|
||||
options = append(options, api.Log(logger))
|
||||
|
||||
for _, path := range vcsPaths {
|
||||
kv := strings.SplitN(path, ":", 2)
|
||||
if len(kv) != 2 {
|
||||
log.Fatal("bad VCS syntax:", path)
|
||||
}
|
||||
options = append(options, api.CustomVCS(kv[0], kv[1]))
|
||||
}
|
||||
|
||||
for _, path := range gitPaths {
|
||||
kv := strings.SplitN(path, ":", 2)
|
||||
if len(kv) != 2 {
|
||||
@@ -148,6 +140,14 @@ func main() {
|
||||
options = append(options, api.Git(kv[0], kv[1]))
|
||||
}
|
||||
|
||||
for _, path := range vcsPaths {
|
||||
kv := strings.SplitN(path, ":", 2)
|
||||
if len(kv) != 2 {
|
||||
log.Fatal("bad VCS syntax:", path)
|
||||
}
|
||||
options = append(options, api.CustomVCS(kv[0], kv[1]))
|
||||
}
|
||||
|
||||
options = append(options,
|
||||
api.VCSWorkers(*workers),
|
||||
api.GitDir(*gitdir),
|
||||
|
@@ -15,17 +15,37 @@ import (
|
||||
)
|
||||
|
||||
type cmdVCS struct {
|
||||
log logger
|
||||
module string
|
||||
cmd string
|
||||
log logger
|
||||
module 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 {
|
||||
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) {
|
||||
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 {
|
||||
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) {
|
||||
b, err := c.exec(ctx, "MODULE="+c.module, "ACTION=timestamp", "VERSION="+version.String(),
|
||||
"FILEPATH="+c.module+"/@v/"+version.String()+".info")
|
||||
b, err := c.exec(ctx,
|
||||
"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 {
|
||||
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) {
|
||||
b, err := c.exec(ctx, "MODULE="+c.module, "ACTION=zip", "VERSION="+version.String(),
|
||||
"FILEPATH="+c.module+"/@v/"+version.String()+".zip")
|
||||
b, err := c.exec(ctx,
|
||||
"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 {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user