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

Add build secret flag #264

Closed
wants to merge 6 commits into from
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/drone-docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ func main() {
Usage: "additional host:IP mapping",
EnvVar: "PLUGIN_ADD_HOST",
},
cli.StringSliceFlag{
Name: "secret",
Usage: "Secret file to expose to the build (only if BuildKit enabled): id=mysecret,src=/local/secret",
EnvVar: "PLUGIN_SECRET",
},
}

if err := app.Run(os.Args); err != nil {
Expand Down Expand Up @@ -274,6 +279,7 @@ func run(c *cli.Context) error {
LabelSchema: c.StringSlice("label-schema"),
NoCache: c.Bool("no-cache"),
AddHost: c.StringSlice("add-host"),
Secrets: c.StringSlice("secret"),
Quiet: c.Bool("quiet"),
},
Daemon: docker.Daemon{
Expand Down
4 changes: 4 additions & 0 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type (
Labels []string // Label map
NoCache bool // Docker build no-cache
AddHost []string // Docker build add-host
Secrets []string // Docker build secret
Quiet bool // Docker build quiet
}

Expand Down Expand Up @@ -248,6 +249,9 @@ func commandBuild(build Build) *exec.Cmd {
if build.Target != "" {
args = append(args, "--target", build.Target)
}
for _, secret := range build.Secrets {
args = append(args, "--secret", secret)
}
if build.Quiet {
args = append(args, "--quiet")
}
Expand Down