Add field "kind" to task for use in connect tasks

This commit is contained in:
Preetha Appan 2019-08-07 18:43:36 -05:00
parent bf6f97edfb
commit a393ea79e8
No known key found for this signature in database
GPG key ID: 9F7C19990A50EAFC
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 {