Skip to content

git: support all git transports - #416

Merged
AkihiroSuda merged 1 commit into
moby:masterfrom
tonistiigi:git-transports
May 30, 2018
Merged

AkihiroSuda merged 1 commit into
moby:masterfrom
tonistiigi:git-transports

Conversation

@tonistiigi

Copy link
Copy Markdown
Member

Add clearer support for all supported git transports that optionally switch to another attribute field instead of making invalid URLs. Also, update dockerfile to accept https://../repo.git as a git URL instead of HTTP URL

Signed-off-by: Tonis Tiigi tonistiigi@gmail.com

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
if httpPrefix.MatchString(ref) && gitUrlPathWithFragmentSuffix.MatchString(ref) {
found = true
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not robust, although go get does similar stuff with support for gitlab and bitbucket (IIRC docker does not)

Can we use another opt string?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker build uses similar logic to switch between http/git. If we use a separate field we just need to do this in a wrapper and users need to remember that docker build and dockerfile frontend take different opts. Also, we probably still would need to validate this value in a similar way as llb.Git() doesn't necessarily handle any string.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC docker build does not depend on "github.com" string, unlike this PR and go get?
https://github.com/moby/moby/blob/master/builder/remotecontext/git/gitutils.go

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮 sorry didn't notice

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that on the CLI, a test was added (docker/cli#390) to make sure that an existing local directory starting with github.com/ is not ignored; https://github.com/docker/cli/blob/0f11a310fd7d64a697d0ed9098205b6cdd585f1b/cli/command/image/build_test.go#L176-L196

@tonistiigi

Copy link
Copy Markdown
Member Author

Something is really up with gcr/travis today. I've restarted many times already

Received unexpected error rpc error: code = Unknown desc = failed to do request: Head https://gcr.io/v2/google_containers/pause/manifests/sha256:0d093c962a6c2dd8bb8727b661e2b5f13e9df884af9945b4cc7088d9350cd3ee: dial tcp 74.125.124.82:443: i/o timeout

@AkihiroSuda

AkihiroSuda commented May 30, 2018 •

Copy link
Copy Markdown
Member

LGTM but probably we should also add gitlab to both Docker/Moby and BuildKit later.

EDIT: we should NOT, see moby/moby#37173

@tonistiigi

Copy link
Copy Markdown
Member Author

re: ci, is it possible that #417 broke something?

@AkihiroSuda

Copy link
Copy Markdown
Member

restarted and green

)

var httpPrefix = regexp.MustCompile("^https?://")
var gitUrlPathWithFragmentSuffix = regexp.MustCompile(".git(?:#.+)?$")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super minor but I think the first . (in .git) needs escaping since you want a literal . not to match any char.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very related: moby/moby#47109 😄 ❤️

found = true
}

for _, prefix := range []string{"git://", "github.com/", "git@"} {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it weren't for the github.com/ (which I think is/should be Dockerfile specific) in here this would be quite a convenient utility function for the common case, is there some way we could extract/abstract it perhaps?

A new SourceFromPath function which produced either an llb.Git or an llb.Local depending what it found might be useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants