Skip to content
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

include default ssh socket when given an ssh-based git url #581

Merged
merged 2 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion bake/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,11 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
}
bo.Session = append(bo.Session, secrets)

ssh, err := build.ParseSSHSpecs(t.SSH)
sshSpecs := t.SSH
if len(sshSpecs) == 0 && build.IsGitSSH(contextPath) {
sshSpecs = []string{"default"}
}
ssh, err := build.ParseSSHSpecs(sshSpecs)
if err != nil {
return nil, err
}
Expand Down
7 changes: 7 additions & 0 deletions build/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/moby/buildkit/session"
"github.com/moby/buildkit/session/sshforward/sshprovider"
"github.com/moby/buildkit/util/gitutil"
)

func ParseSSHSpecs(sl []string) (session.Attachable, error) {
Expand All @@ -29,3 +30,9 @@ func parseSSH(value string) (*sshprovider.AgentConfig, error) {
}
return &cfg, nil
}

// IsGitSSH returns true if the given repo URL is accessed over ssh
func IsGitSSH(url string) bool {
_, gitProtocol := gitutil.ParseProtocol(url)
return gitProtocol == gitutil.SSHProtocol
}
6 changes: 5 additions & 1 deletion commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ func runBuild(dockerCli command.Cli, in buildOptions) error {
}
opts.Session = append(opts.Session, secrets)

ssh, err := build.ParseSSHSpecs(in.ssh)
sshSpecs := in.ssh
if len(sshSpecs) == 0 && build.IsGitSSH(in.contextPath) {
sshSpecs = []string{"default"}
}
ssh, err := build.ParseSSHSpecs(sshSpecs)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ require (
github.com/cenkalti/backoff v2.1.1+incompatible // indirect
github.com/cloudflare/cfssl v0.0.0-20181213083726-b94e044bb51e // indirect
github.com/containerd/console v1.0.1
github.com/containerd/containerd v1.5.0-beta.3.0.20210309150730-ddf6594fbeed
github.com/containerd/containerd v1.5.0-beta.4
github.com/denisenkom/go-mssqldb v0.0.0-20190315220205-a8ed825ac853 // indirect
github.com/docker/cli v20.10.3-0.20210127070556-d26bdfd4ea23+incompatible
github.com/docker/cli v20.10.5+incompatible
github.com/docker/compose-on-kubernetes v0.4.19-0.20190128150448-356b2919c496 // indirect
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/docker v20.10.0-beta1.0.20201110211921-af34b94a78a1+incompatible
github.com/docker/docker v20.10.5+incompatible
github.com/docker/docker-credential-helpers v0.6.4-0.20210125172408-38bea2ce277a // indirect
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
github.com/docker/libtrust v0.0.0-20150526203908-9cbd2a1374f4 // indirect
Expand All @@ -37,7 +37,7 @@ require (
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/lib/pq v1.10.0 // indirect
github.com/mattn/go-sqlite3 v1.10.0 // indirect
github.com/moby/buildkit v0.8.2-0.20210322063634-8effd45b99b8
github.com/moby/buildkit v0.8.2-0.20210401015549-df49b648c8bf
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.1
github.com/pkg/errors v0.9.1
Expand Down
51 changes: 25 additions & 26 deletions go.sum

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 45 additions & 4 deletions vendor/github.com/docker/cli/cli/context/store/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/github.com/docker/docker/api/swagger.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading