grim/convey

2b2135d540db
Parents 9850991e6f0a
Children 9b88105145ca
Add an --allow-deprecated command line argument
--- a/config/loader.go Sat Jan 06 23:31:44 2018 -0600
+++ b/config/loader.go Sat Jan 06 23:32:30 2018 -0600
@@ -28,8 +28,8 @@
)
type Loader interface {
- Load(path, base string, data []byte) (*Config, error)
- LoadOverride(path, base string, data []byte, config *Config)
+ Load(path, base string, data []byte, allowDeprecated bool) (*Config, error)
+ LoadOverride(path, base string, data []byte, config *Config, allowDeprecated bool)
Filenames() []string
OverrideSuffix() string
DefaultPlan() string
@@ -43,7 +43,7 @@
return base + loader.OverrideSuffix() + ext
}
-func loadOverride(path, base string, loader Loader, cfg *Config) {
+func loadOverride(path, base string, loader Loader, cfg *Config, allowDeprecated bool) {
overrideFilename := determineFilename(base, loader)
absName := filepath.Join(path, overrideFilename)
@@ -58,10 +58,10 @@
return
}
- loader.LoadOverride(path, base, data, cfg)
+ loader.LoadOverride(path, base, data, cfg, allowDeprecated)
}
-func LoadFile(file string, loader Loader) (*Config, error) {
+func LoadFile(file string, loader Loader, allowDeprecated bool) (*Config, error) {
// split the filename into our parts
path, base := filepath.Split(file)
@@ -70,12 +70,12 @@
return nil, fmt.Errorf("failed to read config file '%s'", file)
}
- cfg, err := loader.Load(path, base, data)
+ cfg, err := loader.Load(path, base, data, allowDeprecated)
if err != nil {
return cfg, err
}
- loadOverride(path, base, loader, cfg)
+ loadOverride(path, base, loader, cfg, allowDeprecated)
return cfg, nil
}
--- a/config/override_test.go Sat Jan 06 23:31:44 2018 -0600
+++ b/config/override_test.go Sat Jan 06 23:32:30 2018 -0600
@@ -26,11 +26,11 @@
type testLoader struct{}
-func (l *testLoader) Load(path, base string, data []byte) (*Config, error) {
+func (l *testLoader) Load(path, base string, data []byte, allowDeprecated bool) (*Config, error) {
return nil, nil
}
-func (l *testLoader) LoadOverride(path, base string, data []byte, cfg *Config) {
+func (l *testLoader) LoadOverride(path, base string, data []byte, cfg *Config, allowDeprecated bool) {
}
func (l *testLoader) OverrideSuffix() string {
--- a/loaders/bitbucket/loader.go Sat Jan 06 23:31:44 2018 -0600
+++ b/loaders/bitbucket/loader.go Sat Jan 06 23:32:30 2018 -0600
@@ -172,7 +172,7 @@
return nil
}
-func (l *Loader) Load(base, path string, data []byte) (*config.Config, error) {
+func (l *Loader) Load(base, path string, data []byte, allowDeprecated bool) (*config.Config, error) {
var pipeline bitbucketPipelines
err := yaml.Unmarshal(data, &pipeline)
if err != nil {
@@ -236,7 +236,7 @@
return cfg, nil
}
-func (l *Loader) LoadOverride(base, path string, data []byte, cfg *config.Config) {
+func (l *Loader) LoadOverride(base, path string, data []byte, cfg *config.Config, allowDeprecated bool) {
return
}
--- a/loaders/bitbucket/loader_test.go Sat Jan 06 23:31:44 2018 -0600
+++ b/loaders/bitbucket/loader_test.go Sat Jan 06 23:32:30 2018 -0600
@@ -43,7 +43,7 @@
- flake8
- PYTHONPATH=$(pwd) py.test --color=auto --cov=pipelines --cov-report=term-missing tests`)
- cfg, err := l.Load("", "", data)
+ cfg, err := l.Load("", "", data, true)
Expect(err).To(BeNil())
@@ -101,7 +101,7 @@
- flake8
- PYTHONPATH=$(pwd) py.test --color=auto --cov=pipelines --cov-report=term-missing tests`)
- cfg, err := l.Load("", "", data)
+ cfg, err := l.Load("", "", data, true)
Expect(err).To(BeNil())
@@ -162,7 +162,7 @@
- flake8
- PYTHONPATH=$(pwd) py.test --color=auto --cov=pipelines --cov-report=term-missing tests`)
- cfg, err := l.Load("", "", data)
+ cfg, err := l.Load("", "", data, true)
Expect(err).To(BeNil())
@@ -228,7 +228,7 @@
- flake8
- PYTHONPATH=$(pwd) py.test --color=auto --cov=pipelines --cov-report=term-missing tests`)
- cfg, err := l.Load("", "", data)
+ cfg, err := l.Load("", "", data, true)
Expect(err).To(BeNil())
@@ -288,7 +288,7 @@
- flake8
- PYTHONPATH=$(pwd) py.test --color=auto --cov=pipelines --cov-report=term-missing tests`)
- cfg, err := l.Load("", "", data)
+ cfg, err := l.Load("", "", data, true)
Expect(err).To(BeNil())
@@ -356,7 +356,7 @@
docker: true
`)
- cfg, err := l.Load("", "", data)
+ cfg, err := l.Load("", "", data, true)
Expect(err).To(BeNil())
@@ -436,7 +436,7 @@
docker: true
`)
- cfg, err := l.Load("", "", data)
+ cfg, err := l.Load("", "", data, true)
Expect(err).To(BeNil())
--- a/loaders/convey/convey.go Sat Jan 06 23:31:44 2018 -0600
+++ b/loaders/convey/convey.go Sat Jan 06 23:32:30 2018 -0600
@@ -58,7 +58,7 @@
fileLoader func(string, *Loader) (*cConfig.Config, error)
}
-func (c *Loader) Load(path, base string, data []byte) (*cConfig.Config, error) {
+func (c *Loader) Load(path, base string, data []byte, allowDeprecated bool) (*cConfig.Config, error) {
// load the raw config
cfg := config{}
err := yaml.Unmarshal(data, &cfg)
@@ -78,7 +78,7 @@
}
c.depth++
- baseConfig, err = c.loadFile(cfg.Extends)
+ baseConfig, err = c.loadFile(cfg.Extends, allowDeprecated)
c.depth--
// We can safely ignore no plans and no tasks errors here
@@ -261,15 +261,15 @@
return nil
}
-func (c *Loader) loadFile(path string) (*cConfig.Config, error) {
+func (c *Loader) loadFile(path string, allowDeprecated bool) (*cConfig.Config, error) {
if c.fileLoader == nil {
- return cConfig.LoadFile(path, c)
+ return cConfig.LoadFile(path, c, allowDeprecated)
}
return c.fileLoader(path, c)
}
-func (c *Loader) LoadOverride(path, base string, data []byte, config *cConfig.Config) {
+func (c *Loader) LoadOverride(path, base string, data []byte, config *cConfig.Config, allowDeprecated bool) {
var overrideData override
err := yaml.Unmarshal(data, &overrideData)
--- a/loaders/convey/convey_test.go Sat Jan 06 23:31:44 2018 -0600
+++ b/loaders/convey/convey_test.go Sat Jan 06 23:32:30 2018 -0600
@@ -77,7 +77,7 @@
l := Loader{}
- _, err := l.Load(".", ".", []byte(data))
+ _, err := l.Load(".", ".", []byte(data), true)
Expect(err).To(MatchError(ErrNoTasks))
}
@@ -89,6 +89,6 @@
l := Loader{}
- _, err := l.Load(".", ".", []byte(data))
+ _, err := l.Load(".", ".", []byte(data), true)
Expect(err).To(MatchError(ErrNoPlans))
}
--- a/loaders/convey/default_plan_test.go Sat Jan 06 23:31:44 2018 -0600
+++ b/loaders/convey/default_plan_test.go Sat Jan 06 23:32:30 2018 -0600
@@ -54,7 +54,7 @@
`
l := Loader{}
- cfg, err := l.Load(".", ".", []byte(data))
+ cfg, err := l.Load(".", ".", []byte(data), true)
Expect(err).To(BeNil())
Expect(l.defaultPlan).To(Equal("overridden-plan"))
@@ -73,7 +73,7 @@
`
l := Loader{}
- cfg, err := l.Load(".", ".", []byte(data))
+ cfg, err := l.Load(".", ".", []byte(data), true)
Expect(err).To(BeNil())
Expect(l.defaultPlan).To(Equal(""))
@@ -83,6 +83,6 @@
default-plan: abcxyz
`
- l.LoadOverride(".", ".", []byte(overrideData), cfg)
+ l.LoadOverride(".", ".", []byte(overrideData), cfg, true)
Expect(l.DefaultPlan()).To(Equal("abcxyz"))
}
--- a/loaders/convey/environment_test.go Sat Jan 06 23:31:44 2018 -0600
+++ b/loaders/convey/environment_test.go Sat Jan 06 23:32:30 2018 -0600
@@ -45,7 +45,7 @@
` + baseData
loader := Loader{}
- cfg, err := loader.Load(".", ".", []byte(data))
+ cfg, err := loader.Load(".", ".", []byte(data), true)
Expect(err).To(BeNil())
Expect(cfg.Environment).To(ConsistOf([]string{"foo=bar", "baz"}))
@@ -56,7 +56,7 @@
` + baseData
loader := Loader{}
- cfg, err := loader.Load(".", ".", []byte(data))
+ cfg, err := loader.Load(".", ".", []byte(data), true)
Expect(err).To(BeNil())
Expect(cfg.Environment).To(Equal([]string{"foo=bar"}))
@@ -64,7 +64,7 @@
func (e *environmentSuite) TestEnvironmentUnmarshalGlobalOverrideSlice(t sweet.T) {
loader := Loader{}
- cfg, err := loader.Load(".", ".", []byte(baseData))
+ cfg, err := loader.Load(".", ".", []byte(baseData), true)
Expect(err).To(BeNil())
Expect(cfg.Environment).To(BeEmpty())
@@ -74,14 +74,14 @@
- foo=bar
- baz
`
- loader.LoadOverride(".", ".", []byte(overrideData), cfg)
+ loader.LoadOverride(".", ".", []byte(overrideData), cfg, true)
Expect(cfg.Environment).To(ConsistOf([]string{"foo=bar", "baz"}))
}
func (e *environmentSuite) TestEnvironmentUnmarshalGlobalOverrideString(t sweet.T) {
loader := Loader{}
- cfg, err := loader.Load(".", ".", []byte(baseData))
+ cfg, err := loader.Load(".", ".", []byte(baseData), true)
Expect(err).To(BeNil())
Expect(cfg.Environment).To(BeEmpty())
@@ -89,7 +89,7 @@
overrideData := `
environment: foo=bar
`
- loader.LoadOverride(".", ".", []byte(overrideData), cfg)
+ loader.LoadOverride(".", ".", []byte(overrideData), cfg, true)
Expect(cfg.Environment).To(Equal([]string{"foo=bar"}))
}
--- a/loaders/convey/extend_test.go Sat Jan 06 23:31:44 2018 -0600
+++ b/loaders/convey/extend_test.go Sat Jan 06 23:32:30 2018 -0600
@@ -49,7 +49,7 @@
`
loader := &Loader{}
- cfg, err := loader.Load(".", ".", []byte(data))
+ cfg, err := loader.Load(".", ".", []byte(data), true)
Expect(err).To(BeNil())
Expect(cfg.Tasks).To(HaveLen(2))
@@ -84,7 +84,7 @@
`
loader := &Loader{}
- cfg, err := loader.Load(".", ".", []byte(data))
+ cfg, err := loader.Load(".", ".", []byte(data), true)
Expect(err).To(BeNil())
Expect(cfg.Tasks).To(HaveLen(3))
@@ -115,7 +115,7 @@
`
loader := &Loader{}
- _, err := loader.Load(".", ".", []byte(data))
+ _, err := loader.Load(".", ".", []byte(data), true)
Expect(err).To(MatchError("The following tasks are part of a dependency cycle: a, b"))
}
@@ -132,7 +132,7 @@
`
loader := &Loader{}
- _, err := loader.Load(".", ".", []byte(data))
+ _, err := loader.Load(".", ".", []byte(data), true)
Expect(err).To(MatchError("b: Extending undeclared task 'a'"))
}
@@ -165,11 +165,11 @@
loader := &Loader{
fileLoader: func(name string, c *Loader) (*cConfig.Config, error) {
- return c.Load(".", name, []byte(baseData))
+ return c.Load(".", name, []byte(baseData), true)
},
}
- cfg, err := loader.Load(".", ".", []byte(extendedData))
+ cfg, err := loader.Load(".", ".", []byte(extendedData), true)
Expect(err).To(BeNil())
Expect(cfg.Tasks).To(HaveLen(2))
@@ -250,11 +250,11 @@
"base2.yaml": data2,
}
- return c.Load(".", name, []byte(m[name]))
+ return c.Load(".", name, []byte(m[name]), true)
},
}
- cfg, err := loader.Load(".", ".", []byte(data3))
+ cfg, err := loader.Load(".", ".", []byte(data3), true)
Expect(err).To(BeNil())
Expect(cfg.Plans).To(HaveLen(2))
Expect(cfg.Plans).To(HaveKey("plan1"))
@@ -301,11 +301,11 @@
loader := &Loader{
fileLoader: func(name string, c *Loader) (*cConfig.Config, error) {
- return c.Load(".", name, []byte(data1))
+ return c.Load(".", name, []byte(data1), true)
},
}
- _, err := loader.Load(".", ".", []byte(data2))
+ _, err := loader.Load(".", ".", []byte(data2), true)
Expect(err).To(MatchError("cannot merge with unknown plan 'plan2'"))
}
@@ -338,11 +338,11 @@
loader := &Loader{
fileLoader: func(name string, c *Loader) (*cConfig.Config, error) {
- return c.Load(".", name, []byte(data1))
+ return c.Load(".", name, []byte(data1), true)
},
}
- _, err := loader.Load(".", ".", []byte(data2))
+ _, err := loader.Load(".", ".", []byte(data2), true)
Expect(err).To(MatchError("cannot overwrite stage 'missing' in plan 'plan1' (no such stage in parent)"))
}
@@ -373,11 +373,11 @@
loader := &Loader{
fileLoader: func(name string, c *Loader) (*cConfig.Config, error) {
- return c.Load(".", name, []byte(data1))
+ return c.Load(".", name, []byte(data1), true)
},
}
- cfg, err := loader.Load(".", ".", []byte(data2))
+ cfg, err := loader.Load(".", ".", []byte(data2), true)
Expect(err).To(BeNil())
Expect(cfg.Plans["plan1"].Stages[0].Tasks).To(ConsistOf("foo"))
Expect(cfg.Plans["plan1"].Environment).To(ConsistOf("FOO=BAR", "BAR=BONK"))
--- a/loaders/convey/extends_test.go Sat Jan 06 23:31:44 2018 -0600
+++ b/loaders/convey/extends_test.go Sat Jan 06 23:32:30 2018 -0600
@@ -65,11 +65,11 @@
loader := &Loader{
fileLoader: func(name string, c *Loader) (*cConfig.Config, error) {
- return c.Load(".", name, []byte(baseData))
+ return c.Load(".", name, []byte(baseData), true)
},
}
- cfg, err := loader.Load(".", ".", []byte(extendedData))
+ cfg, err := loader.Load(".", ".", []byte(extendedData), true)
Expect(err).To(BeNil())
Expect(cfg.Environment).To(ConsistOf([]string{"x=1", "y=2", "z=3", "w=4"}))
@@ -117,11 +117,11 @@
loader := &Loader{
fileLoader: func(name string, c *Loader) (*cConfig.Config, error) {
- return c.Load(".", name, []byte(baseData))
+ return c.Load(".", name, []byte(baseData), true)
},
}
- cfg, err := loader.Load(".", ".", []byte(extendedData))
+ cfg, err := loader.Load(".", ".", []byte(extendedData), true)
Expect(err).To(BeNil())
Expect(cfg.Environment).To(ConsistOf([]string{"x=1", "y=2", "z=4"}))
@@ -164,11 +164,11 @@
loader := &Loader{
fileLoader: func(name string, c *Loader) (*cConfig.Config, error) {
- return c.Load(".", name, []byte(baseData))
+ return c.Load(".", name, []byte(baseData), true)
},
}
- _, err := loader.Load(".", ".", []byte(extendedData))
+ _, err := loader.Load(".", ".", []byte(extendedData), true)
Expect(err).To(BeNil())
Expect(loader.defaultPlan).To(Equal("plan2"))
}
@@ -192,11 +192,11 @@
loader := &Loader{
fileLoader: func(name string, c *Loader) (*cConfig.Config, error) {
- return c.Load(".", name, []byte(baseData))
+ return c.Load(".", name, []byte(baseData), true)
},
}
- cfg, err := loader.Load(".", ".", []byte(extendedData))
+ cfg, err := loader.Load(".", ".", []byte(extendedData), true)
Expect(err).To(BeNil())
Expect(cfg.Tasks).To(HaveLen(1))
Expect(cfg.Tasks).To(HaveKey("foo"))
@@ -210,11 +210,11 @@
loader := &Loader{
fileLoader: func(name string, c *Loader) (*cConfig.Config, error) {
- return c.Load(".", name, []byte(baseData))
+ return c.Load(".", name, []byte(baseData), true)
},
}
- _, err := loader.Load(".", ".", []byte(extendedData))
+ _, err := loader.Load(".", ".", []byte(extendedData), true)
Expect(err).To(Equal(ErrNoTasks))
}
@@ -231,11 +231,11 @@
loader := &Loader{
fileLoader: func(name string, c *Loader) (*cConfig.Config, error) {
- return c.Load(".", name, []byte(baseData))
+ return c.Load(".", name, []byte(baseData), true)
},
}
- cfg, err := loader.Load(".", ".", []byte(extendedData))
+ cfg, err := loader.Load(".", ".", []byte(extendedData), true)
Expect(err).To(Equal(ErrNoPlans))
Expect(cfg.Tasks).To(HaveLen(1))
Expect(cfg.Tasks).To(HaveKey("foo"))
@@ -248,11 +248,11 @@
loader := &Loader{
fileLoader: func(name string, c *Loader) (*cConfig.Config, error) {
- return c.Load(".", name, []byte(sameData))
+ return c.Load(".", name, []byte(sameData), true)
},
}
- _, err := loader.Load(".", ".", []byte(sameData))
+ _, err := loader.Load(".", ".", []byte(sameData), true)
Expect(err).To(Equal(ErrMaxExtendsDepth))
}
@@ -270,6 +270,6 @@
},
}
- loader.Load(".", ".", []byte(data))
+ loader.Load(".", ".", []byte(data), true)
Expect(calledWith).To(Equal("../base.yaml"))
}
--- a/main.go Sat Jan 06 23:31:44 2018 -0600
+++ b/main.go Sat Jan 06 23:32:30 2018 -0600
@@ -64,6 +64,7 @@
sshIdentities = app.Flag("ssh-identity", "Enable ssh-agent for the given identities").Strings()
planTimeout = app.Flag("timeout", "The maximum amount of time a plan can run. 0 to disable. Units must be specified.").Default("15m").Duration()
verbose = app.Flag("verbose", "Be more verbose").Short('v').Default("False").Bool()
+ allowDeprecated = app.Flag("allow-deprecated", "Allow the user of deprecated features").Default("False").Bool()
planNames = app.Arg("plan", "The plan or list of plans to run in specified order").Strings()
)
@@ -105,7 +106,7 @@
return 1
}
- cfg, err := config.LoadFile(*configFile, loader)
+ cfg, err := config.LoadFile(*configFile, loader, *allowDeprecated)
if err != nil {
fmt.Printf("%s\n", err)
return 1
@@ -147,6 +148,7 @@
st.CfgPath = cfgPath
st.CleanupList = cleanupList
st.KeepWorkspace = *keep
+ st.AllowDeprecated = *allowDeprecated
st.ForceSequential = *forceSequential
st.EnableSSHAgent = enableSSHAgent
st.PlanTimeout = *planTimeout
--- a/state/state.go Sat Jan 06 23:31:44 2018 -0600
+++ b/state/state.go Sat Jan 06 23:32:30 2018 -0600
@@ -39,6 +39,7 @@
Workspace workspace.Workspace
KeepWorkspace bool
+ AllowDeprecated bool
ForceSequential bool
EnableSSHAgent bool
PlanTimeout time.Duration