func (exec *sidecarExecutor) taskKilled(taskInfo *mesos.TaskInfo) {
	taskID := taskInfo.GetTaskID()
	exec.sendStatus(TaskKilled, &taskID)
	time.Sleep(exec.statusSleepTime)
	exec.StopDriver()
}
taskKilled tells Mesos and the framework that the task was killed. Shutdown driver.
package main
import (
	"encoding/json"
	"errors"
	"io/ioutil"
	"net/http"
	"os"
	"regexp"
	"strings"
	"sync"
	"syscall"
	"time"
	"fmt"
	"github.com/Nitro/sidecar-executor/container"
	"github.com/Nitro/sidecar-executor/vault"
	"github.com/Nitro/sidecar/service"
	docker "github.com/fsouza/go-dockerclient"
	"github.com/jinzhu/copier"
	mesos "github.com/mesos/mesos-go/api/v1/lib"
	"github.com/relistan/go-director"
	log "github.com/sirupsen/logrus"
)
const (
	StillRunning = -1
)
type ExecDriver interface {
	NewStatus(id mesos.TaskID) mesos.TaskStatus
	SendStatusUpdate(status mesos.TaskStatus) error
	Stop()
	Run() error
}
type sidecarExecutor struct {
	client          container.DockerClient
	fetcher         SidecarFetcher
	watchLooper     director.Looper
	watcherWg       sync.WaitGroup
	logsQuitChan    chan struct{}
	dockerAuth      *docker.AuthConfiguration
	failCount       int
	vault           vault.Vault
	config          Config
	statusSleepTime time.Duration
	containerConfig *docker.CreateContainerOptions
	containerID     string
	driver          ExecDriver
	awsCredsLease   *vault.VaultAWSCredsLease
}
func newSidecarExecutor(client container.DockerClient, auth *docker.AuthConfiguration,
	config Config) *sidecarExecutor {
	var vaultConfig vault.EnvVaultConfig
	copier.Copy(&vaultConfig, &config)
	return &sidecarExecutor{
		client:          client,
		fetcher:         &http.Client{Timeout: config.HttpTimeout},
		dockerAuth:      auth,
		vault:           vault.NewDefaultVault(&vaultConfig),
		config:          config,
		statusSleepTime: DefaultStatusSleepTime,
	}
}
func (exec *sidecarExecutor) logTaskEnv(taskInfo *mesos.TaskInfo, labels map[string]string, addEnvVars []string) {
	env := container.EnvForTask(taskInfo, labels, addEnvVars)
	if len(env) < 1 {
		log.Info("No Docker environment provided")
		return
	}
	log.Infof("Docker Environment --------------------")
	for _, setting := range env {
		log.Infof(" * %s", redactSetting(setting))
	}
	log.Infof("---------------------------------------")
}
var replExpr = regexp.MustCompile("(.*)=(...).{10}(.+).{5}")
func redactSetting(setting string) string {
	if strings.Contains(setting, "SECRET") {
		return replExpr.ReplaceAllString(setting, "$1=$2[REDACTED]$3...")
	}
	return setting
}
func (exec *sidecarExecutor) sendStatus(status int64, taskID *mesos.TaskID) {
	update := exec.driver.NewStatus(*taskID)
	switch status {
	case TaskRunning:
		update.State = mesos.TASK_RUNNING.Enum()
	case TaskFinished:
		update.State = mesos.TASK_FINISHED.Enum()
	case TaskFailed:
		update.State = mesos.TASK_FAILED.Enum()
	case TaskKilled:
		update.State = mesos.TASK_KILLED.Enum()
	}
	if err := exec.driver.SendStatusUpdate(update); err != nil {
		log.Errorf("Error sending status update %s", err.Error())
		panic(err.Error())
	}
}
func (exec *sidecarExecutor) finishTask(taskInfo *mesos.TaskInfo) {
	taskID := taskInfo.GetTaskID()
	exec.sendStatus(TaskFinished, &taskID)
	time.Sleep(exec.statusSleepTime)
	exec.StopDriver()
}
func (exec *sidecarExecutor) failTask(taskInfo *mesos.TaskInfo) {
	taskID := taskInfo.GetTaskID()
	exec.sendStatus(TaskFailed, &taskID)
	time.Sleep(exec.statusSleepTime)
	exec.StopDriver()
}