client: Rename drivers/shared/env => client/taskenv

This commit is contained in:
Danielle Tomlinson 2018-11-30 12:18:39 +01:00
parent f00e127d46
commit 2db5ae38d8
27 changed files with 72 additions and 72 deletions

View File

@ -6,7 +6,7 @@ import (
"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/client/allocrunner/taskrunner/interfaces"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/plugins/drivers"
)
@ -58,7 +58,7 @@ type TaskPrestartRequest struct {
TaskDir *allocdir.TaskDir
// TaskEnv is the task's environment
TaskEnv *env.TaskEnv
TaskEnv *taskenv.TaskEnv
}
type TaskPrestartResponse struct {
@ -99,7 +99,7 @@ type TaskPoststartRequest struct {
DriverNetwork *cstructs.DriverNetwork
// TaskEnv is the task's environment
TaskEnv *env.TaskEnv
TaskEnv *taskenv.TaskEnv
// Stats collector
DriverStats DriverStats
@ -141,7 +141,7 @@ type TaskUpdateRequest struct {
Alloc *structs.Allocation
// TaskEnv is the task's environment
TaskEnv *env.TaskEnv
TaskEnv *taskenv.TaskEnv
}
type TaskUpdateResponse struct{}

View File

@ -27,7 +27,7 @@ const (
)
// EnvReplacer is an interface which can interpolate environment variables and
// is usually satisfied by env.TaskEnv.
// is usually satisfied by taskenv.TaskEnv.
type EnvReplacer interface {
ReplaceEnv(string) string
}

View File

@ -11,12 +11,12 @@ import (
"strings"
"testing"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
)
// fakeReplacer is a noop version of env.TaskEnv.ReplaceEnv
// fakeReplacer is a noop version of taskenv.TaskEnv.ReplaceEnv
type fakeReplacer struct{}
func (fakeReplacer) ReplaceEnv(s string) string {
@ -101,7 +101,7 @@ func TestGetGetterUrl_Interpolation(t *testing.T) {
alloc := mock.Alloc()
task := alloc.Job.TaskGroups[0].Tasks[0]
task.Meta = map[string]string{"artifact": url}
taskEnv := env.NewBuilder(mock.Node(), alloc, task, "global").Build()
taskEnv := taskenv.NewBuilder(mock.Node(), alloc, task, "global").Build()
act, err := getGetterUrl(taskEnv, artifact)
if err != nil {

View File

@ -11,8 +11,8 @@ import (
tinterfaces "github.com/hashicorp/nomad/client/allocrunner/taskrunner/interfaces"
"github.com/hashicorp/nomad/client/consul"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/client/taskenv"
agentconsul "github.com/hashicorp/nomad/command/agent/consul"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/nomad/structs"
)
@ -41,7 +41,7 @@ type serviceHook struct {
canary bool
services []*structs.Service
networks structs.Networks
taskEnv *env.TaskEnv
taskEnv *taskenv.TaskEnv
// Since Update() may be called concurrently with any other hook all
// hook methods must be fully serialized
@ -184,7 +184,7 @@ func (h *serviceHook) getTaskServices() *agentconsul.TaskServices {
// interpolateServices returns an interpolated copy of services and checks with
// values from the task's environment.
func interpolateServices(taskEnv *env.TaskEnv, services []*structs.Service) []*structs.Service {
func interpolateServices(taskEnv *taskenv.TaskEnv, services []*structs.Service) []*structs.Service {
interpolated := make([]*structs.Service, len(services))
for i, origService := range services {

View File

@ -9,7 +9,7 @@ import (
"github.com/hashicorp/nomad/client/allocrunner/interfaces"
cconfig "github.com/hashicorp/nomad/client/config"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/nomad/structs"
)
@ -54,7 +54,7 @@ func (h *taskDirHook) Prestart(ctx context.Context, req *interfaces.TaskPrestart
}
// setEnvvars sets path and host env vars depending on the FS isolation used.
func setEnvvars(envBuilder *env.Builder, fsi cstructs.FSIsolation, taskDir *allocdir.TaskDir, conf *cconfig.Config) {
func setEnvvars(envBuilder *taskenv.Builder, fsi cstructs.FSIsolation, taskDir *allocdir.TaskDir, conf *cconfig.Config) {
// Set driver-specific environment variables
switch fsi {
case cstructs.FSIsolationNone:

View File

@ -23,8 +23,8 @@ import (
cinterfaces "github.com/hashicorp/nomad/client/interfaces"
cstate "github.com/hashicorp/nomad/client/state"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/client/vaultclient"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/plugins/base"
"github.com/hashicorp/nomad/plugins/drivers"
@ -133,7 +133,7 @@ type TaskRunner struct {
taskDir *allocdir.TaskDir
// envBuilder is used to build the task's environment
envBuilder *env.Builder
envBuilder *taskenv.Builder
// restartTracker is used to decide if the task should be restarted.
restartTracker *restarts.RestartTracker
@ -219,7 +219,7 @@ func NewTaskRunner(config *Config) (*TaskRunner, error) {
killCtx, killCancel := context.WithCancel(context.Background())
// Initialize the environment builder
envBuilder := env.NewBuilder(
envBuilder := taskenv.NewBuilder(
config.ClientConfig.Node,
config.Alloc,
config.Task,

View File

@ -19,7 +19,7 @@ import (
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/client/allocrunner/taskrunner/interfaces"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
)
@ -91,7 +91,7 @@ type TaskTemplateManagerConfig struct {
TaskDir string
// EnvBuilder is the environment variable builder for the task.
EnvBuilder *env.Builder
EnvBuilder *taskenv.Builder
// MaxTemplateEventRate is the maximum rate at which we should emit events.
MaxTemplateEventRate time.Duration

View File

@ -13,7 +13,7 @@ import (
ctestutil "github.com/hashicorp/consul/testutil"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
@ -102,7 +102,7 @@ type testHarness struct {
manager *TaskTemplateManager
mockHooks *MockTaskHooks
templates []*structs.Template
envBuilder *env.Builder
envBuilder *taskenv.Builder
node *structs.Node
config *config.Config
vaultToken string
@ -128,7 +128,7 @@ func newTestHarness(t *testing.T, templates []*structs.Template, consul, vault b
a := mock.Alloc()
task := a.Job.TaskGroups[0].Tasks[0]
task.Name = TestTaskName
harness.envBuilder = env.NewBuilder(harness.node, a, task, region)
harness.envBuilder = taskenv.NewBuilder(harness.node, a, task, region)
// Make a tempdir
d, err := ioutil.TempDir("", "ct_test")
@ -206,7 +206,7 @@ func TestTaskTemplateManager_InvalidConfig(t *testing.T) {
clientConfig := &config.Config{Region: "global"}
taskDir := "foo"
a := mock.Alloc()
envBuilder := env.NewBuilder(mock.Node(), a, a.Job.TaskGroups[0].Tasks[0], clientConfig.Region)
envBuilder := taskenv.NewBuilder(mock.Node(), a, a.Job.TaskGroups[0].Tasks[0], clientConfig.Region)
cases := []struct {
name string
@ -1277,7 +1277,7 @@ func TestTaskTemplateManager_Config_VaultGrace(t *testing.T) {
VaultGrace: 100 * time.Second,
},
},
EnvBuilder: env.NewBuilder(c.Node, alloc, alloc.Job.TaskGroups[0].Tasks[0], c.Region),
EnvBuilder: taskenv.NewBuilder(c.Node, alloc, alloc.Job.TaskGroups[0].Tasks[0], c.Region),
}
ctmplMapping, err := parseTemplateConfigs(config)

View File

@ -10,7 +10,7 @@ import (
ti "github.com/hashicorp/nomad/client/allocrunner/taskrunner/interfaces"
"github.com/hashicorp/nomad/client/allocrunner/taskrunner/template"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/nomad/structs"
)
@ -31,7 +31,7 @@ type templateHookConfig struct {
clientConfig *config.Config
// envBuilder is the environment variable builder for the task.
envBuilder *env.Builder
envBuilder *taskenv.Builder
}
type templateHook struct {

View File

@ -8,7 +8,7 @@ import (
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/client/allocrunner/interfaces"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/nomad/structs"
)
@ -39,7 +39,7 @@ func (h *validateHook) Prestart(ctx context.Context, req *interfaces.TaskPrestar
return nil
}
func validateTask(task *structs.Task, taskEnv *env.TaskEnv, conf *config.Config) error {
func validateTask(task *structs.Task, taskEnv *taskenv.TaskEnv, conf *config.Config) error {
var mErr multierror.Error
// Validate the user

View File

@ -4,7 +4,7 @@ import (
"testing"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/stretchr/testify/require"
)
@ -12,7 +12,7 @@ import (
func TestTaskRunner_Validate_UserEnforcement(t *testing.T) {
t.Parallel()
taskEnv := env.NewEmptyBuilder().Build()
taskEnv := taskenv.NewEmptyBuilder().Build()
conf := config.DefaultConfig()
// Try to run as root with exec.
@ -37,7 +37,7 @@ func TestTaskRunner_Validate_UserEnforcement(t *testing.T) {
func TestTaskRunner_Validate_ServiceName(t *testing.T) {
t.Parallel()
builder := env.NewEmptyBuilder()
builder := taskenv.NewEmptyBuilder()
conf := config.DefaultConfig()
// Create a task with a service for validation

View File

@ -19,7 +19,7 @@ import (
envparse "github.com/hashicorp/go-envparse"
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
)
@ -105,7 +105,7 @@ type TaskTemplateManagerConfig struct {
TaskDir string
// EnvBuilder is the environment variable builder for the task.
EnvBuilder *env.Builder
EnvBuilder *taskenv.Builder
// MaxTemplateEventRate is the maximum rate at which we should emit events.
MaxTemplateEventRate time.Duration

View File

@ -14,7 +14,7 @@ import (
ctestutil "github.com/hashicorp/consul/testutil"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
@ -108,7 +108,7 @@ type testHarness struct {
manager *TaskTemplateManager
mockHooks *MockTaskHooks
templates []*structs.Template
envBuilder *env.Builder
envBuilder *taskenv.Builder
node *structs.Node
config *config.Config
vaultToken string
@ -134,7 +134,7 @@ func newTestHarness(t *testing.T, templates []*structs.Template, consul, vault b
a := mock.Alloc()
task := a.Job.TaskGroups[0].Tasks[0]
task.Name = TestTaskName
harness.envBuilder = env.NewBuilder(harness.node, a, task, region)
harness.envBuilder = taskenv.NewBuilder(harness.node, a, task, region)
// Make a tempdir
d, err := ioutil.TempDir("", "ct_test")
@ -210,7 +210,7 @@ func TestTaskTemplateManager_InvalidConfig(t *testing.T) {
clientConfig := &config.Config{Region: "global"}
taskDir := "foo"
a := mock.Alloc()
envBuilder := env.NewBuilder(mock.Node(), a, a.Job.TaskGroups[0].Tasks[0], clientConfig.Region)
envBuilder := taskenv.NewBuilder(mock.Node(), a, a.Job.TaskGroups[0].Tasks[0], clientConfig.Region)
cases := []struct {
name string
@ -1254,7 +1254,7 @@ func TestTaskTemplateManager_Config_VaultGrace(t *testing.T) {
VaultGrace: 100 * time.Second,
},
},
EnvBuilder: env.NewBuilder(c.Node, alloc, alloc.Job.TaskGroups[0].Tasks[0], c.Region),
EnvBuilder: taskenv.NewBuilder(c.Node, alloc, alloc.Job.TaskGroups[0].Tasks[0], c.Region),
}
ctmplMapping, err := parseTemplateConfigs(config)

View File

@ -34,7 +34,7 @@ import (
dstructs "github.com/hashicorp/nomad/client/driver/structs"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
)
const (
@ -107,7 +107,7 @@ type TaskRunner struct {
taskDir *allocdir.TaskDir
// envBuilder is used to build the task's environment
envBuilder *env.Builder
envBuilder *taskenv.Builder
// driverNet is the network information returned by the driver
driverNet *cstructs.DriverNetwork
@ -248,7 +248,7 @@ func NewTaskRunner(logger *log.Logger, config *config.Config,
restartTracker := restarts.NewRestartTracker(tg.RestartPolicy, alloc.Job.Type)
// Initialize the environment builder
envBuilder := env.NewBuilder(config.Node, alloc, task, config.Region)
envBuilder := taskenv.NewBuilder(config.Node, alloc, task, config.Region)
tc := &TaskRunner{
config: config,
@ -1514,7 +1514,7 @@ func (r *TaskRunner) registerServices(d driver.Driver, h driver.DriverHandle, n
// interpolateServices interpolates tags in a service and checks with values from the
// task's environment.
func interpolateServices(taskEnv *env.TaskEnv, task *structs.Task) *structs.Task {
func interpolateServices(taskEnv *taskenv.TaskEnv, task *structs.Task) *structs.Task {
taskCopy := task.Copy()
for _, service := range taskCopy.Services {
for _, check := range service.Checks {

View File

@ -22,9 +22,9 @@ import (
"github.com/hashicorp/nomad/client/config"
consulApi "github.com/hashicorp/nomad/client/consul"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/client/vaultclient"
"github.com/hashicorp/nomad/command/agent/consul"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/helper/testlog"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
@ -1695,7 +1695,7 @@ func TestTaskRunner_interpolateServices(t *testing.T) {
},
}
env := &env.TaskEnv{
env := &taskenv.TaskEnv{
EnvMap: map[string]string{
"name": "name",
"portlabel": "portlabel",

View File

@ -1,4 +1,4 @@
package env
package taskenv
import (
"fmt"

View File

@ -1,4 +1,4 @@
package env
package taskenv
import (
"fmt"
@ -613,7 +613,7 @@ func TestEnvironment_UpdateTask(t *testing.T) {
a.Job.TaskGroups[0].Meta = map[string]string{"tgmeta": "tgmetaval"}
task := a.Job.TaskGroups[0].Tasks[0]
task.Name = "orig"
task.Env = map[string]string{"taskenv": "taskenvval"}
task.Env = map[string]string{"env": "envval"}
task.Meta = map[string]string{"taskmeta": "taskmetaval"}
builder := NewBuilder(mock.Node(), a, task, "global")
@ -624,8 +624,8 @@ func TestEnvironment_UpdateTask(t *testing.T) {
if origMap["NOMAD_META_taskmeta"] != "taskmetaval" {
t.Errorf("Expected NOMAD_META_taskmeta=taskmetaval but found %q", origMap["NOMAD_META_taskmeta"])
}
if origMap["taskenv"] != "taskenvval" {
t.Errorf("Expected taskenv=taskenvva but found %q", origMap["taskenv"])
if origMap["env"] != "envval" {
t.Errorf("Expected env=envva but found %q", origMap["env"])
}
if origMap["NOMAD_META_tgmeta"] != "tgmetaval" {
t.Errorf("Expected NOMAD_META_tgmeta=tgmetaval but found %q", origMap["NOMAD_META_tgmeta"])
@ -633,7 +633,7 @@ func TestEnvironment_UpdateTask(t *testing.T) {
a.Job.TaskGroups[0].Meta = map[string]string{"tgmeta2": "tgmetaval2"}
task.Name = "new"
task.Env = map[string]string{"taskenv2": "taskenvval2"}
task.Env = map[string]string{"env2": "envval2"}
task.Meta = map[string]string{"taskmeta2": "taskmetaval2"}
newMap := builder.UpdateTask(a, task).Build().Map()
@ -643,8 +643,8 @@ func TestEnvironment_UpdateTask(t *testing.T) {
if newMap["NOMAD_META_taskmeta2"] != "taskmetaval2" {
t.Errorf("Expected NOMAD_META_taskmeta=taskmetaval but found %q", newMap["NOMAD_META_taskmeta2"])
}
if newMap["taskenv2"] != "taskenvval2" {
t.Errorf("Expected taskenv=taskenvva but found %q", newMap["taskenv2"])
if newMap["env2"] != "envval2" {
t.Errorf("Expected env=envva but found %q", newMap["env2"])
}
if newMap["NOMAD_META_tgmeta2"] != "tgmetaval2" {
t.Errorf("Expected NOMAD_META_tgmeta=tgmetaval but found %q", newMap["NOMAD_META_tgmeta2"])

View File

@ -1,4 +1,4 @@
package env
package taskenv
import (
"errors"

View File

@ -1,4 +1,4 @@
package env
package taskenv
import (
"fmt"

View File

@ -17,8 +17,8 @@ import (
hclog "github.com/hashicorp/go-hclog"
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/drivers/docker/docklog"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/drivers/shared/eventer"
nstructs "github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/plugins/base"
@ -536,9 +536,9 @@ func (d *Driver) loadImage(task *drivers.TaskConfig, driverConfig *TaskConfig, c
func (d *Driver) containerBinds(task *drivers.TaskConfig, driverConfig *TaskConfig) ([]string, error) {
allocDirBind := fmt.Sprintf("%s:%s", task.TaskDir().SharedAllocDir, task.Env[env.AllocDir])
taskLocalBind := fmt.Sprintf("%s:%s", task.TaskDir().LocalDir, task.Env[env.TaskLocalDir])
secretDirBind := fmt.Sprintf("%s:%s", task.TaskDir().SecretsDir, task.Env[env.SecretsDir])
allocDirBind := fmt.Sprintf("%s:%s", task.TaskDir().SharedAllocDir, task.Env[taskenv.AllocDir])
taskLocalBind := fmt.Sprintf("%s:%s", task.TaskDir().LocalDir, task.Env[taskenv.TaskLocalDir])
secretDirBind := fmt.Sprintf("%s:%s", task.TaskDir().SecretsDir, task.Env[taskenv.SecretsDir])
binds := []string{allocDirBind, taskLocalBind, secretDirBind}
if !d.config.Volumes.Enabled && driverConfig.VolumeDriver != "" {

View File

@ -20,8 +20,8 @@ import (
"github.com/hashicorp/consul/lib/freeport"
hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/client/testutil"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/helper/testlog"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/structs"
@ -572,7 +572,7 @@ func TestDockerDriver_Start_Wait_AllocDir(t *testing.T) {
Args: []string{
"-c",
fmt.Sprintf(`sleep 1; echo -n %s > $%s/%s`,
string(exp), env.AllocDir, file),
string(exp), taskenv.AllocDir, file),
},
}
task := &drivers.TaskConfig{

View File

@ -26,7 +26,7 @@ import (
"github.com/hashicorp/go-version"
"github.com/hashicorp/nomad/client/config"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/drivers/shared/eventer"
"github.com/hashicorp/nomad/drivers/shared/executor"
"github.com/hashicorp/nomad/plugins/base"
@ -353,7 +353,7 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error {
// The taskConfig's environment is set via --set-env flags in Start, but the rkt
// command itself needs an environment with PATH set to find iptables.
// TODO (preetha) need to figure out how to read env.blacklist
eb := env.NewEmptyBuilder()
eb := taskenv.NewEmptyBuilder()
filter := strings.Split(config.DefaultEnvBlacklist, ",")
rktEnv := eb.SetHostEnvvars(filter).Build()
@ -636,7 +636,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
// command itself needs an environment with PATH set to find iptables.
// TODO (preetha) need to figure out how to pass env.blacklist from client config
eb := env.NewEmptyBuilder()
eb := taskenv.NewEmptyBuilder()
filter := strings.Split(config.DefaultEnvBlacklist, ",")
rktEnv := eb.SetHostEnvvars(filter).Build()

View File

@ -9,14 +9,14 @@ import (
hclog "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/drivers/shared/executor"
"github.com/hashicorp/nomad/plugins/drivers"
)
type taskHandle struct {
exec executor.Executor
env *env.TaskEnv
env *taskenv.TaskEnv
uuid string
pid int
pluginClient *plugin.Client

View File

@ -13,8 +13,8 @@ import (
hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/client/allocdir"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/client/testutil"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/helper/testlog"
"github.com/hashicorp/nomad/nomad/mock"
tu "github.com/hashicorp/nomad/testutil"
@ -50,7 +50,7 @@ func testExecutorCommandWithChroot(t *testing.T) (*ExecCommand, *allocdir.AllocD
alloc := mock.Alloc()
task := alloc.Job.TaskGroups[0].Tasks[0]
taskEnv := env.NewBuilder(mock.Node(), alloc, task, "global").Build()
taskEnv := taskenv.NewBuilder(mock.Node(), alloc, task, "global").Build()
allocDir := allocdir.NewAllocDir(testlog.HCLogger(t), filepath.Join(os.TempDir(), alloc.ID))
if err := allocDir.Build(); err != nil {

View File

@ -16,7 +16,7 @@ import (
hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/client/allocdir"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/helper/testlog"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/stretchr/testify/require"
@ -37,7 +37,7 @@ func init() {
func testExecutorCommand(t *testing.T) (*ExecCommand, *allocdir.AllocDir) {
alloc := mock.Alloc()
task := alloc.Job.TaskGroups[0].Tasks[0]
taskEnv := env.NewBuilder(mock.Node(), alloc, task, "global").Build()
taskEnv := taskenv.NewBuilder(mock.Node(), alloc, task, "global").Build()
allocDir := allocdir.NewAllocDir(testlog.HCLogger(t), filepath.Join(os.TempDir(), alloc.ID))
if err := allocDir.Build(); err != nil {

View File

@ -14,7 +14,7 @@ import (
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/client/logmon"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/helper/testlog"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock"
@ -112,7 +112,7 @@ func (h *DriverHarness) MkAllocDir(t *TaskConfig, enableLogs bool) func() {
if t.Resources != nil {
task.Resources = t.Resources.NomadResources
}
taskBuilder := env.NewBuilder(mock.Node(), mock.Alloc(), task, "global")
taskBuilder := taskenv.NewBuilder(mock.Node(), mock.Alloc(), task, "global")
utils.SetEnvvars(taskBuilder, fsi, taskDir, config.DefaultConfig())
taskEnv := taskBuilder.Build()

View File

@ -13,7 +13,7 @@ import (
"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/client/config"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/drivers/shared/env"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/drivers/shared/executor"
"github.com/hashicorp/nomad/helper/discover"
"github.com/hashicorp/nomad/nomad/structs"
@ -32,7 +32,7 @@ const (
)
// SetEnvvars sets path and host env vars depending on the FS isolation used.
func SetEnvvars(envBuilder *env.Builder, fsi cstructs.FSIsolation, taskDir *allocdir.TaskDir, conf *config.Config) {
func SetEnvvars(envBuilder *taskenv.Builder, fsi cstructs.FSIsolation, taskDir *allocdir.TaskDir, conf *config.Config) {
// Set driver-specific environment variables
switch fsi {
case cstructs.FSIsolationNone: