grim/convey

Parents 83065e023cbc
Children 029768cfe81d
Remove the implicit task types and make it so the type attribute is the only way to define a task's type now
--- a/ChangeLog Sun Oct 27 03:41:33 2019 -0500
+++ b/ChangeLog Sun Oct 27 04:19:03 2019 -0500
@@ -37,6 +37,8 @@
replicated by plan/stage environment variables.
* Removed the deprecated always attribute on stages.
* Added the convey/fail task which is good for testing.
+ * Removed deprecated tasks formats. All tasks types must be defined via the
+ type attribute now.
0.13.1: 20180114
* Write warning, error, and fatal log messages to stderr. Fixed #156
--- a/loaders/convey/tasks.go Sun Oct 27 03:41:33 2019 -0500
+++ b/loaders/convey/tasks.go Sun Oct 27 04:19:03 2019 -0500
@@ -18,7 +18,6 @@
import (
"fmt"
- "strings"
"github.com/go-yaml/yaml"
log "github.com/sirupsen/logrus"
@@ -34,67 +33,17 @@
}
)
-func loadLegacyTask(rawEngine, rawType string, logger *log.Entry) (tasks.Task, error) {
- legacyEngine := "docker"
-
- // there are only two intrinsic tasks, so check them first
- if rawType == "clean" || rawType == "extend" {
- legacyEngine = "convey"
- }
-
- // figure out the engine
- if rawEngine != "" {
- msg := "the engine attribute is deprecated and will be removed in a future version. Please update to the new type format as this format will be removed in a future version."
- logger.Warn(msg)
-
- if rawEngine == "intrinsic" {
- msg := "the intrinsic engine is deprecated, using convey instead"
- logger.Warn(msg)
-
- rawEngine = "convey"
- }
-
- legacyEngine = rawEngine
- }
-
- // figure out the type
- legacyType := "run"
- if rawType != "" {
- legacyType = rawType
- }
-
- typeName := fmt.Sprintf("%s/%s", legacyEngine, legacyType)
- msgFmt := "converted deprecated task format {engine: '%s', type: '%s'} to type %s. Please update to the new type format as this format will be removed in a future version."
- logger.Warnf(msgFmt, rawEngine, rawType, typeName)
-
- task, ok := cConfig.TasksMap[typeName]
- if !ok {
- return nil, fmt.Errorf(
- "failed to find task with engine '%s' and type '%s'",
- rawEngine,
- rawType,
- )
- }
-
- return task, nil
-}
-
func loadTask(name string, yamlTask yaml.MapSlice, logger *log.Entry, disableDeprecated bool) (tasks.Task, error) {
- // figure out the engine and type for the task
- var (
- rawEngine string
- rawType string
- )
-
// task is a yaml.MapSlice since we can't unmarshal it into the proper data
// structure right away, so we have to walk it and grab the attributes
// we're interested in.
+ rawType := ""
+
for _, item := range yamlTask {
- switch item.Key.(string) {
- case "engine":
- rawEngine = item.Value.(string)
- case "type":
- rawType = item.Value.(string)
+ if key, ok := item.Key.(string); ok && key == "type" {
+ if value, ok := item.Value.(string); ok {
+ rawType = value
+ }
}
}
@@ -116,18 +65,7 @@
}
task = newTask
} else {
- // TODO remove when the old format for task types is removed.
- // if deprecated tasks are disabled, just bomb out
- if disableDeprecated || strings.ContainsRune(rawType, '/') {
- return nil, fmt.Errorf("task '%s' not found", rawType)
- }
-
- rawTask, err := loadLegacyTask(rawEngine, rawType, logger)
- if err != nil {
- return nil, err
- }
-
- task = rawTask
+ return nil, fmt.Errorf("task '%s' not found", rawType)
}
}
--- a/tests/tasks-types.yml Sun Oct 27 03:41:33 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-# This file is just to test all the different ways that a task can be defined
-
-tasks:
- # implicit
- # engine: implicit: docker
- # type: implicit: run
- implicit:
- image: alpine:edge
- script:
- - echo "implicit"
-
- # implicit-engine
- # engine: implict: docker
- # type: run
- implicit-engine:
- type: run
- image: alpine:edge
- script:
- - echo "implicit-engine"
-
- # implicit-type
- # engine: docker
- # type: implicit: run
- implicit-type:
- engine: docker
- image: alpine:edge
- script:
- - echo "implicit-type"
-
- # explicit
- explicit-old:
- engine: docker
- type: run
- image: alpine:edge
- script:
- - echo "explicit-old"
-
- # explicit-new
- # engine: omitted
- # type: docker/run
- explicit-new:
- type: docker/run
- image: alpine:edge
- script:
- - echo "explicit-new"
-
- explicit-new-unknown:
- type: imaginary/type
-
-plans:
- default:
- stages:
- - tasks:
- - implicit
- - implicit-engine
- - implicit-type
- - explicit-old
- - explicit-new
- - tasks:
- - explicit-new-unknown
-