2014-02-07 10:10:01 +00:00
|
|
|
package deploy
|
|
|
|
|
|
|
|
import (
|
2014-09-08 06:08:35 +00:00
|
|
|
"github.com/drone/drone/plugin/condition"
|
2014-10-12 02:20:47 +00:00
|
|
|
"github.com/drone/drone/shared/build/buildfile"
|
|
|
|
"github.com/drone/drone/shared/build/repo"
|
|
|
|
|
2014-10-12 01:55:58 +00:00
|
|
|
"github.com/drone/drone/plugin/deploy/git"
|
|
|
|
"github.com/drone/drone/plugin/deploy/heroku"
|
2014-11-27 17:46:15 +00:00
|
|
|
"github.com/drone/drone/plugin/deploy/deis"
|
2014-10-12 02:20:47 +00:00
|
|
|
"github.com/drone/drone/plugin/deploy/modulus"
|
2014-10-12 02:32:31 +00:00
|
|
|
"github.com/drone/drone/plugin/deploy/nodejitsu"
|
2014-10-12 01:55:58 +00:00
|
|
|
"github.com/drone/drone/plugin/deploy/tsuru"
|
2014-02-07 10:10:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Deploy stores the configuration details
|
|
|
|
// for deploying build artifacts when
|
|
|
|
// a Build has succeeded
|
|
|
|
type Deploy struct {
|
2014-10-12 02:32:31 +00:00
|
|
|
CloudFoundry *CloudFoundry `yaml:"cloudfoundry,omitempty"`
|
|
|
|
Git *git.Git `yaml:"git,omitempty"`
|
|
|
|
Heroku *heroku.Heroku `yaml:"heroku,omitempty"`
|
2014-11-27 17:46:15 +00:00
|
|
|
Deis *deis.Deis `yaml:"deis,omitempty"`
|
2014-10-12 02:32:31 +00:00
|
|
|
Modulus *modulus.Modulus `yaml:"modulus,omitempty"`
|
|
|
|
Nodejitsu *nodejitsu.Nodejitsu `yaml:"nodejitsu,omitempty"`
|
|
|
|
SSH *SSH `yaml:"ssh,omitempty"`
|
|
|
|
Tsuru *tsuru.Tsuru `yaml:"tsuru,omitempty"`
|
|
|
|
Bash *Bash `yaml:"bash,omitempty"`
|
2014-02-07 10:10:01 +00:00
|
|
|
}
|
|
|
|
|
2014-09-08 06:08:35 +00:00
|
|
|
func (d *Deploy) Write(f *buildfile.Buildfile, r *repo.Repo) {
|
|
|
|
|
|
|
|
if d.CloudFoundry != nil && match(d.CloudFoundry.GetCondition(), r) {
|
2014-02-07 10:10:01 +00:00
|
|
|
d.CloudFoundry.Write(f)
|
|
|
|
}
|
2014-09-08 06:08:35 +00:00
|
|
|
if d.Git != nil && match(d.Git.GetCondition(), r) {
|
2014-02-11 19:28:50 +00:00
|
|
|
d.Git.Write(f)
|
|
|
|
}
|
2014-09-08 06:08:35 +00:00
|
|
|
if d.Heroku != nil && match(d.Heroku.GetCondition(), r) {
|
2014-02-07 10:10:01 +00:00
|
|
|
d.Heroku.Write(f)
|
|
|
|
}
|
2014-11-27 17:46:15 +00:00
|
|
|
if d.Deis != nil && match(d.Deis.GetCondition(), r) {
|
|
|
|
d.Deis.Write(f)
|
|
|
|
}
|
2014-09-08 06:08:35 +00:00
|
|
|
if d.Modulus != nil && match(d.Modulus.GetCondition(), r) {
|
2014-02-23 17:08:44 +00:00
|
|
|
d.Modulus.Write(f)
|
|
|
|
}
|
2014-09-08 06:08:35 +00:00
|
|
|
if d.Nodejitsu != nil && match(d.Nodejitsu.GetCondition(), r) {
|
2014-02-07 10:10:01 +00:00
|
|
|
d.Nodejitsu.Write(f)
|
|
|
|
}
|
2014-09-08 06:08:35 +00:00
|
|
|
if d.SSH != nil && match(d.SSH.GetCondition(), r) {
|
2014-02-23 13:19:00 +00:00
|
|
|
d.SSH.Write(f)
|
|
|
|
}
|
2014-09-08 06:08:35 +00:00
|
|
|
if d.Tsuru != nil && match(d.Tsuru.GetCondition(), r) {
|
2014-03-23 02:22:01 +00:00
|
|
|
d.Tsuru.Write(f)
|
|
|
|
}
|
2014-09-08 06:08:35 +00:00
|
|
|
if d.Bash != nil && match(d.Bash.GetCondition(), r) {
|
2014-03-19 20:36:14 +00:00
|
|
|
d.Bash.Write(f)
|
|
|
|
}
|
2014-02-07 10:10:01 +00:00
|
|
|
}
|
2014-09-08 06:08:35 +00:00
|
|
|
|
|
|
|
func match(c *condition.Condition, r *repo.Repo) bool {
|
|
|
|
switch {
|
|
|
|
case c == nil:
|
|
|
|
return true
|
|
|
|
case !c.MatchBranch(r.Branch):
|
|
|
|
return false
|
|
|
|
case !c.MatchOwner(r.Name):
|
|
|
|
return false
|
|
|
|
case !c.MatchPullRequest(r.PR):
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|