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 authored and TP Honey committed Jan 17, 2023
1 parent 94c8139 commit 4d92e81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/drone-docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ func main() {
Usage: "platform value to pass to docker",
EnvVar: "PLUGIN_PLATFORM",
},
cli.StringSliceFlag{
Name: "ssh-agent",
Usage: "mount ssh agent",
EnvVar: "PLUGIN_SSH_AGENT",
},
}

if err := app.Run(os.Args); err != nil {
Expand Down Expand Up @@ -318,6 +323,7 @@ func run(c *cli.Context) error {
AddHost: c.StringSlice("add-host"),
Quiet: c.Bool("quiet"),
Platform: c.String("platform"),
SSHAgent: c.StringSlice("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 @@ -64,6 +64,7 @@ type (
AddHost []string // Docker build add-host
Quiet bool // Docker build quiet
Platform string // Docker build platform
SSHAgent []string // Docker build ssh
}

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

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

0 comments on commit 4d92e81

Please sign in to comment.