diff --git a/cmd/finch/nerdctl_darwin_test.go b/cmd/finch/nerdctl_darwin_test.go index bc909ca77..5fa79b458 100644 --- a/cmd/finch/nerdctl_darwin_test.go +++ b/cmd/finch/nerdctl_darwin_test.go @@ -46,11 +46,7 @@ func TestNerdctlCommand_runAdaptor(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) ncc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "info").Return(c) c.EXPECT().Run() @@ -112,12 +108,8 @@ func TestNerdctlCommand_run_pullCommand(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) logger.EXPECT().SetLevel(flog.Debug) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) c := mocks.NewCommand(ctrl) ncc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "pull", "test:tag").Return(c) c.EXPECT().Run() @@ -142,11 +134,7 @@ func TestNerdctlCommand_run_pullCommand(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) + AddEmptyEnvLookUps(ncsd) ncc.EXPECT().RunWithReplacingStdout( testStdoutRs, "shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "pull", "test:tag", "--help").Return(nil) }, @@ -170,11 +158,7 @@ func TestNerdctlCommand_run_pullCommand(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) + AddEmptyEnvLookUps(ncsd) ncc.EXPECT().RunWithReplacingStdout( testStdoutRs, "shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "pull", "test:tag", "--help"). Return(fmt.Errorf("failed to replace")) @@ -202,6 +186,10 @@ func TestNerdctlCommand_run_pullCommand(t *testing.T) { ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("test", true) ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) c := mocks.NewCommand(ctrl) @@ -232,6 +220,10 @@ func TestNerdctlCommand_run_pullCommand(t *testing.T) { ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("test", true) ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) c := mocks.NewCommand(ctrl) @@ -262,6 +254,10 @@ func TestNerdctlCommand_run_pullCommand(t *testing.T) { ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("test", true) ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) c := mocks.NewCommand(ctrl) @@ -298,6 +294,10 @@ func TestNerdctlCommand_run_pullCommand(t *testing.T) { ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("TEST_SESSION_TOKEN", true) ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) awsCmd := mocks.NewCommand(ctrl) ecc.EXPECT().Create( @@ -360,6 +360,10 @@ func TestNerdctlCommand_run_pullCommand(t *testing.T) { ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("TEST_SESSION_TOKEN", false) ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) awsCmd := mocks.NewCommand(ctrl) ecc.EXPECT().Create( @@ -419,6 +423,10 @@ func TestNerdctlCommand_run_pullCommand(t *testing.T) { ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("TEST_SESSION_TOKEN", true) ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) awsCmd := mocks.NewCommand(ctrl) ecc.EXPECT().Create( @@ -474,6 +482,10 @@ func TestNerdctlCommand_run_pullCommand(t *testing.T) { ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("TEST_SESSION_TOKEN", true) ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) awsCmd := mocks.NewCommand(ctrl) ecc.EXPECT().Create( @@ -562,11 +574,7 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "-it", "alpine:latest", "env").Return(c) @@ -595,11 +603,7 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "-it", "--name", "myContainer", "--rm", "-e", "ARG1=val1", "-e", "ARG2=val2", "-e", "ARG3=val3", @@ -626,14 +630,10 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().LookupEnv("ARG1").Return("val1", true) ncsd.EXPECT().LookupEnv("ARG2").Return("val2", true) ncsd.EXPECT().LookupEnv("ARG3").Return("val3", true) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "-it", "--rm", "--name", "myContainer", "-e", "ARG1=val1", "-e", "ARG2=val2", "-e", "ARG3=val3", @@ -663,14 +663,10 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().LookupEnv("ARG1") ncsd.EXPECT().LookupEnv("ARG2") ncsd.EXPECT().LookupEnv("ARG3") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--name", "myContainer", "-it", "--rm", "-e", "ARG0=val0", "alpine:latest", "env").Return(c) @@ -700,11 +696,7 @@ func TestNerdctlCommand_run(t *testing.T) { getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().SetLevel(flog.Debug) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--name", "myContainer", "--rm", "-it", "-e", "ARG1=val1", "-e", "ARG2=val2", "-e", "ARG3=val3", @@ -732,14 +724,10 @@ func TestNerdctlCommand_run(t *testing.T) { getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().SetLevel(flog.Debug) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().LookupEnv("ARG1").Return("val1", true) ncsd.EXPECT().LookupEnv("ARG2").Return("val2", true) ncsd.EXPECT().LookupEnv("ARG3").Return("val3", true) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--rm", "--name", "myContainer", "-it", "-e", "ARG1=val1", "-e", "ARG2=val2", "-e", "ARG3=val3", @@ -770,14 +758,10 @@ func TestNerdctlCommand_run(t *testing.T) { getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().SetLevel(flog.Debug) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().LookupEnv("ARG1") ncsd.EXPECT().LookupEnv("ARG2") ncsd.EXPECT().LookupEnv("ARG3") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--rm", "-it", "--name", "myContainer", "-e", "ARG0=val0", "alpine:latest", "env").Return(c) @@ -807,11 +791,7 @@ func TestNerdctlCommand_run(t *testing.T) { getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().SetLevel(flog.Debug) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "-i", "--name", "myContainer", "--rm", "-t", "-e", "ARG1=val1", "-e", "ARG2=val2", "-e", "ARG3=val3", @@ -841,14 +821,10 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) ncsd.EXPECT().LookupEnv("ARG2") ncsd.EXPECT().LookupEnv("NOTSETARG") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) lcc.EXPECT(). Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "-i", "--name", "myContainer", "--rm", "-e", "ARG1=val1", @@ -879,14 +855,10 @@ func TestNerdctlCommand_run(t *testing.T) { getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().SetLevel(flog.Debug) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) ncsd.EXPECT().LookupEnv("ARG2") ncsd.EXPECT().LookupEnv("NOTSETARG") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) lcc.EXPECT(). Create( "shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--rm", @@ -918,14 +890,10 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) ncsd.EXPECT().LookupEnv("ARG2").Return("val2", true) ncsd.EXPECT().LookupEnv("NOTSETARG") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) lcc.EXPECT(). Create( "shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", @@ -972,13 +940,9 @@ func TestNerdctlCommand_run(t *testing.T) { getVMStatusC := mocks.NewCommand(ctrl) lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) + AddEmptyEnvLookUps(ncsd) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) logger.EXPECT().Debugf(`Resolving special IP "host-gateway" to %q for host %q`, "192.168.5.2", "name") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--rm", "--add-host", "name:192.168.5.2", "alpine:latest").Return(c) @@ -1004,11 +968,7 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--rm", "--add-host", "name:0.0.0.0", "alpine:latest").Return(c) @@ -1034,11 +994,7 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--rm", "--add-host", "alpine:latest").Return(c) @@ -1064,12 +1020,8 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) logger.EXPECT().Debugf(`Resolving special IP "host-gateway" to %q for host %q`, "192.168.5.2", "name") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--rm", "--add-host=name:192.168.5.2", "alpine:latest").Return(c) @@ -1095,12 +1047,7 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) - + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--rm", "--add-host=name:0.0.0.0", "alpine:latest").Return(c) @@ -1129,11 +1076,7 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--rm", "-v", "/tmp:/tmp1/tmp2:rro", "--volume", "/tmp:/tmp1:rprivate,rro", "-v", "/tmp:/tmp1/tmp2/tmp3/tmp4:rro", @@ -1163,11 +1106,7 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--rm", "-v", "/tmp:/tmp1/tmp2:rro", "--volume", "/tmp:/tmp1:rprivate,rro", @@ -1198,11 +1137,7 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "-i", "-d", "-p", "8080:8080", "--name", "myContainer", "--rm", "-e", "ARG1=val1", @@ -1229,11 +1164,7 @@ func TestNerdctlCommand_run(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--mount", ContainsMultipleStrs([]string{"bind", "type", "!consistency"}), "alpine:latest").Return(c) @@ -1301,11 +1232,7 @@ func TestNerdctlCommand_run_inspectCommand(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) var stdoutBuf bytes.Buffer c.EXPECT().SetStdout(&stdoutBuf) @@ -1337,11 +1264,7 @@ func TestNerdctlCommand_run_inspectCommand(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) var stdoutBuf bytes.Buffer c.EXPECT().SetStdout(&stdoutBuf) @@ -1373,11 +1296,7 @@ func TestNerdctlCommand_run_inspectCommand(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "volume", "inspect", "myVolume").Return(c) c.EXPECT().Run() @@ -1406,11 +1325,7 @@ func TestNerdctlCommand_run_inspectCommand(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create( "shell", @@ -1449,11 +1364,7 @@ func TestNerdctlCommand_run_inspectCommand(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) var stdoutBuf bytes.Buffer c.EXPECT().SetStdout(&stdoutBuf) @@ -1523,11 +1434,7 @@ func TestNerdctlCommand_run_buildxCommand(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "build", "-t", "demo", ".").Return(c) c.EXPECT().Run() @@ -1615,11 +1522,7 @@ func TestNerdctlCommand_run_miscCommand(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "image", "build", "-t", "demo", ".").Return(c) c.EXPECT().Run() @@ -1647,6 +1550,10 @@ func TestNerdctlCommand_run_miscCommand(t *testing.T) { ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("test", true) ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) c := mocks.NewCommand(ctrl) @@ -1675,11 +1582,7 @@ func TestNerdctlCommand_run_miscCommand(t *testing.T) { lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "exec", "test-ctr", "sh", "-c", "echo", "foo", ">", "/tmp/test.txt").Return(c) @@ -1706,6 +1609,18 @@ func TestNerdctlCommand_run_miscCommand(t *testing.T) { } } +func AddEmptyEnvLookUps(ncsd *mocks.NerdctlCommandSystemDeps) { + ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) + ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) +} + type ContainsSubstring struct { substr string } diff --git a/cmd/finch/nerdctl_remote.go b/cmd/finch/nerdctl_remote.go index 8709fbdfd..b7f68ce90 100644 --- a/cmd/finch/nerdctl_remote.go +++ b/cmd/finch/nerdctl_remote.go @@ -286,7 +286,8 @@ func (nc *nerdctlCommand) run(cmdName string, args []string) error { passedEnvs := []string{ "COSIGN_PASSWORD", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", - "AWS_SESSION_TOKEN", "COMPOSE_FILE", + "AWS_SESSION_TOKEN", "COMPOSE_FILE", "SOURCE_DATE_EPOCH", + "AWS_ECR_DISABLE_CACHE", "AWS_ECR_CACHE_DIR", "AWS_ECR_IGNORE_CREDS_STORAGE", } var passedEnvArgs []string diff --git a/cmd/finch/nerdctl_windows_test.go b/cmd/finch/nerdctl_windows_test.go index e03aac519..e3400541d 100644 --- a/cmd/finch/nerdctl_windows_test.go +++ b/cmd/finch/nerdctl_windows_test.go @@ -51,11 +51,7 @@ func TestNerdctlCommand_runAdaptor(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -116,11 +112,7 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\Users").Return("C:\\Users", nil) @@ -156,12 +148,8 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) logger.EXPECT().SetLevel(flog.Debug) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -192,15 +180,11 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) ncsd.EXPECT().LookupEnv("ARG1") ncsd.EXPECT().LookupEnv("ARG2") ncsd.EXPECT().LookupEnv("ARG3") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -231,14 +215,10 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) ncsd.EXPECT().LookupEnv("ARG2") ncsd.EXPECT().LookupEnv("ARG3").Return("val3", true) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -270,14 +250,10 @@ func TestNerdctlCommand_run(t *testing.T) { getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().SetLevel(flog.Debug) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) ncsd.EXPECT().LookupEnv("ARG2") ncsd.EXPECT().LookupEnv("ARG3").Return("val3", true) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -311,14 +287,10 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) ncsd.EXPECT().LookupEnv("ARG2") ncsd.EXPECT().LookupEnv("NOTSETARG") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -352,14 +324,10 @@ func TestNerdctlCommand_run(t *testing.T) { getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().SetLevel(flog.Debug) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) ncsd.EXPECT().LookupEnv("ARG2") ncsd.EXPECT().LookupEnv("NOTSETARG") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -392,14 +360,10 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) c := mocks.NewCommand(ctrl) ncsd.EXPECT().LookupEnv("ARG2").Return("val2", true) ncsd.EXPECT().LookupEnv("NOTSETARG") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -453,12 +417,8 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) logger.EXPECT().Debugf(`Resolving special IP "host-gateway" to %q for host %q`, "192.168.5.2", "name") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -490,11 +450,7 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -525,11 +481,7 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -562,12 +514,8 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + AddEmptyEnvLookUps(ncsd) logger.EXPECT().Debugf(`Resolving special IP "host-gateway" to %q for host %q`, "192.168.5.2", "name") - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -598,11 +546,7 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -636,11 +580,7 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil).Times(1) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil).Times(5) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath).Times(3) @@ -672,11 +612,7 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -706,11 +642,7 @@ func TestNerdctlCommand_run(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -745,6 +677,10 @@ func TestNerdctlCommand_run(t *testing.T) { ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("test", true) ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -780,6 +716,10 @@ func TestNerdctlCommand_run(t *testing.T) { ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("test", true) ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -815,6 +755,10 @@ func TestNerdctlCommand_run(t *testing.T) { ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("test", true) ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -893,11 +837,7 @@ func TestNerdctlCommand_Run_withBindMounts(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil).Times(2) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath).Times(2) @@ -929,11 +869,7 @@ func TestNerdctlCommand_Run_withBindMounts(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil).Times(2) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath).Times(2) @@ -965,11 +901,7 @@ func TestNerdctlCommand_Run_withBindMounts(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil).Times(2) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath).Times(2) @@ -1001,11 +933,7 @@ func TestNerdctlCommand_Run_withBindMounts(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil).Times(1) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath).Times(1) @@ -1037,11 +965,7 @@ func TestNerdctlCommand_Run_withBindMounts(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil).Times(1) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath).Times(1) @@ -1096,11 +1020,7 @@ func TestNerdctlCommand_run_CpCommand(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -1126,11 +1046,7 @@ func TestNerdctlCommand_run_CpCommand(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -1156,11 +1072,7 @@ func TestNerdctlCommand_run_CpCommand(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -1220,11 +1132,7 @@ func TestNerdctlCommand_run_BuildCommand(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -1250,11 +1158,7 @@ func TestNerdctlCommand_run_BuildCommand(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -1280,11 +1184,7 @@ func TestNerdctlCommand_run_BuildCommand(t *testing.T) { ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil) logger.EXPECT().Debugf("Status of virtual machine: %s", "Running") - ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) - ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) - ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) - ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + AddEmptyEnvLookUps(ncsd) ncsd.EXPECT().GetWd().Return("C:\\workdir", nil) ncsd.EXPECT().FilePathAbs("C:\\workdir").Return("C:\\workdir", nil) ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) @@ -1322,3 +1222,15 @@ func TestNerdctlCommand_run_BuildCommand(t *testing.T) { }) } } + +func AddEmptyEnvLookUps(ncsd *mocks.NerdctlCommandSystemDeps) { + ncsd.EXPECT().LookupEnv("AWS_ACCESS_KEY_ID").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_SECRET_ACCESS_KEY").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_SESSION_TOKEN").Return("", false) + ncsd.EXPECT().LookupEnv("COSIGN_PASSWORD").Return("", false) + ncsd.EXPECT().LookupEnv("COMPOSE_FILE").Return("", false) + ncsd.EXPECT().LookupEnv("SOURCE_DATE_EPOCH").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_DISABLE_CACHE").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_CACHE_DIR").Return("", false) + ncsd.EXPECT().LookupEnv("AWS_ECR_IGNORE_CREDS_STORAGE").Return("", false) +}