diff --git a/cli/cli/commands/service/exec/exec.go b/cli/cli/commands/service/exec/exec.go index ccd304b3bc..f479564f57 100644 --- a/cli/cli/commands/service/exec/exec.go +++ b/cli/cli/commands/service/exec/exec.go @@ -3,6 +3,7 @@ package exec import ( "context" "fmt" + "github.com/kurtosis-tech/kurtosis/api/golang/engine/kurtosis_engine_rpc_api_bindings" "github.com/kurtosis-tech/kurtosis/api/golang/engine/lib/kurtosis_context" "github.com/kurtosis-tech/kurtosis/cli/cli/command_framework/highlevel/enclave_id_arg" @@ -32,6 +33,10 @@ const ( isExecCommandArgOptional = false isExecCommandArgGreedy = false + containerUserKey = "user" + containerUserShortKey = "u" + containerUserDefault = "root" + kurtosisBackendCtxKey = "kurtosis-backend" engineClientCtxKey = "engine-client" @@ -45,7 +50,13 @@ var ServiceShellCmd = &engine_consuming_kurtosis_command.EngineConsumingKurtosis LongDescription: "Execute a command in a service. Note if the command being run is multiple words you should wrap it in quotes", KurtosisBackendContextKey: kurtosisBackendCtxKey, EngineClientContextKey: engineClientCtxKey, - Flags: []*flags.FlagConfig{}, + Flags: []*flags.FlagConfig{{ + Key: containerUserKey, + Usage: "optional service container user for command", + Shorthand: containerUserShortKey, + Type: flags.FlagType_String, + Default: containerUserDefault, + }}, Args: []*args.ArgConfig{ enclave_id_arg.NewEnclaveIdentifierArg( enclaveIdentifierArgKey, @@ -109,7 +120,17 @@ func run( } serviceUuid := service.ServiceUUID(serviceCtx.GetServiceUUID()) - results, resultErrors, err := kurtosisBackend.RunUserServiceExecCommands(ctx, enclaveUuid, map[service.ServiceUUID][]string{ + containerUser, err := flags.GetString(containerUserKey) + if err != nil { + return stacktrace.Propagate(err, "An error occurred getting the exec container user flag '%v'", containerUserKey) + } + // convert "root" to "" as it is implied if empty. This simplifies the backend + // impl usages that do not support --user + if containerUser == containerUserDefault { + containerUser = "" + } + + results, resultErrors, err := kurtosisBackend.RunUserServiceExecCommands(ctx, enclaveUuid, containerUser, map[service.ServiceUUID][]string{ serviceUuid: { binShCommand, binShCommandFlag, diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/docker_kurtosis_backend.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/docker_kurtosis_backend.go index d2af3c2e81..0f0188c814 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/docker_kurtosis_backend.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/docker_kurtosis_backend.go @@ -297,13 +297,14 @@ func (backend *DockerKurtosisBackend) GetUserServiceLogs( func (backend *DockerKurtosisBackend) RunUserServiceExecCommands( ctx context.Context, enclaveUuid enclave.EnclaveUUID, + containerUser string, userServiceCommands map[service.ServiceUUID][]string, ) ( map[service.ServiceUUID]*exec_result.ExecResult, map[service.ServiceUUID]error, error, ) { - return user_service_functions.RunUserServiceExecCommands(ctx, enclaveUuid, userServiceCommands, backend.dockerManager) + return user_service_functions.RunUserServiceExecCommands(ctx, enclaveUuid, containerUser, userServiceCommands, backend.dockerManager) } func (backend *DockerKurtosisBackend) RunUserServiceExecCommandWithStreamedOutput( diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go index e5a22cfa36..e0c313c0ae 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/docker_config_storage_creator/docker_config_storage_creator.go @@ -142,7 +142,7 @@ func storeConfigInVolume( } for i := uint(0); i < maxRetries; i++ { outputBuffer := &bytes.Buffer{} - exitCode, err := dockerManager.RunExecCommand(ctx, containerId, execCmd, outputBuffer) + exitCode, err := dockerManager.RunUserServiceExecCommands(ctx, containerId, "", execCmd, outputBuffer) if err == nil { if exitCode == creationSuccessExitCode { logrus.Debugf("The Docker config file was successfully added into the volume.") diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/github_auth_storage_creator/github_auth_storage_creator.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/github_auth_storage_creator/github_auth_storage_creator.go index f918ec4f92..929b1991bc 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/github_auth_storage_creator/github_auth_storage_creator.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/engine_functions/github_auth_storage_creator/github_auth_storage_creator.go @@ -4,13 +4,14 @@ import ( "bytes" "context" "fmt" + "os" + "path" + "time" + "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/consts" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_manager" "github.com/kurtosis-tech/stacktrace" "github.com/sirupsen/logrus" - "os" - "path" - "time" ) const ( @@ -124,7 +125,7 @@ func storeTokenInVolume( } for i := uint(0); i < maxRetries; i++ { outputBuffer := &bytes.Buffer{} - exitCode, err := dockerManager.RunExecCommand(ctx, containerId, execCmd, outputBuffer) + exitCode, err := dockerManager.RunUserServiceExecCommands(ctx, containerId, "", execCmd, outputBuffer) if err == nil { if exitCode == authStorageCreationSuccessExitCode { logrus.Debugf("The GitHub auth token was successfully added into the volume.") diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/logs_collector_functions/implementations/fluentbit/fluentbit_configuration_creator.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/logs_collector_functions/implementations/fluentbit/fluentbit_configuration_creator.go index d713300b46..9226eb24aa 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/logs_collector_functions/implementations/fluentbit/fluentbit_configuration_creator.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/logs_collector_functions/implementations/fluentbit/fluentbit_configuration_creator.go @@ -129,7 +129,7 @@ func (fluent *fluentbitConfigurationCreator) createFluentbitConfigFileInVolume( } for i := uint(0); i < maxRetries; i++ { outputBuffer := &bytes.Buffer{} - exitCode, err := dockerManager.RunExecCommand(ctx, containerId, execCmd, outputBuffer) + exitCode, err := dockerManager.RunUserServiceExecCommands(ctx, containerId, "", execCmd, outputBuffer) if err == nil { if exitCode == configFileCreationSuccessExitCode { logrus.Debugf("The Fluentbit config file with content '%v' was successfully added into the volume", configFileContentStr) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/shared_helpers/shared_helpers.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/shared_helpers/shared_helpers.go index 18c3e533e2..2a11bc0288 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/shared_helpers/shared_helpers.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/shared_helpers/shared_helpers.go @@ -5,7 +5,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/object_attributes_provider/docker_label_key" "io" "net" "os" @@ -14,6 +13,8 @@ import ( "strings" "time" + "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/object_attributes_provider/docker_label_key" + "github.com/docker/docker/pkg/stdcopy" "github.com/docker/go-connections/nat" "github.com/gammazero/workerpool" @@ -379,7 +380,7 @@ func WaitForPortAvailabilityUsingNetstat( } for i := uint(0); i < maxRetries; i++ { outputBuffer := &bytes.Buffer{} - exitCode, err := dockerManager.RunExecCommand(ctx, containerId, execCmd, outputBuffer) + exitCode, err := dockerManager.RunUserServiceExecCommands(ctx, containerId, "", execCmd, outputBuffer) if err == nil { if exitCode == netstatSuccessExitCode { return nil diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/run_user_service_exec_commands.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/run_user_service_exec_commands.go index 0eddf3b013..1fd7b4ef2e 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/run_user_service_exec_commands.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/run_user_service_exec_commands.go @@ -3,6 +3,8 @@ package user_service_functions import ( "bytes" "context" + "reflect" + "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/shared_helpers" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_manager" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/enclave" @@ -10,13 +12,13 @@ import ( "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/operation_parallelizer" "github.com/kurtosis-tech/stacktrace" - "reflect" ) // TODO Switch these to streaming so that huge command outputs don't blow up the API container memory func RunUserServiceExecCommands( ctx context.Context, enclaveId enclave.EnclaveUUID, + containerUser string, userServiceCommands map[service.ServiceUUID][]string, dockerManager *docker_manager.DockerManager, ) ( @@ -46,7 +48,7 @@ func RunUserServiceExecCommands( // the error to the map downstream } - successfulExecs, failedExecs, err := runExecOperationsInParallel(ctx, userServiceCommands, userServiceDockerResources, dockerManager) + successfulExecs, failedExecs, err := runExecOperationsInParallel(ctx, containerUser, userServiceCommands, userServiceDockerResources, dockerManager) if err != nil { return nil, nil, stacktrace.Propagate(err, "An unexpected error occurred running the exec commands in parallel") } @@ -55,6 +57,7 @@ func RunUserServiceExecCommands( func runExecOperationsInParallel( ctx context.Context, + containerUser string, commandArgs map[service.ServiceUUID][]string, userServiceDockerResources map[service.ServiceUUID]*shared_helpers.UserServiceDockerResources, dockerManager *docker_manager.DockerManager, @@ -79,7 +82,7 @@ func runExecOperationsInParallel( } execOperationId := operation_parallelizer.OperationID(serviceUuid) - execOperation := createExecOperation(ctx, serviceUuid, userServiceDockerResource, commandArg, dockerManager) + execOperation := createExecOperation(ctx, serviceUuid, containerUser, userServiceDockerResource, commandArg, dockerManager) execOperations[execOperationId] = execOperation } @@ -108,6 +111,7 @@ func runExecOperationsInParallel( func createExecOperation( ctx context.Context, serviceUuid service.ServiceUUID, + containerUser string, userServiceDockerResource *shared_helpers.UserServiceDockerResources, commandArg []string, dockerManager *docker_manager.DockerManager, @@ -116,9 +120,10 @@ func createExecOperation( execOutputBuf := &bytes.Buffer{} userServiceDockerContainer := userServiceDockerResource.ServiceContainer - exitCode, err := dockerManager.RunExecCommand( + exitCode, err := dockerManager.RunUserServiceExecCommands( ctx, userServiceDockerContainer.GetId(), + containerUser, commandArg, execOutputBuf, ) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_manager.go b/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_manager.go index c75e39862b..bae23ee2d4 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_manager.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_manager.go @@ -990,13 +990,13 @@ func (manager *DockerManager) GetContainerLogs( } /* -RunExecCommand +RunUserServiceExecCommands Executes the given command inside the container with the given ID, blocking until the command completes */ -func (manager *DockerManager) RunExecCommand(context context.Context, containerId string, command []string, logOutput io.Writer) (int32, error) { +func (manager *DockerManager) RunUserServiceExecCommands(context context.Context, containerId, userId string, command []string, logOutput io.Writer) (int32, error) { dockerClient := manager.dockerClient execConfig := types.ExecConfig{ - User: "", + User: userId, Privileged: false, Tty: false, ConsoleSize: nil, diff --git a/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/kubernetes_kurtosis_backend.go b/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/kubernetes_kurtosis_backend.go index 8f835e4e7e..3c3b284536 100644 --- a/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/kubernetes_kurtosis_backend.go +++ b/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/kubernetes_kurtosis_backend.go @@ -347,12 +347,17 @@ func (backend *KubernetesKurtosisBackend) GetUserServiceLogs( func (backend *KubernetesKurtosisBackend) RunUserServiceExecCommands( ctx context.Context, enclaveUuid enclave.EnclaveUUID, + containerUser string, userServiceCommands map[service.ServiceUUID][]string, ) ( succesfulUserServiceExecResults map[service.ServiceUUID]*exec_result.ExecResult, erroredUserServiceUuids map[service.ServiceUUID]error, resultErr error, ) { + if containerUser != "" { + resultErr = stacktrace.NewError("--user not implemented for kurtosis backend") + return + } return user_services_functions.RunUserServiceExecCommands( ctx, enclaveUuid, diff --git a/container-engine-lib/lib/backend_impls/metrics_reporting/metrics_reporting_kurtosis_backend.go b/container-engine-lib/lib/backend_impls/metrics_reporting/metrics_reporting_kurtosis_backend.go index c96e23449e..6bd0477876 100644 --- a/container-engine-lib/lib/backend_impls/metrics_reporting/metrics_reporting_kurtosis_backend.go +++ b/container-engine-lib/lib/backend_impls/metrics_reporting/metrics_reporting_kurtosis_backend.go @@ -322,13 +322,14 @@ func (backend *MetricsReportingKurtosisBackend) GetUserServiceLogs( func (backend *MetricsReportingKurtosisBackend) RunUserServiceExecCommands( ctx context.Context, enclaveUuid enclave.EnclaveUUID, + containerUser string, userServiceCommands map[service.ServiceUUID][]string, ) ( - succesfulUserServiceExecResults map[service.ServiceUUID]*exec_result.ExecResult, + successfulUserServiceExecResults map[service.ServiceUUID]*exec_result.ExecResult, erroredUserServiceUuids map[service.ServiceUUID]error, resultErr error, ) { - succesfulUserServiceExecResults, erroredUserServiceUuids, err := backend.underlying.RunUserServiceExecCommands(ctx, enclaveUuid, userServiceCommands) + successfulUserServiceExecResults, erroredUserServiceUuids, err := backend.underlying.RunUserServiceExecCommands(ctx, enclaveUuid, containerUser, userServiceCommands) if err != nil { return nil, nil, stacktrace.Propagate( err, @@ -337,7 +338,7 @@ func (backend *MetricsReportingKurtosisBackend) RunUserServiceExecCommands( enclaveUuid, ) } - return succesfulUserServiceExecResults, erroredUserServiceUuids, nil + return successfulUserServiceExecResults, erroredUserServiceUuids, nil } func (backend *MetricsReportingKurtosisBackend) RunUserServiceExecCommandWithStreamedOutput( diff --git a/container-engine-lib/lib/backend_interface/kurtosis_backend.go b/container-engine-lib/lib/backend_interface/kurtosis_backend.go index c0d7ad2039..fa23108d5c 100644 --- a/container-engine-lib/lib/backend_interface/kurtosis_backend.go +++ b/container-engine-lib/lib/backend_interface/kurtosis_backend.go @@ -280,9 +280,10 @@ type KurtosisBackend interface { RunUserServiceExecCommands( ctx context.Context, enclaveUuid enclave.EnclaveUUID, + containerUser string, userServiceCommands map[service.ServiceUUID][]string, ) ( - succesfulUserServiceExecResults map[service.ServiceUUID]*exec_result.ExecResult, + successfulUserServiceExecResults map[service.ServiceUUID]*exec_result.ExecResult, erroredUserServiceUuids map[service.ServiceUUID]error, resultErr error, ) diff --git a/container-engine-lib/lib/backend_interface/mock_kurtosis_backend.go b/container-engine-lib/lib/backend_interface/mock_kurtosis_backend.go index 63260d872b..f400480f99 100644 --- a/container-engine-lib/lib/backend_interface/mock_kurtosis_backend.go +++ b/container-engine-lib/lib/backend_interface/mock_kurtosis_backend.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.36.0. DO NOT EDIT. +// Code generated by mockery v2.39.0. DO NOT EDIT. package backend_interface @@ -54,6 +54,10 @@ func (_m *MockKurtosisBackend) EXPECT() *MockKurtosisBackend_Expecter { func (_m *MockKurtosisBackend) BuildImage(ctx context.Context, imageName string, imageBuildSpec *image_build_spec.ImageBuildSpec) (string, error) { ret := _m.Called(ctx, imageName, imageBuildSpec) + if len(ret) == 0 { + panic("no return value specified for BuildImage") + } + var r0 string var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, *image_build_spec.ImageBuildSpec) (string, error)); ok { @@ -108,6 +112,10 @@ func (_c *MockKurtosisBackend_BuildImage_Call) RunAndReturn(run func(context.Con func (_m *MockKurtosisBackend) CopyFilesFromUserService(ctx context.Context, enclaveUuid enclave.EnclaveUUID, serviceUuid service.ServiceUUID, srcPathOnService string, output io.Writer) error { ret := _m.Called(ctx, enclaveUuid, serviceUuid, srcPathOnService, output) + if len(ret) == 0 { + panic("no return value specified for CopyFilesFromUserService") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID, service.ServiceUUID, string, io.Writer) error); ok { r0 = rf(ctx, enclaveUuid, serviceUuid, srcPathOnService, output) @@ -154,6 +162,10 @@ func (_c *MockKurtosisBackend_CopyFilesFromUserService_Call) RunAndReturn(run fu func (_m *MockKurtosisBackend) CreateAPIContainer(ctx context.Context, image string, enclaveUuid enclave.EnclaveUUID, grpcPortNum uint16, enclaveDataVolumeDirpath string, ownIpAddressEnvVar string, customEnvVars map[string]string, shouldStartInDebugMode bool) (*api_container.APIContainer, error) { ret := _m.Called(ctx, image, enclaveUuid, grpcPortNum, enclaveDataVolumeDirpath, ownIpAddressEnvVar, customEnvVars, shouldStartInDebugMode) + if len(ret) == 0 { + panic("no return value specified for CreateAPIContainer") + } + var r0 *api_container.APIContainer var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, enclave.EnclaveUUID, uint16, string, string, map[string]string, bool) (*api_container.APIContainer, error)); ok { @@ -215,6 +227,10 @@ func (_c *MockKurtosisBackend_CreateAPIContainer_Call) RunAndReturn(run func(con func (_m *MockKurtosisBackend) CreateEnclave(ctx context.Context, enclaveUuid enclave.EnclaveUUID, enclaveName string) (*enclave.Enclave, error) { ret := _m.Called(ctx, enclaveUuid, enclaveName) + if len(ret) == 0 { + panic("no return value specified for CreateEnclave") + } + var r0 *enclave.Enclave var r1 error if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID, string) (*enclave.Enclave, error)); ok { @@ -271,6 +287,10 @@ func (_c *MockKurtosisBackend_CreateEnclave_Call) RunAndReturn(run func(context. func (_m *MockKurtosisBackend) CreateEngine(ctx context.Context, imageOrgAndRepo string, imageVersionTag string, grpcPortNum uint16, envVars map[string]string, shouldStartInDebugMode bool, githubAuthToken string) (*engine.Engine, error) { ret := _m.Called(ctx, imageOrgAndRepo, imageVersionTag, grpcPortNum, envVars, shouldStartInDebugMode, githubAuthToken) + if len(ret) == 0 { + panic("no return value specified for CreateEngine") + } + var r0 *engine.Engine var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, string, uint16, map[string]string, bool, string) (*engine.Engine, error)); ok { @@ -331,6 +351,10 @@ func (_c *MockKurtosisBackend_CreateEngine_Call) RunAndReturn(run func(context.C func (_m *MockKurtosisBackend) CreateLogsAggregator(ctx context.Context) (*logs_aggregator.LogsAggregator, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for CreateLogsAggregator") + } + var r0 *logs_aggregator.LogsAggregator var r1 error if rf, ok := ret.Get(0).(func(context.Context) (*logs_aggregator.LogsAggregator, error)); ok { @@ -385,6 +409,10 @@ func (_c *MockKurtosisBackend_CreateLogsAggregator_Call) RunAndReturn(run func(c func (_m *MockKurtosisBackend) CreateLogsCollectorForEnclave(ctx context.Context, enclaveUuid enclave.EnclaveUUID, logsCollectorHttpPortNumber uint16, logsCollectorTcpPortNumber uint16) (*logs_collector.LogsCollector, error) { ret := _m.Called(ctx, enclaveUuid, logsCollectorHttpPortNumber, logsCollectorTcpPortNumber) + if len(ret) == 0 { + panic("no return value specified for CreateLogsCollectorForEnclave") + } + var r0 *logs_collector.LogsCollector var r1 error if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID, uint16, uint16) (*logs_collector.LogsCollector, error)); ok { @@ -442,6 +470,10 @@ func (_c *MockKurtosisBackend_CreateLogsCollectorForEnclave_Call) RunAndReturn(r func (_m *MockKurtosisBackend) CreateReverseProxy(ctx context.Context, engineGuid engine.EngineGUID) (*reverse_proxy.ReverseProxy, error) { ret := _m.Called(ctx, engineGuid) + if len(ret) == 0 { + panic("no return value specified for CreateReverseProxy") + } + var r0 *reverse_proxy.ReverseProxy var r1 error if rf, ok := ret.Get(0).(func(context.Context, engine.EngineGUID) (*reverse_proxy.ReverseProxy, error)); ok { @@ -497,6 +529,10 @@ func (_c *MockKurtosisBackend_CreateReverseProxy_Call) RunAndReturn(run func(con func (_m *MockKurtosisBackend) DestroyAPIContainers(ctx context.Context, filters *api_container.APIContainerFilters) (map[enclave.EnclaveUUID]bool, map[enclave.EnclaveUUID]error, error) { ret := _m.Called(ctx, filters) + if len(ret) == 0 { + panic("no return value specified for DestroyAPIContainers") + } + var r0 map[enclave.EnclaveUUID]bool var r1 map[enclave.EnclaveUUID]error var r2 error @@ -561,6 +597,10 @@ func (_c *MockKurtosisBackend_DestroyAPIContainers_Call) RunAndReturn(run func(c func (_m *MockKurtosisBackend) DestroyEnclaves(ctx context.Context, filters *enclave.EnclaveFilters) (map[enclave.EnclaveUUID]bool, map[enclave.EnclaveUUID]error, error) { ret := _m.Called(ctx, filters) + if len(ret) == 0 { + panic("no return value specified for DestroyEnclaves") + } + var r0 map[enclave.EnclaveUUID]bool var r1 map[enclave.EnclaveUUID]error var r2 error @@ -625,6 +665,10 @@ func (_c *MockKurtosisBackend_DestroyEnclaves_Call) RunAndReturn(run func(contex func (_m *MockKurtosisBackend) DestroyEngines(ctx context.Context, filters *engine.EngineFilters) (map[engine.EngineGUID]bool, map[engine.EngineGUID]error, error) { ret := _m.Called(ctx, filters) + if len(ret) == 0 { + panic("no return value specified for DestroyEngines") + } + var r0 map[engine.EngineGUID]bool var r1 map[engine.EngineGUID]error var r2 error @@ -689,6 +733,10 @@ func (_c *MockKurtosisBackend_DestroyEngines_Call) RunAndReturn(run func(context func (_m *MockKurtosisBackend) DestroyLogsAggregator(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for DestroyLogsAggregator") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -731,6 +779,10 @@ func (_c *MockKurtosisBackend_DestroyLogsAggregator_Call) RunAndReturn(run func( func (_m *MockKurtosisBackend) DestroyLogsCollectorForEnclave(ctx context.Context, enclaveUuid enclave.EnclaveUUID) error { ret := _m.Called(ctx, enclaveUuid) + if len(ret) == 0 { + panic("no return value specified for DestroyLogsCollectorForEnclave") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID) error); ok { r0 = rf(ctx, enclaveUuid) @@ -774,6 +826,10 @@ func (_c *MockKurtosisBackend_DestroyLogsCollectorForEnclave_Call) RunAndReturn( func (_m *MockKurtosisBackend) DestroyReverseProxy(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for DestroyReverseProxy") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -816,6 +872,10 @@ func (_c *MockKurtosisBackend_DestroyReverseProxy_Call) RunAndReturn(run func(co func (_m *MockKurtosisBackend) DestroyUserServices(ctx context.Context, enclaveUuid enclave.EnclaveUUID, filters *service.ServiceFilters) (map[service.ServiceUUID]bool, map[service.ServiceUUID]error, error) { ret := _m.Called(ctx, enclaveUuid, filters) + if len(ret) == 0 { + panic("no return value specified for DestroyUserServices") + } + var r0 map[service.ServiceUUID]bool var r1 map[service.ServiceUUID]error var r2 error @@ -881,6 +941,10 @@ func (_c *MockKurtosisBackend_DestroyUserServices_Call) RunAndReturn(run func(co func (_m *MockKurtosisBackend) DumpEnclave(ctx context.Context, enclaveUuid enclave.EnclaveUUID, outputDirpath string) error { ret := _m.Called(ctx, enclaveUuid, outputDirpath) + if len(ret) == 0 { + panic("no return value specified for DumpEnclave") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID, string) error); ok { r0 = rf(ctx, enclaveUuid, outputDirpath) @@ -925,6 +989,10 @@ func (_c *MockKurtosisBackend_DumpEnclave_Call) RunAndReturn(run func(context.Co func (_m *MockKurtosisBackend) DumpKurtosis(ctx context.Context, outputDirpath string) error { ret := _m.Called(ctx, outputDirpath) + if len(ret) == 0 { + panic("no return value specified for DumpKurtosis") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { r0 = rf(ctx, outputDirpath) @@ -968,6 +1036,10 @@ func (_c *MockKurtosisBackend_DumpKurtosis_Call) RunAndReturn(run func(context.C func (_m *MockKurtosisBackend) FetchImage(ctx context.Context, image string, registrySpec *image_registry_spec.ImageRegistrySpec, downloadMode image_download_mode.ImageDownloadMode) (bool, string, error) { ret := _m.Called(ctx, image, registrySpec, downloadMode) + if len(ret) == 0 { + panic("no return value specified for FetchImage") + } + var r0 bool var r1 string var r2 error @@ -1030,6 +1102,10 @@ func (_c *MockKurtosisBackend_FetchImage_Call) RunAndReturn(run func(context.Con func (_m *MockKurtosisBackend) GetAPIContainers(ctx context.Context, filters *api_container.APIContainerFilters) (map[enclave.EnclaveUUID]*api_container.APIContainer, error) { ret := _m.Called(ctx, filters) + if len(ret) == 0 { + panic("no return value specified for GetAPIContainers") + } + var r0 map[enclave.EnclaveUUID]*api_container.APIContainer var r1 error if rf, ok := ret.Get(0).(func(context.Context, *api_container.APIContainerFilters) (map[enclave.EnclaveUUID]*api_container.APIContainer, error)); ok { @@ -1085,6 +1161,10 @@ func (_c *MockKurtosisBackend_GetAPIContainers_Call) RunAndReturn(run func(conte func (_m *MockKurtosisBackend) GetAvailableCPUAndMemory(ctx context.Context) (compute_resources.MemoryInMegaBytes, compute_resources.CpuMilliCores, bool, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetAvailableCPUAndMemory") + } + var r0 compute_resources.MemoryInMegaBytes var r1 compute_resources.CpuMilliCores var r2 bool @@ -1151,6 +1231,10 @@ func (_c *MockKurtosisBackend_GetAvailableCPUAndMemory_Call) RunAndReturn(run fu func (_m *MockKurtosisBackend) GetEnclaves(ctx context.Context, filters *enclave.EnclaveFilters) (map[enclave.EnclaveUUID]*enclave.Enclave, error) { ret := _m.Called(ctx, filters) + if len(ret) == 0 { + panic("no return value specified for GetEnclaves") + } + var r0 map[enclave.EnclaveUUID]*enclave.Enclave var r1 error if rf, ok := ret.Get(0).(func(context.Context, *enclave.EnclaveFilters) (map[enclave.EnclaveUUID]*enclave.Enclave, error)); ok { @@ -1206,6 +1290,10 @@ func (_c *MockKurtosisBackend_GetEnclaves_Call) RunAndReturn(run func(context.Co func (_m *MockKurtosisBackend) GetEngineLogs(ctx context.Context, outputDirpath string) error { ret := _m.Called(ctx, outputDirpath) + if len(ret) == 0 { + panic("no return value specified for GetEngineLogs") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { r0 = rf(ctx, outputDirpath) @@ -1249,6 +1337,10 @@ func (_c *MockKurtosisBackend_GetEngineLogs_Call) RunAndReturn(run func(context. func (_m *MockKurtosisBackend) GetEngines(ctx context.Context, filters *engine.EngineFilters) (map[engine.EngineGUID]*engine.Engine, error) { ret := _m.Called(ctx, filters) + if len(ret) == 0 { + panic("no return value specified for GetEngines") + } + var r0 map[engine.EngineGUID]*engine.Engine var r1 error if rf, ok := ret.Get(0).(func(context.Context, *engine.EngineFilters) (map[engine.EngineGUID]*engine.Engine, error)); ok { @@ -1304,6 +1396,10 @@ func (_c *MockKurtosisBackend_GetEngines_Call) RunAndReturn(run func(context.Con func (_m *MockKurtosisBackend) GetLogsAggregator(ctx context.Context) (*logs_aggregator.LogsAggregator, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetLogsAggregator") + } + var r0 *logs_aggregator.LogsAggregator var r1 error if rf, ok := ret.Get(0).(func(context.Context) (*logs_aggregator.LogsAggregator, error)); ok { @@ -1358,6 +1454,10 @@ func (_c *MockKurtosisBackend_GetLogsAggregator_Call) RunAndReturn(run func(cont func (_m *MockKurtosisBackend) GetLogsCollectorForEnclave(ctx context.Context, enclaveUuid enclave.EnclaveUUID) (*logs_collector.LogsCollector, error) { ret := _m.Called(ctx, enclaveUuid) + if len(ret) == 0 { + panic("no return value specified for GetLogsCollectorForEnclave") + } + var r0 *logs_collector.LogsCollector var r1 error if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID) (*logs_collector.LogsCollector, error)); ok { @@ -1413,6 +1513,10 @@ func (_c *MockKurtosisBackend_GetLogsCollectorForEnclave_Call) RunAndReturn(run func (_m *MockKurtosisBackend) GetReverseProxy(ctx context.Context) (*reverse_proxy.ReverseProxy, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetReverseProxy") + } + var r0 *reverse_proxy.ReverseProxy var r1 error if rf, ok := ret.Get(0).(func(context.Context) (*reverse_proxy.ReverseProxy, error)); ok { @@ -1467,6 +1571,10 @@ func (_c *MockKurtosisBackend_GetReverseProxy_Call) RunAndReturn(run func(contex func (_m *MockKurtosisBackend) GetShellOnUserService(ctx context.Context, enclaveUuid enclave.EnclaveUUID, serviceUuid service.ServiceUUID) error { ret := _m.Called(ctx, enclaveUuid, serviceUuid) + if len(ret) == 0 { + panic("no return value specified for GetShellOnUserService") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID, service.ServiceUUID) error); ok { r0 = rf(ctx, enclaveUuid, serviceUuid) @@ -1511,6 +1619,10 @@ func (_c *MockKurtosisBackend_GetShellOnUserService_Call) RunAndReturn(run func( func (_m *MockKurtosisBackend) GetUserServiceLogs(ctx context.Context, enclaveUuid enclave.EnclaveUUID, filters *service.ServiceFilters, shouldFollowLogs bool) (map[service.ServiceUUID]io.ReadCloser, map[service.ServiceUUID]error, error) { ret := _m.Called(ctx, enclaveUuid, filters, shouldFollowLogs) + if len(ret) == 0 { + panic("no return value specified for GetUserServiceLogs") + } + var r0 map[service.ServiceUUID]io.ReadCloser var r1 map[service.ServiceUUID]error var r2 error @@ -1577,6 +1689,10 @@ func (_c *MockKurtosisBackend_GetUserServiceLogs_Call) RunAndReturn(run func(con func (_m *MockKurtosisBackend) GetUserServices(ctx context.Context, enclaveUuid enclave.EnclaveUUID, filters *service.ServiceFilters) (map[service.ServiceUUID]*service.Service, error) { ret := _m.Called(ctx, enclaveUuid, filters) + if len(ret) == 0 { + panic("no return value specified for GetUserServices") + } + var r0 map[service.ServiceUUID]*service.Service var r1 error if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID, *service.ServiceFilters) (map[service.ServiceUUID]*service.Service, error)); ok { @@ -1633,6 +1749,10 @@ func (_c *MockKurtosisBackend_GetUserServices_Call) RunAndReturn(run func(contex func (_m *MockKurtosisBackend) NixBuild(ctx context.Context, nixBuildSpec *nix_build_spec.NixBuildSpec) (string, error) { ret := _m.Called(ctx, nixBuildSpec) + if len(ret) == 0 { + panic("no return value specified for NixBuild") + } + var r0 string var r1 error if rf, ok := ret.Get(0).(func(context.Context, *nix_build_spec.NixBuildSpec) (string, error)); ok { @@ -1686,6 +1806,10 @@ func (_c *MockKurtosisBackend_NixBuild_Call) RunAndReturn(run func(context.Conte func (_m *MockKurtosisBackend) PruneUnusedImages(ctx context.Context) ([]string, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for PruneUnusedImages") + } + var r0 []string var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]string, error)); ok { @@ -1740,6 +1864,10 @@ func (_c *MockKurtosisBackend_PruneUnusedImages_Call) RunAndReturn(run func(cont func (_m *MockKurtosisBackend) RegisterUserServices(ctx context.Context, enclaveUuid enclave.EnclaveUUID, services map[service.ServiceName]bool) (map[service.ServiceName]*service.ServiceRegistration, map[service.ServiceName]error, error) { ret := _m.Called(ctx, enclaveUuid, services) + if len(ret) == 0 { + panic("no return value specified for RegisterUserServices") + } + var r0 map[service.ServiceName]*service.ServiceRegistration var r1 map[service.ServiceName]error var r2 error @@ -1805,6 +1933,10 @@ func (_c *MockKurtosisBackend_RegisterUserServices_Call) RunAndReturn(run func(c func (_m *MockKurtosisBackend) RemoveRegisteredUserServiceProcesses(ctx context.Context, enclaveUuid enclave.EnclaveUUID, services map[service.ServiceUUID]bool) (map[service.ServiceUUID]bool, map[service.ServiceUUID]error, error) { ret := _m.Called(ctx, enclaveUuid, services) + if len(ret) == 0 { + panic("no return value specified for RemoveRegisteredUserServiceProcesses") + } + var r0 map[service.ServiceUUID]bool var r1 map[service.ServiceUUID]error var r2 error @@ -1870,6 +2002,10 @@ func (_c *MockKurtosisBackend_RemoveRegisteredUserServiceProcesses_Call) RunAndR func (_m *MockKurtosisBackend) RunUserServiceExecCommandWithStreamedOutput(ctx context.Context, enclaveUuid enclave.EnclaveUUID, serviceUuid service.ServiceUUID, cmd []string) (chan string, chan *exec_result.ExecResult, error) { ret := _m.Called(ctx, enclaveUuid, serviceUuid, cmd) + if len(ret) == 0 { + panic("no return value specified for RunUserServiceExecCommandWithStreamedOutput") + } + var r0 chan string var r1 chan *exec_result.ExecResult var r2 error @@ -1932,34 +2068,38 @@ func (_c *MockKurtosisBackend_RunUserServiceExecCommandWithStreamedOutput_Call) return _c } -// RunUserServiceExecCommands provides a mock function with given fields: ctx, enclaveUuid, userServiceCommands -func (_m *MockKurtosisBackend) RunUserServiceExecCommands(ctx context.Context, enclaveUuid enclave.EnclaveUUID, userServiceCommands map[service.ServiceUUID][]string) (map[service.ServiceUUID]*exec_result.ExecResult, map[service.ServiceUUID]error, error) { - ret := _m.Called(ctx, enclaveUuid, userServiceCommands) +// RunUserServiceExecCommands provides a mock function with given fields: ctx, enclaveUuid, containerUser, userServiceCommands +func (_m *MockKurtosisBackend) RunUserServiceExecCommands(ctx context.Context, enclaveUuid enclave.EnclaveUUID, containerUser string, userServiceCommands map[service.ServiceUUID][]string) (map[service.ServiceUUID]*exec_result.ExecResult, map[service.ServiceUUID]error, error) { + ret := _m.Called(ctx, enclaveUuid, containerUser, userServiceCommands) + + if len(ret) == 0 { + panic("no return value specified for RunUserServiceExecCommands") + } var r0 map[service.ServiceUUID]*exec_result.ExecResult var r1 map[service.ServiceUUID]error var r2 error - if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID, map[service.ServiceUUID][]string) (map[service.ServiceUUID]*exec_result.ExecResult, map[service.ServiceUUID]error, error)); ok { - return rf(ctx, enclaveUuid, userServiceCommands) + if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID, string, map[service.ServiceUUID][]string) (map[service.ServiceUUID]*exec_result.ExecResult, map[service.ServiceUUID]error, error)); ok { + return rf(ctx, enclaveUuid, containerUser, userServiceCommands) } - if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID, map[service.ServiceUUID][]string) map[service.ServiceUUID]*exec_result.ExecResult); ok { - r0 = rf(ctx, enclaveUuid, userServiceCommands) + if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID, string, map[service.ServiceUUID][]string) map[service.ServiceUUID]*exec_result.ExecResult); ok { + r0 = rf(ctx, enclaveUuid, containerUser, userServiceCommands) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(map[service.ServiceUUID]*exec_result.ExecResult) } } - if rf, ok := ret.Get(1).(func(context.Context, enclave.EnclaveUUID, map[service.ServiceUUID][]string) map[service.ServiceUUID]error); ok { - r1 = rf(ctx, enclaveUuid, userServiceCommands) + if rf, ok := ret.Get(1).(func(context.Context, enclave.EnclaveUUID, string, map[service.ServiceUUID][]string) map[service.ServiceUUID]error); ok { + r1 = rf(ctx, enclaveUuid, containerUser, userServiceCommands) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(map[service.ServiceUUID]error) } } - if rf, ok := ret.Get(2).(func(context.Context, enclave.EnclaveUUID, map[service.ServiceUUID][]string) error); ok { - r2 = rf(ctx, enclaveUuid, userServiceCommands) + if rf, ok := ret.Get(2).(func(context.Context, enclave.EnclaveUUID, string, map[service.ServiceUUID][]string) error); ok { + r2 = rf(ctx, enclaveUuid, containerUser, userServiceCommands) } else { r2 = ret.Error(2) } @@ -1975,24 +2115,25 @@ type MockKurtosisBackend_RunUserServiceExecCommands_Call struct { // RunUserServiceExecCommands is a helper method to define mock.On call // - ctx context.Context // - enclaveUuid enclave.EnclaveUUID +// - containerUser string // - userServiceCommands map[service.ServiceUUID][]string -func (_e *MockKurtosisBackend_Expecter) RunUserServiceExecCommands(ctx interface{}, enclaveUuid interface{}, userServiceCommands interface{}) *MockKurtosisBackend_RunUserServiceExecCommands_Call { - return &MockKurtosisBackend_RunUserServiceExecCommands_Call{Call: _e.mock.On("RunUserServiceExecCommands", ctx, enclaveUuid, userServiceCommands)} +func (_e *MockKurtosisBackend_Expecter) RunUserServiceExecCommands(ctx interface{}, enclaveUuid interface{}, containerUser interface{}, userServiceCommands interface{}) *MockKurtosisBackend_RunUserServiceExecCommands_Call { + return &MockKurtosisBackend_RunUserServiceExecCommands_Call{Call: _e.mock.On("RunUserServiceExecCommands", ctx, enclaveUuid, containerUser, userServiceCommands)} } -func (_c *MockKurtosisBackend_RunUserServiceExecCommands_Call) Run(run func(ctx context.Context, enclaveUuid enclave.EnclaveUUID, userServiceCommands map[service.ServiceUUID][]string)) *MockKurtosisBackend_RunUserServiceExecCommands_Call { +func (_c *MockKurtosisBackend_RunUserServiceExecCommands_Call) Run(run func(ctx context.Context, enclaveUuid enclave.EnclaveUUID, containerUser string, userServiceCommands map[service.ServiceUUID][]string)) *MockKurtosisBackend_RunUserServiceExecCommands_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(enclave.EnclaveUUID), args[2].(map[service.ServiceUUID][]string)) + run(args[0].(context.Context), args[1].(enclave.EnclaveUUID), args[2].(string), args[3].(map[service.ServiceUUID][]string)) }) return _c } -func (_c *MockKurtosisBackend_RunUserServiceExecCommands_Call) Return(succesfulUserServiceExecResults map[service.ServiceUUID]*exec_result.ExecResult, erroredUserServiceUuids map[service.ServiceUUID]error, resultErr error) *MockKurtosisBackend_RunUserServiceExecCommands_Call { - _c.Call.Return(succesfulUserServiceExecResults, erroredUserServiceUuids, resultErr) +func (_c *MockKurtosisBackend_RunUserServiceExecCommands_Call) Return(successfulUserServiceExecResults map[service.ServiceUUID]*exec_result.ExecResult, erroredUserServiceUuids map[service.ServiceUUID]error, resultErr error) *MockKurtosisBackend_RunUserServiceExecCommands_Call { + _c.Call.Return(successfulUserServiceExecResults, erroredUserServiceUuids, resultErr) return _c } -func (_c *MockKurtosisBackend_RunUserServiceExecCommands_Call) RunAndReturn(run func(context.Context, enclave.EnclaveUUID, map[service.ServiceUUID][]string) (map[service.ServiceUUID]*exec_result.ExecResult, map[service.ServiceUUID]error, error)) *MockKurtosisBackend_RunUserServiceExecCommands_Call { +func (_c *MockKurtosisBackend_RunUserServiceExecCommands_Call) RunAndReturn(run func(context.Context, enclave.EnclaveUUID, string, map[service.ServiceUUID][]string) (map[service.ServiceUUID]*exec_result.ExecResult, map[service.ServiceUUID]error, error)) *MockKurtosisBackend_RunUserServiceExecCommands_Call { _c.Call.Return(run) return _c } @@ -2001,6 +2142,10 @@ func (_c *MockKurtosisBackend_RunUserServiceExecCommands_Call) RunAndReturn(run func (_m *MockKurtosisBackend) StartRegisteredUserServices(ctx context.Context, enclaveUuid enclave.EnclaveUUID, services map[service.ServiceUUID]*service.ServiceConfig) (map[service.ServiceUUID]*service.Service, map[service.ServiceUUID]error, error) { ret := _m.Called(ctx, enclaveUuid, services) + if len(ret) == 0 { + panic("no return value specified for StartRegisteredUserServices") + } + var r0 map[service.ServiceUUID]*service.Service var r1 map[service.ServiceUUID]error var r2 error @@ -2066,6 +2211,10 @@ func (_c *MockKurtosisBackend_StartRegisteredUserServices_Call) RunAndReturn(run func (_m *MockKurtosisBackend) StopAPIContainers(ctx context.Context, filters *api_container.APIContainerFilters) (map[enclave.EnclaveUUID]bool, map[enclave.EnclaveUUID]error, error) { ret := _m.Called(ctx, filters) + if len(ret) == 0 { + panic("no return value specified for StopAPIContainers") + } + var r0 map[enclave.EnclaveUUID]bool var r1 map[enclave.EnclaveUUID]error var r2 error @@ -2130,6 +2279,10 @@ func (_c *MockKurtosisBackend_StopAPIContainers_Call) RunAndReturn(run func(cont func (_m *MockKurtosisBackend) StopEnclaves(ctx context.Context, filters *enclave.EnclaveFilters) (map[enclave.EnclaveUUID]bool, map[enclave.EnclaveUUID]error, error) { ret := _m.Called(ctx, filters) + if len(ret) == 0 { + panic("no return value specified for StopEnclaves") + } + var r0 map[enclave.EnclaveUUID]bool var r1 map[enclave.EnclaveUUID]error var r2 error @@ -2194,6 +2347,10 @@ func (_c *MockKurtosisBackend_StopEnclaves_Call) RunAndReturn(run func(context.C func (_m *MockKurtosisBackend) StopEngines(ctx context.Context, filters *engine.EngineFilters) (map[engine.EngineGUID]bool, map[engine.EngineGUID]error, error) { ret := _m.Called(ctx, filters) + if len(ret) == 0 { + panic("no return value specified for StopEngines") + } + var r0 map[engine.EngineGUID]bool var r1 map[engine.EngineGUID]error var r2 error @@ -2258,6 +2415,10 @@ func (_c *MockKurtosisBackend_StopEngines_Call) RunAndReturn(run func(context.Co func (_m *MockKurtosisBackend) StopUserServices(ctx context.Context, enclaveUuid enclave.EnclaveUUID, filters *service.ServiceFilters) (map[service.ServiceUUID]bool, map[service.ServiceUUID]error, error) { ret := _m.Called(ctx, enclaveUuid, filters) + if len(ret) == 0 { + panic("no return value specified for StopUserServices") + } + var r0 map[service.ServiceUUID]bool var r1 map[service.ServiceUUID]error var r2 error @@ -2323,6 +2484,10 @@ func (_c *MockKurtosisBackend_StopUserServices_Call) RunAndReturn(run func(conte func (_m *MockKurtosisBackend) UnregisterUserServices(ctx context.Context, enclaveUuid enclave.EnclaveUUID, services map[service.ServiceUUID]bool) (map[service.ServiceUUID]bool, map[service.ServiceUUID]error, error) { ret := _m.Called(ctx, enclaveUuid, services) + if len(ret) == 0 { + panic("no return value specified for UnregisterUserServices") + } + var r0 map[service.ServiceUUID]bool var r1 map[service.ServiceUUID]error var r2 error @@ -2388,6 +2553,10 @@ func (_c *MockKurtosisBackend_UnregisterUserServices_Call) RunAndReturn(run func func (_m *MockKurtosisBackend) UpdateEnclave(ctx context.Context, enclaveUuid enclave.EnclaveUUID, newName string, creationTime *time.Time) error { ret := _m.Called(ctx, enclaveUuid, newName, creationTime) + if len(ret) == 0 { + panic("no return value specified for UpdateEnclave") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, enclave.EnclaveUUID, string, *time.Time) error); ok { r0 = rf(ctx, enclaveUuid, newName, creationTime) diff --git a/core/server/api_container/server/service_network/default_service_network.go b/core/server/api_container/server/service_network/default_service_network.go index f0f46916c6..64eea71e21 100644 --- a/core/server/api_container/server/service_network/default_service_network.go +++ b/core/server/api_container/server/service_network/default_service_network.go @@ -10,12 +10,6 @@ import ( "compress/gzip" "context" "fmt" - "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/exec_result" - "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/database_accessors/enclave_db" - "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/database_accessors/enclave_db/service_registration" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network/render_templates" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network/service_identifiers" - "github.com/kurtosis-tech/kurtosis/path-compression" "io" "net" "net/http" @@ -25,6 +19,13 @@ import ( "sync" "time" + "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/exec_result" + "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/database_accessors/enclave_db" + "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/database_accessors/enclave_db/service_registration" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network/render_templates" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network/service_identifiers" + "github.com/kurtosis-tech/kurtosis/path-compression" + "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/enclave" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/port_spec" @@ -577,7 +578,7 @@ func (network *DefaultServiceNetwork) RunExec(ctx context.Context, serviceIdenti } successfulExecCommands, failedExecCommands, err := network.kurtosisBackend.RunUserServiceExecCommands( - ctx, network.enclaveUuid, userServiceCommands) + ctx, network.enclaveUuid, "", userServiceCommands) if err != nil { return nil, stacktrace.Propagate( err, @@ -620,7 +621,7 @@ func (network *DefaultServiceNetwork) RunExecs(ctx context.Context, userServiceC userServiceCommandsByServiceUuid[serviceUuid] = userServiceCommand } - successfulExecs, failedExecs, err := network.kurtosisBackend.RunUserServiceExecCommands(ctx, network.enclaveUuid, userServiceCommandsByServiceUuid) + successfulExecs, failedExecs, err := network.kurtosisBackend.RunUserServiceExecCommands(ctx, network.enclaveUuid, "", userServiceCommandsByServiceUuid) if err != nil { return nil, nil, stacktrace.Propagate(err, "An unexpected error occurred running multiple exec commands "+ "on user services:\n%v", userServiceCommands) diff --git a/docs/docs/cli-reference/service-exec.md b/docs/docs/cli-reference/service-exec.md index c890c34553..27b7041a3d 100644 --- a/docs/docs/cli-reference/service-exec.md +++ b/docs/docs/cli-reference/service-exec.md @@ -7,11 +7,13 @@ slug: /service-exec To run a specific shell command inside a service container, run: ```bash -kurtosis service exec $THE_ENCLAVE_IDENTIFIER $THE_SERVICE_IDENTIFIER 'COMMAND' +kurtosis service exec [--user $CONTAINER_USER] $THE_ENCLAVE_IDENTIFIER $THE_SERVICE_IDENTIFIER 'COMMAND' ``` where `$THE_ENCLAVE_IDENTIFIER` and the `$THE_SERVICE_IDENTIFIER` are [resource identifiers](../advanced-concepts/resource-identifier.md) for the enclave and service, respectively. +Optionally pass `--user` flag to `exec` with $CONTAINER_USER, to execute the command on the container as that user. This only works for the docker case, the kubernetes case will fail if used. Omitting `--user` will default to `root`. + The specified command should be appropriately quoted and will be passed as it is to the shell interpreter of the running service container. If the command returns a non-zero exit code, Kurtosis CLI will print an error and also return a non-zero exit code.