Skip to content

Commit

Permalink
Add option to mount host ssh agent (--ssh)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohenning committed Oct 22, 2021
1 parent 6ec5e71 commit b85d92e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
46 changes: 26 additions & 20 deletions cmd/drone-docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ func main() {
Usage: "additional host:IP mapping",
EnvVar: "PLUGIN_ADD_HOST",
},
cli.StringSliceFlag{
Name: "ssh-agent",
Usage: "mount ssh agent",
EnvVar: "PLUGIN_SSH_AGENT",
},
}

if err := app.Run(os.Args); err != nil {
Expand All @@ -267,26 +272,27 @@ func run(c *cli.Context) error {
Config: c.String("docker.config"),
},
Build: docker.Build{
Remote: c.String("remote.url"),
Name: c.String("commit.sha"),
Dockerfile: c.String("dockerfile"),
Context: c.String("context"),
Tags: c.StringSlice("tags"),
Args: c.StringSlice("args"),
ArgsEnv: c.StringSlice("args-from-env"),
Target: c.String("target"),
Squash: c.Bool("squash"),
Pull: c.BoolT("pull-image"),
CacheFrom: c.StringSlice("cache-from"),
Compress: c.Bool("compress"),
Repo: c.String("repo"),
Labels: c.StringSlice("custom-labels"),
LabelSchema: c.StringSlice("label-schema"),
AutoLabel: c.BoolT("auto-label"),
Link: c.String("link"),
NoCache: c.Bool("no-cache"),
AddHost: c.StringSlice("add-host"),
Quiet: c.Bool("quiet"),
Remote: c.String("remote.url"),
Name: c.String("commit.sha"),
Dockerfile: c.String("dockerfile"),
Context: c.String("context"),
Tags: c.StringSlice("tags"),
Args: c.StringSlice("args"),
ArgsEnv: c.StringSlice("args-from-env"),
Target: c.String("target"),
Squash: c.Bool("squash"),
Pull: c.BoolT("pull-image"),
CacheFrom: c.StringSlice("cache-from"),
Compress: c.Bool("compress"),
Repo: c.String("repo"),
Labels: c.StringSlice("custom-labels"),
LabelSchema: c.StringSlice("label-schema"),
AutoLabel: c.BoolT("auto-label"),
Link: c.String("link"),
NoCache: c.Bool("no-cache"),
AddHost: c.StringSlice("add-host"),
Quiet: c.Bool("quiet"),
SSHAgent: c.String("ssh-agent"),
},
Daemon: docker.Daemon{
Registry: c.String("docker.registry"),
Expand Down
4 changes: 4 additions & 0 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type (
NoCache bool // Docker build no-cache
AddHost []string // Docker build add-host
Quiet bool // Docker build quiet
SSHAgent string // Docker build ssh
}

// Plugin defines the Docker plugin parameters.
Expand Down Expand Up @@ -264,6 +265,9 @@ func commandBuild(build Build) *exec.Cmd {
if build.Quiet {
args = append(args, "--quiet")
}
if build.SSHAgent != "" {
args = append(args, "--ssh", build.SSHAgent)
}

if build.AutoLabel {
labelSchema := []string{
Expand Down

0 comments on commit b85d92e

Please sign in to comment.