grim/convey

9a93ecb33e19
Parents f7d2f34c886b
Children 7000be82ce02
Add a required_version attribute to convey.yml. Fixed #168
--- a/ChangeLog Mon Feb 12 22:17:07 2018 -0600
+++ b/ChangeLog Mon Feb 12 22:41:56 2018 -0600
@@ -1,4 +1,4 @@
-0.13.2dev:
+0.13.2-dev:
* Changed tasks names for bitbucket pipeline tasks.
* Abstracted the bitbucket pipeline script parsing to a library function.
* Fixed an issue where the files for clean tasks were not having their
@@ -7,6 +7,8 @@
* Set the workdir parameter for docker/run tasks to ${CONVEY_WORKSPACE} if
the image does not have a workdir set and the user has not specified on in
convey.yml. Fixed #167
+ * Add a top level convey.yml option for specifying the minimum required
+ version of convey to use for the convey.yml. Fixed #168
0.13.1: 20180114
* Write warning, error, and fatal log messages to stderr. Fixed #156
--- a/REFERENCE.md Mon Feb 12 22:17:07 2018 -0600
+++ b/REFERENCE.md Mon Feb 12 22:41:56 2018 -0600
@@ -80,6 +80,12 @@
The complete reference for convey.yml can be found below.
+## required_version
+
+The `required_version` field let's you specify a minimum required version of
+convey to run your `convey.yml`. If a required_version is not specified,
+convey will always attempt to run the `convey.yml`.
+
## Options
The options section let's you fine tune a few things about your configuration.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/consts/consts.go Mon Feb 12 22:41:56 2018 -0600
@@ -0,0 +1,21 @@
+// Convey
+// Copyright 2016-2018 Gary Kramlich <grim@reaperworld.com>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package consts
+
+const (
+ Version = "0.13.2-dev"
+)
--- a/convey.yml Mon Feb 12 22:17:07 2018 -0600
+++ b/convey.yml Mon Feb 12 22:41:56 2018 -0600
@@ -1,5 +1,6 @@
+required_version: 0.13.2-dev
environment:
- - CONVEY_VERSION=0.13.2dev
+ - CONVEY_VERSION=0.13.2-dev
- GO_PACKAGE=bitbucket.org/rw_grim/convey
tasks:
# tasks for the default plan
--- a/loaders/convey/convey.go Mon Feb 12 22:17:07 2018 -0600
+++ b/loaders/convey/convey.go Mon Feb 12 22:41:56 2018 -0600
@@ -24,10 +24,12 @@
"strings"
"github.com/aphistic/gomol"
+ "github.com/blang/semver"
"github.com/go-yaml/yaml"
toposort "github.com/philopon/go-toposort"
cConfig "bitbucket.org/rw_grim/convey/config"
+ "bitbucket.org/rw_grim/convey/consts"
"bitbucket.org/rw_grim/convey/environment"
"bitbucket.org/rw_grim/convey/logging"
"bitbucket.org/rw_grim/convey/plans"
@@ -42,12 +44,13 @@
}
type config struct {
- Extends string `yaml:"extends"`
- Tasks map[string]yaml.MapSlice `yaml:"tasks"`
- Plans map[string]plans.Plan `yaml:"plans"`
- MetaPlans map[string]plans.MetaPlan `yaml:"meta-plans"`
- Environment cYaml.StringOrSlice `yaml:"environment"`
- Options options `yaml:"options"`
+ RequiredVersion string `yaml:"required_version"`
+ Extends string `yaml:"extends"`
+ Tasks map[string]yaml.MapSlice `yaml:"tasks"`
+ Plans map[string]plans.Plan `yaml:"plans"`
+ MetaPlans map[string]plans.MetaPlan `yaml:"meta-plans"`
+ Environment cYaml.StringOrSlice `yaml:"environment"`
+ Options options `yaml:"options"`
}
type override struct {
@@ -146,6 +149,28 @@
return nil, err
}
+ if cfg.RequiredVersion != "" {
+ reqVer, err := semver.Make(cfg.RequiredVersion)
+ if err != nil {
+ return nil, err
+ }
+
+ curVer, err := semver.Make(consts.Version)
+ if err != nil {
+ return nil, err
+ }
+
+ if !curVer.GTE(reqVer) {
+ err := fmt.Errorf(
+ "convey version %s required, but %s is in use.",
+ cfg.RequiredVersion,
+ consts.Version,
+ )
+
+ return nil, err
+ }
+ }
+
// get our base config
baseConfig, err := l.loadBase(cfg, path, options, disableDeprecated)
if err != nil {
--- a/main.go Mon Feb 12 22:17:07 2018 -0600
+++ b/main.go Mon Feb 12 22:41:56 2018 -0600
@@ -27,6 +27,7 @@
"github.com/aphistic/gomol"
"bitbucket.org/rw_grim/convey/config"
+ "bitbucket.org/rw_grim/convey/consts"
"bitbucket.org/rw_grim/convey/environment"
"bitbucket.org/rw_grim/convey/loaders/bitbucket"
"bitbucket.org/rw_grim/convey/loaders/codebuild"
@@ -37,12 +38,8 @@
"bitbucket.org/rw_grim/convey/state"
)
-const (
- version = "0.13.2dev"
-)
-
var (
- app = kingpin.New("convey", "Convey is a container pipeline runner.").Version(version)
+ app = kingpin.New("convey", "Convey is a container pipeline runner.").Version(consts.Version)
color = app.Flag("color", "Enable colorized output").Default("true").Bool()
configLoader = app.Flag("config-loader", "Select the configuration loader").Short('l').Default("convey").Enum("convey", "bitbucket", "codebuild")