modified Docker plugin to use new Condition struct to limit execution
This commit is contained in:
parent
bd7ad88fb8
commit
167eb21b21
3 changed files with 13 additions and 8 deletions
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/drone/drone/plugin/condition"
|
||||
"github.com/drone/drone/shared/build/buildfile"
|
||||
"github.com/drone/drone/shared/build/repo"
|
||||
)
|
||||
|
||||
type Docker struct {
|
||||
|
@ -35,7 +35,8 @@ type Docker struct {
|
|||
// Do we want to override "latest" automatically with this build?
|
||||
PushLatest bool `yaml:"push_latest"`
|
||||
CustomTag string `yaml:"custom_tag"`
|
||||
Branch string `yaml:"branch"`
|
||||
|
||||
Condition *condition.Condition `yaml:"when,omitempty"`
|
||||
}
|
||||
|
||||
// Write adds commands to the buildfile to do the following:
|
||||
|
@ -43,7 +44,7 @@ type Docker struct {
|
|||
// 2. Build a docker image based on the dockerfile defined in the config.
|
||||
// 3. Push that docker image to index.docker.io.
|
||||
// 4. Delete the docker image on the server it was build on so we conserve disk space.
|
||||
func (d *Docker) Write(f *buildfile.Buildfile, r *repo.Repo) {
|
||||
func (d *Docker) Write(f *buildfile.Buildfile) {
|
||||
if len(d.DockerServer) == 0 || d.DockerServerPort == 0 || len(d.DockerVersion) == 0 ||
|
||||
len(d.ImageName) == 0 {
|
||||
f.WriteCmdSilent(`echo -e "Docker Plugin: Missing argument(s)\n\n"`)
|
||||
|
@ -124,3 +125,7 @@ func (d *Docker) Write(f *buildfile.Buildfile, r *repo.Repo) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Docker) GetCondition() *condition.Condition {
|
||||
return d.Condition
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ func (p *Publish) Write(f *buildfile.Buildfile, r *repo.Repo) {
|
|||
}
|
||||
|
||||
// Docker
|
||||
if p.Docker != nil && (len(p.Docker.Branch) == 0 || (len(p.Docker.Branch) > 0 && r.Branch == p.Docker.Branch)) {
|
||||
p.Docker.Write(f, r)
|
||||
if p.Docker != nil && match(p.Docker.GetCondition(), r) {
|
||||
p.Docker.Write(f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,9 +59,9 @@ var (
|
|||
pub *pubsub.PubSub
|
||||
|
||||
// Docker configuration details.
|
||||
tlscacert = config.String("docker-tlscacert")
|
||||
tlscert = config.String("docker-tlscert")
|
||||
tlskey = config.String("docker-tlskey")
|
||||
tlscacert = config.String("docker-tlscacert", "")
|
||||
tlscert = config.String("docker-tlscert", "")
|
||||
tlskey = config.String("docker-tlskey", "")
|
||||
nodes StringArr
|
||||
|
||||
db *sql.DB
|
||||
|
|
Loading…
Reference in a new issue