switch from Clone to Workspace object

This commit is contained in:
Brad Rydzewski 2015-09-02 15:30:42 -07:00
parent c6f4642586
commit a92ebb2b11

21
main.go
View File

@ -24,15 +24,14 @@ type Docker struct {
} }
func main() { func main() {
clone := plugin.Clone{} workspace := plugin.Workspace{}
build := plugin.Build{}
vargs := Docker{} vargs := Docker{}
plugin.Param("clone", &clone) plugin.Param("workspace", &workspace)
plugin.Param("build", &build)
plugin.Param("vargs", &vargs) plugin.Param("vargs", &vargs)
if err := plugin.Parse(); err != nil { plugin.MustParse()
println(err.Error())
os.Exit(1)
}
// Set the storage driver // Set the storage driver
if len(vargs.Storage) == 0 { if len(vargs.Storage) == 0 {
@ -76,9 +75,9 @@ func main() {
// Set the Tag value // Set the Tag value
switch vargs.Tag { switch vargs.Tag {
case "$DRONE_BRANCH": case "$DRONE_BRANCH":
vargs.Tag = clone.Branch vargs.Tag = build.Commit.Branch
case "$DRONE_COMMIT": case "$DRONE_COMMIT":
vargs.Tag = clone.Sha vargs.Tag = build.Commit.Sha
case "": case "":
vargs.Tag = "latest" vargs.Tag = "latest"
} }
@ -86,7 +85,7 @@ func main() {
// Login to Docker // Login to Docker
cmd := exec.Command("docker", "login", "-u", vargs.Username, "-p", vargs.Password, "-e", vargs.Email, vargs.Registry) cmd := exec.Command("docker", "login", "-u", vargs.Username, "-p", vargs.Password, "-e", vargs.Email, vargs.Registry)
cmd.Dir = clone.Dir cmd.Dir = workspace.Path
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
err := cmd.Run() err := cmd.Run()
@ -109,7 +108,7 @@ func main() {
// Build the container // Build the container
cmd = exec.Command("docker", "build", "--pull=true", "--rm=true", "-t", vargs.Repo, vargs.File) cmd = exec.Command("docker", "build", "--pull=true", "--rm=true", "-t", vargs.Repo, vargs.File)
cmd.Dir = clone.Dir cmd.Dir = workspace.Path
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
trace(cmd) trace(cmd)
@ -121,7 +120,7 @@ func main() {
// Push the container // Push the container
cmd = exec.Command("docker", "push", vargs.Repo) cmd = exec.Command("docker", "push", vargs.Repo)
cmd.Dir = clone.Dir cmd.Dir = workspace.Path
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
trace(cmd) trace(cmd)