6 Commits

Author SHA1 Message Date
Serge Zaitsev
5a917d7c6f fix symlink checks to use OS file mode, not git file mode 2019-02-08 14:31:55 +01:00
Serge Zaitsev
c2825d2276 process git CLI flags before vcs flags 2019-02-04 15:33:54 +01:00
Serge Zaitsev
d4aafd60cf Merge branch 'master' of github.com:sixt/gomodproxy 2019-02-04 13:27:27 +01:00
Serge Zaitsev
c7f7535da8 expose module name in both, bang-encoded and normal mixed-case form 2019-02-04 13:24:47 +01:00
Andrii S
2bf79f79ab Add mount point for disk persistence (#8)
* Add mount point for disk persistence

* Use empty folder for both images
2019-01-28 09:03:37 +00:00
Serge Zaitsev
4b37c90d04 publish both, golang and scratch based containers 2019-01-25 13:50:06 +01:00
4 changed files with 65 additions and 19 deletions

View File

@@ -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"

View File

@@ -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),

View File

@@ -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
}

View File

@@ -163,7 +163,11 @@ func (g *gitVCS) Zip(ctx context.Context, version Version) (io.ReadCloser, error
if submodule(f.Name) {
continue
}
if !f.Mode.IsRegular() {
mode, err := f.Mode.ToOSFileMode()
if err != nil {
return nil, err
}
if !mode.IsRegular() {
continue
}
name := f.Name