grim/convey

598a722a4678
Parents a005e09151fc
Children 9de53dd0c019
Fix extends working outside of the working directory. Fixes #150
--- a/ChangeLog Sun Jan 07 03:46:56 2018 -0600
+++ b/ChangeLog Sun Jan 07 04:07:53 2018 -0600
@@ -2,6 +2,7 @@
* Deprecated engine attribute, and changed type attribute to be {engine}/{type}. Warnings will be output if legacy formats are detected. Fixed # 143
* Unknown command line arguments are now fatal. Fixed #149
* convey/clean can now take a single string for it's files attribute. Fixed #148
+ * Fix running configs that extend other configs outside of the working directory. Fixed #150
0.11.2: 20171227
* Changed TaskTimeout to PlanTimeout. Fixed # 134
--- a/examples/base.yml Sun Jan 07 03:46:56 2018 -0600
+++ b/examples/base.yml Sun Jan 07 04:07:53 2018 -0600
@@ -19,14 +19,16 @@
plans:
plan1:
stages:
- - tasks: [one]
+ - tasks:
+ - one
plan2:
stages:
- - tasks: [two]
- plan3:
+ - tasks:
+ - two
+ default:
stages:
- name: pre
- tasks: []
- - tasks: [one, two]
+ - tasks:
+ - one
+ - two
- name: post
- tasks: []
--- a/examples/extends-merge.yml Sun Jan 07 03:46:56 2018 -0600
+++ b/examples/extends-merge.yml Sun Jan 07 04:07:53 2018 -0600
@@ -2,6 +2,13 @@
# stages of a plan defined in the parent config. This shows how
# to build "abstract" plans which can be extended in ways that
# allow blocks of plans to be replaced.
+#
+# It should output
+#
+# <= before
+# YO one
+# YO two
+# => after
extends: base.yml
@@ -19,10 +26,12 @@
command: echo "=> after"
plans:
- plan3:
+ default:
merge: true
stages:
- name: pre
- tasks: [before]
+ tasks:
+ - before
- name: post
- tasks: [after]
+ tasks:
+ - after
--- a/examples/extends.yml Sun Jan 07 03:46:56 2018 -0600
+++ b/examples/extends.yml Sun Jan 07 04:07:53 2018 -0600
@@ -1,6 +1,10 @@
# This plan extends another plan by overwriting one of the tasks
# and defining its own, then defining its own plan. The two are
# merged where anything in the extending file overwrites the base.
+#
+# HEY one
+# HEY two
+# HEY three
extends: base.yml
@@ -23,4 +27,7 @@
# one is inherited from base.yml
# two is overridden from base.yml
# three is newly defined
- - tasks: [one, two, three]
+ - tasks:
+ - one
+ - two
+ - three
--- a/loaders/convey/convey.go Sun Jan 07 03:46:56 2018 -0600
+++ b/loaders/convey/convey.go Sun Jan 07 04:07:53 2018 -0600
@@ -19,6 +19,7 @@
import (
"fmt"
+ "path/filepath"
"sort"
"strings"
@@ -84,8 +85,10 @@
return nil, ErrMaxExtendsDepth
}
+ extendsAbsName := filepath.Join(path, cfg.Extends)
+
c.depth++
- baseConfig, err = c.loadFile(cfg.Extends, allowDeprecated)
+ baseConfig, err = c.loadFile(extendsAbsName, allowDeprecated)
c.depth--
// We can safely ignore no plans and no tasks errors here