grim/convey

e71f90d57ec7
Parents 849b90fda301
Children 02b81cdf72bf
Propagate errors from the bitbucket loader. Fixes #119
--- a/loaders/bitbucket/loader.go Mon Sep 04 23:14:28 2017 -0500
+++ b/loaders/bitbucket/loader.go Tue Sep 05 20:14:44 2017 -0500
@@ -54,7 +54,7 @@
addTask(name, task, plan, cfg)
}
-func addPipeline(name string, defImage image, pipelines []pipeline, cfg *config.Config) {
+func addPipeline(name string, defImage image, pipelines []pipeline, cfg *config.Config) error {
plan := plans.Plan{
Stages: []stages.Stage{
stages.Stage{
@@ -110,8 +110,7 @@
for scriptIdx, command := range pipeline.Steps.Script {
argv, err := shellquote.Split(command)
if err != nil {
- // TODO fix me soon by returning the error!
- panic(err)
+ return err
}
if len(argv) > 0 {
@@ -129,8 +128,7 @@
// now figure out what docker command we're running
task, err := parseDockerCommand(argv)
if err != nil {
- // TODO fix me
- panic(err)
+ return err
}
addTask(taskName, task, plan, cfg)
@@ -156,15 +154,22 @@
}
cfg.Plans[name] = plan
+
+ return nil
}
-func addPipelines(base string, defImage image, pipelines map[string][]pipeline, cfg *config.Config) {
+func addPipelines(base string, defImage image, pipelines map[string][]pipeline, cfg *config.Config) error {
for name, branchPipeline := range pipelines {
if len(branchPipeline) > 0 {
name := fmt.Sprintf("%s-%s", base, name)
- addPipeline(name, defImage, branchPipeline, cfg)
+ err := addPipeline(name, defImage, branchPipeline, cfg)
+ if err != nil {
+ return err
+ }
}
}
+
+ return nil
}
func (l *Loader) Load(base, path string, data []byte) (*config.Config, error) {
@@ -202,13 +207,31 @@
// add the default pipelines
if len(pipeline.Pipelines.Default) > 0 {
- addPipeline("default", defImage, pipeline.Pipelines.Default, cfg)
+ err = addPipeline("default", defImage, pipeline.Pipelines.Default, cfg)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ err = addPipelines("bookmark", defImage, pipeline.Pipelines.Bookmarks, cfg)
+ if err != nil {
+ return nil, err
}
- addPipelines("bookmark", defImage, pipeline.Pipelines.Bookmarks, cfg)
- addPipelines("branch", defImage, pipeline.Pipelines.Branches, cfg)
- addPipelines("custom", defImage, pipeline.Pipelines.Custom, cfg)
- addPipelines("tag", defImage, pipeline.Pipelines.Tags, cfg)
+ err = addPipelines("branch", defImage, pipeline.Pipelines.Branches, cfg)
+ if err != nil {
+ return nil, err
+ }
+
+ err = addPipelines("custom", defImage, pipeline.Pipelines.Custom, cfg)
+ if err != nil {
+ return nil, err
+ }
+
+ err = addPipelines("tag", defImage, pipeline.Pipelines.Tags, cfg)
+ if err != nil {
+ return nil, err
+ }
return cfg, nil
}
--- a/loaders/bitbucket/loader_test.go Mon Sep 04 23:14:28 2017 -0500
+++ b/loaders/bitbucket/loader_test.go Tue Sep 05 20:14:44 2017 -0500
@@ -72,8 +72,8 @@
stages.Stage{
Name: "stage-0",
Enabled: true,
- Always: false,
Concurrent: false,
+ Run: "on-success",
Environment: nil,
Tasks: []string{"import", "default-step-0-0"},
},
@@ -130,8 +130,8 @@
stages.Stage{
Name: "stage-0",
Enabled: true,
- Always: false,
Concurrent: false,
+ Run: "on-success",
Environment: nil,
Tasks: []string{"import", "default-step-0-0"},
},
@@ -199,7 +199,7 @@
stages.Stage{
Name: "stage-0",
Enabled: true,
- Always: false,
+ Run: "on-success",
Concurrent: false,
Environment: nil,
Tasks: []string{"import", "login", "default-step-0-0", "logout"},
@@ -257,8 +257,8 @@
stages.Stage{
Name: "stage-0",
Enabled: true,
- Always: false,
Concurrent: false,
+ Run: "on-success",
Environment: nil,
Tasks: []string{"import", "default-step-0-0"},
},
@@ -325,8 +325,8 @@
stages.Stage{
Name: "stage-0",
Enabled: true,
- Always: false,
Concurrent: false,
+ Run: "on-success",
Environment: nil,
Tasks: []string{"import", "default-0-login", "default-step-0-0", "default-0-logout"},
},
@@ -401,8 +401,8 @@
stages.Stage{
Name: "stage-0",
Enabled: true,
- Always: false,
Concurrent: false,
+ Run: "on-success",
Environment: nil,
Tasks: []string{
"import",
@@ -463,8 +463,8 @@
stages.Stage{
Name: "stage-0",
Enabled: true,
- Always: false,
Concurrent: false,
+ Run: "on-success",
Environment: nil,
Tasks: []string{
"import",