From 3920fd92fed4966284b8cccb112e73a4bde350cb Mon Sep 17 00:00:00 2001 From: Matt Hernandez Date: Sun, 23 Feb 2014 12:02:53 -0500 Subject: [PATCH 1/4] Added Modulus deployment. Uses the configuration options of: Token (the user's Modulus API token) and project (the project to deploy to). --- pkg/plugin/deploy/modulus.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 pkg/plugin/deploy/modulus.go diff --git a/pkg/plugin/deploy/modulus.go b/pkg/plugin/deploy/modulus.go new file mode 100644 index 000000000..192fccef8 --- /dev/null +++ b/pkg/plugin/deploy/modulus.go @@ -0,0 +1,20 @@ +package deploy + +import ( + "fmt" + "github.com/drone/drone/pkg/build/buildfile" +) + +type Modulus struct { + Project string `yaml:"project,omitempty"` + Token string `yaml:"token,omitempty"` +} + +func (m *Modulus) Write(f *buildfile.Buildfile) { + f.writeEnv("MODULUS_TOKEN", m.Token) + + // Install the Modulus command line interface then deploy the configured + // project. + f.WriteCmdSilent("npm install -g modulus") + f.WriteCmd(fmt.Sprintf("modulus deploy -p '%s'", m.App)) +} From 77e2837ff0b9904e8cef26609f0fbc1ab6cb268e Mon Sep 17 00:00:00 2001 From: Matt Hernandez Date: Sun, 23 Feb 2014 12:08:44 -0500 Subject: [PATCH 2/4] Add Modulus to deployment class. Allow the Modulus deployment type to be used. --- pkg/plugin/deploy/deployment.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/plugin/deploy/deployment.go b/pkg/plugin/deploy/deployment.go index 0181586c4..8b190eb73 100644 --- a/pkg/plugin/deploy/deployment.go +++ b/pkg/plugin/deploy/deployment.go @@ -14,6 +14,7 @@ type Deploy struct { EngineYard *EngineYard `yaml:"engineyard,omitempty"` Git *Git `yaml:"git,omitempty"` Heroku *Heroku `yaml:"heroku,omitempty"` + Modulus *Modulus `yaml:"modulus,omitempty"` Nodejitsu *Nodejitsu `yaml:"nodejitsu,omitempty"` Openshift *Openshift `yaml:"openshift,omitempty"` } @@ -37,6 +38,9 @@ func (d *Deploy) Write(f *buildfile.Buildfile) { if d.Heroku != nil { d.Heroku.Write(f) } + if d.Modulus != nil { + d.Modulus.Write(f) + } if d.Nodejitsu != nil { d.Nodejitsu.Write(f) } From 492ac956ca1abbb7918c5a592b6f595398254e9c Mon Sep 17 00:00:00 2001 From: Matt Hernandez Date: Sun, 23 Feb 2014 18:07:25 -0500 Subject: [PATCH 3/4] Fixes. Fixed the WriteEnv usage and updated to allow for sudo if necessary. --- pkg/plugin/deploy/modulus.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/plugin/deploy/modulus.go b/pkg/plugin/deploy/modulus.go index 192fccef8..4f016e76e 100644 --- a/pkg/plugin/deploy/modulus.go +++ b/pkg/plugin/deploy/modulus.go @@ -11,10 +11,11 @@ type Modulus struct { } func (m *Modulus) Write(f *buildfile.Buildfile) { - f.writeEnv("MODULUS_TOKEN", m.Token) + f.WriteEnv("MODULUS_TOKEN", m.Token) // Install the Modulus command line interface then deploy the configured // project. - f.WriteCmdSilent("npm install -g modulus") + f.WriteCmdSilent("[ -f /usr/bin/sudo ] || npm install -g modulus") + f.WriteCmdSilent("[ -f /usr/bin/sudo ] && sudo npm install -g modulus") f.WriteCmd(fmt.Sprintf("modulus deploy -p '%s'", m.App)) } From 40296fbd9317a9af47a80e31774203e7c8df5724 Mon Sep 17 00:00:00 2001 From: Matt Hernandez Date: Sun, 23 Feb 2014 18:10:01 -0500 Subject: [PATCH 4/4] Corrected project usage. --- pkg/plugin/deploy/modulus.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/plugin/deploy/modulus.go b/pkg/plugin/deploy/modulus.go index 4f016e76e..02a41b6d6 100644 --- a/pkg/plugin/deploy/modulus.go +++ b/pkg/plugin/deploy/modulus.go @@ -17,5 +17,5 @@ func (m *Modulus) Write(f *buildfile.Buildfile) { // project. f.WriteCmdSilent("[ -f /usr/bin/sudo ] || npm install -g modulus") f.WriteCmdSilent("[ -f /usr/bin/sudo ] && sudo npm install -g modulus") - f.WriteCmd(fmt.Sprintf("modulus deploy -p '%s'", m.App)) + f.WriteCmd(fmt.Sprintf("modulus deploy -p '%s'", m.Project)) }