Merge pull request #6090 from hashicorp/f-task-kind

Add field "kind" to task for use in connect tasks
This commit is contained in:
Preetha
2019-08-08 14:40:12 -05:00
committed by GitHub
6 changed files with 9 additions and 0 deletions

View File

@@ -583,6 +583,7 @@ type Task struct {
Leader bool
ShutdownDelay time.Duration `mapstructure:"shutdown_delay"`
KillSignal string `mapstructure:"kill_signal"`
Kind string
}
func (t *Task) Canonicalize(tg *TaskGroup, job *Job) {

View File

@@ -784,6 +784,7 @@ func ApiTaskToStructsTask(apiTask *api.Task, structsTask *structs.Task) {
structsTask.KillTimeout = *apiTask.KillTimeout
structsTask.ShutdownDelay = apiTask.ShutdownDelay
structsTask.KillSignal = apiTask.KillSignal
structsTask.Kind = apiTask.Kind
structsTask.Constraints = ApiConstraintsToStructs(apiTask.Constraints)
structsTask.Affinities = ApiAffinitiesToStructs(apiTask.Affinities)

View File

@@ -892,6 +892,7 @@ func parseTasks(jobName string, taskGroupName string, result *[]*api.Task, list
"user",
"vault",
"kill_signal",
"kind",
}
if err := helper.CheckHCLKeys(listVal, valid); err != nil {
return multierror.Prefix(err, fmt.Sprintf("'%s' ->", n))

View File

@@ -178,6 +178,7 @@ func TestParse(t *testing.T) {
Name: "binstore",
Driver: "docker",
User: "bob",
Kind: "connect-proxy:test",
Config: map[string]interface{}{
"image": "hashicorp/binstore",
"labels": []map[string]interface{}{

View File

@@ -126,6 +126,7 @@ job "binstore-storagelocker" {
driver = "docker"
user = "bob"
leader = true
kind = "connect-proxy:test"
affinity {
attribute = "${meta.foo}"

View File

@@ -5142,6 +5142,10 @@ type Task struct {
// KillSignal is the kill signal to use for the task. This is an optional
// specification and defaults to SIGINT
KillSignal string
// Used internally to manage tasks according to their Kind. Initial use case
// is for Consul Connect
Kind string
}
func (t *Task) Copy() *Task {