From 400f08b317f1c8db0495939d4e1aacf64a4ed53c Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 15 Feb 2024 15:43:22 -0500 Subject: [PATCH 01/75] setup plan yaml generator --- .../startosis_engine/plan_yaml_generator.go | 134 ++++++++++++++++++ .../plan_yaml_generator_test.go | 96 +++++++++++++ .../startosis_engine/startosis_runner.go | 10 ++ 3 files changed, 240 insertions(+) create mode 100644 core/server/api_container/server/startosis_engine/plan_yaml_generator.go create mode 100644 core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go new file mode 100644 index 0000000000..a4728b056e --- /dev/null +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -0,0 +1,134 @@ +package startosis_engine + +import "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan" + +const ( + TCP ApplicationProtocol = "TCP" + UDP ApplicationProtocol = "UDP" + + SHELL TaskType = "sh" + PYTHON TaskType = "python" +) + +// we need the package id and the args, the args need to be filled in +// how to represent dependencies within the yaml??? +// say a service config refers to another files artifact +// the conversions are +// add_service -> use service config and returned info to create a ServiceObject +// remove_service -> remove that from the plan representation +// upload_files -> FilesArtifact +// render_template -> FilesArtifact +// run_sh -> Task but returns a files artifact so create that +// run_python -> Task but returns a files artifact so create that + +// go through all the kurtosis builtins and figure out which ones we need to accommodate for +// +// PlanYamlGenerator generates a yaml representation of a [plan]. +type PlanYamlGenerator interface { + // GenerateYaml converts [plan] into a byte array that represents a yaml with information in the plan. + // The format of the yaml in the byte array is as such: + // + // + // + // packageId: github.com/kurtosis-tech/postgres-package + // + // services: + // - uuid: + // - name: + // service_config: + // image: + // env_var: + // ... + // + // + // files_artifacts: + // + // + // + // + // + // + // tasks: + // + // + // + // + // + // + GenerateYaml(plan instructions_plan.InstructionsPlan) ([]byte, error) +} + +type PlanYamlGeneratorImpl struct { + plan *instructions_plan.InstructionsPlan + + componentIndex map[string]bool + + services []*Service + + filesArtifacts []*FilesArtifact + + tasks []*Task +} + +func NewPlanYamlGenerator(plan *instructions_plan.InstructionsPlan) *PlanYamlGeneratorImpl { + return &PlanYamlGeneratorImpl{ + plan: plan, + } +} + +func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { + // first thing: get list of instructions + // second thing: iterate through list of instructions + // depending on type of instruction, update the plan + // at the very end, convert the plan into a yaml + return []byte{}, nil +} + +type Service struct { + uuid string + name string + image string + envVars []*EnvironmentVariable + ports []*Port + files []*FileMount +} + +type FilesArtifact struct { + uuid string + name string + files map[string]string +} + +type EnvironmentVariable struct { + key string + value string +} + +type Port struct { + portName string + portNum uint16 + transportProtocol ApplicationProtocol +} + +type ApplicationProtocol string + +type FileMount struct { + mountPath string + + filesArtifactUuid string + filesArtifactName string +} + +type Task struct { + taskType TaskType + name string + command string + image string + envVar []*EnvironmentVariable + files []*FileMount + store []string + shouldWait bool + wait string +} + +type TaskType string diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go new file mode 100644 index 0000000000..229ca1a57f --- /dev/null +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -0,0 +1,96 @@ +package startosis_engine + +import ( + "context" + "fmt" + "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/service" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/shared_helpers" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + "testing" +) + +type PlanYamlGeneratorTestSuite struct { + suite.Suite + serviceNetwork *service_network.MockServiceNetwork + packageContentProvider *mock_package_content_provider.MockPackageContentProvider + runtimeValueStore *runtime_value_store.RuntimeValueStore + + interpreter *StartosisInterpreter +} + +func (suite *PlanYamlGeneratorTestSuite) SetupTest() { + suite.packageContentProvider = mock_package_content_provider.NewMockPackageContentProvider() + enclaveDb := getEnclaveDBForTest(suite.T()) + + dummySerde := shared_helpers.NewDummyStarlarkValueSerDeForTest() + + runtimeValueStore, err := runtime_value_store.CreateRuntimeValueStore(dummySerde, enclaveDb) + require.NoError(suite.T(), err) + suite.runtimeValueStore = runtimeValueStore + suite.serviceNetwork = service_network.NewMockServiceNetwork(suite.T()) + + suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "") + + service.NewServiceRegistration( + testServiceName, + service.ServiceUUID(fmt.Sprintf("%s-%s", testServiceName, serviceUuidSuffix)), + mockEnclaveUuid, + testServiceIpAddress, + string(testServiceName), + ) + suite.serviceNetwork.EXPECT().GetUniqueNameForFileArtifact().Maybe().Return(mockFileArtifactName, nil) + suite.serviceNetwork.EXPECT().GetEnclaveUuid().Maybe().Return(enclave.EnclaveUUID(mockEnclaveUuid)) + suite.serviceNetwork.EXPECT().ExistServiceRegistration(testServiceName).Maybe().Return(true, nil) +} + +func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { + suite.Run(t, new(PlanYamlGeneratorTestSuite)) +} + +func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { + suite.packageContentProvider.RemoveAll() +} + +func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGenerator() { + script := ` +service_name = "example-datastore-server" +ports = [1323, 1324, 1325] + +def deploy_datastore_services(plan): + for i in range(len(ports)): + unique_service_name = service_name + "-" + str(i) + plan.print("Adding service " + unique_service_name) + config = ServiceConfig( + image = "` + testContainerImageName + `", + ports = { + "grpc": PortSpec( + number = ports[i], + transport_protocol = "TCP" + ) + } + ) + + plan.add_service(name = unique_service_name, config = config) + +def run(plan): + plan.print("Starting Startosis script!") + deploy_datastore_services(plan) + plan.print("Done!") +` + + _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, useDefaultMainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, script, startosis_constants.EmptyInputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 8, instructionsPlan.Size()) + + pyg := NewPlanYamlGenerator(instructionsPlan) + yamlBytes, err := pyg.GenerateYaml() + require.NoError(suite.T(), err) + + require.Equal(suite.T(), yamlBytes, []byte{}) +} diff --git a/core/server/api_container/server/startosis_engine/startosis_runner.go b/core/server/api_container/server/startosis_engine/startosis_runner.go index dd13197c73..f3db65d0b4 100644 --- a/core/server/api_container/server/startosis_engine/startosis_runner.go +++ b/core/server/api_container/server/startosis_engine/startosis_runner.go @@ -164,6 +164,16 @@ func (runner *StartosisRunner) Run( startingExecutionMsg, defaultCurrentStepNumber, totalNumberOfInstructions) starlarkRunResponseLines <- progressInfo + if dryRun { + pyg := NewPlanYamlGenerator(instructionsPlan) + planYaml, err := pyg.GenerateYaml() + if err != nil { + starlarkRunResponseLines <- binding_constructors.NewStarlarkRunResponseLineFromWarning(err.Error()) + } + starlarkRunResponseLines <- binding_constructors.NewStarlarkRunResponseLineFromInfoMsg(string(planYaml)) + return + } + executionResponseLinesChan := runner.startosisExecutor.Execute(ctx, dryRun, parallelism, instructionsPlan.GetIndexOfFirstInstruction(), instructionsSequence, serializedScriptOutput) if isRunFinished, isRunSuccessful := forwardKurtosisResponseLineChannelUntilSourceIsClosed(executionResponseLinesChan, starlarkRunResponseLines); !isRunFinished { logrus.Warnf("Execution finished but no 'RunFinishedEvent' was received through the stream. This is unexpected as every execution should be terminal.") From ffdf6cc1fe7b90aa49541c884e33c19efd20d7e2 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 15 Feb 2024 17:53:13 -0500 Subject: [PATCH 02/75] checkpoint --- .../server/api_container_service.go | 11 +- .../startosis_engine/plan_yaml_generator.go | 145 ++++++--- .../plan_yaml_generator_test.go | 287 +++++++++++++++++- 3 files changed, 390 insertions(+), 53 deletions(-) diff --git a/core/server/api_container/server/api_container_service.go b/core/server/api_container/server/api_container_service.go index 74d8bb5f2b..1a7ad86e3c 100644 --- a/core/server/api_container/server/api_container_service.go +++ b/core/server/api_container/server/api_container_service.go @@ -260,7 +260,7 @@ func (apicService *ApiContainerService) RunStarlarkPackage(args *kurtosis_core_r mainFuncName := args.GetMainFunctionName() ApiDownloadMode := shared_utils.GetOrDefault(args.ImageDownloadMode, defaultImageDownloadMode) downloadMode := convertFromImageDownloadModeAPI(ApiDownloadMode) - nonBlockignMode := args.GetNonBlockingMode() + nonBlockingMode := args.GetNonBlockingMode() var scriptWithRunFunction string var interpretationError *startosis_errors.InterpretationError @@ -293,7 +293,14 @@ func (apicService *ApiContainerService) RunStarlarkPackage(args *kurtosis_core_r if metricsErr != nil { logrus.Warn("An error occurred tracking kurtosis run event") } - apicService.runStarlark(parallelism, dryRun, detectedPackageId, detectedPackageReplaceOptions, mainFuncName, actualRelativePathToMainFile, scriptWithRunFunction, serializedParams, downloadMode, nonBlockignMode, args.ExperimentalFeatures, stream) + + logrus.Infof("package id: %v\n main func name: %v\n actual relative path to main file: %v\n script with run func: %v\n serialized params:%v\n%v", + detectedPackageId, + mainFuncName, + actualRelativePathToMainFile, + scriptWithRunFunction, + serializedParams) + apicService.runStarlark(parallelism, dryRun, detectedPackageId, detectedPackageReplaceOptions, mainFuncName, actualRelativePathToMainFile, scriptWithRunFunction, serializedParams, downloadMode, nonBlockingMode, args.ExperimentalFeatures, stream) apicService.starlarkRun = &kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse{ PackageId: packageIdFromArgs, diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index a4728b056e..78a0cc4e52 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -1,6 +1,10 @@ package startosis_engine -import "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan" +import ( + "github.com/go-yaml/yaml" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service" +) const ( TCP ApplicationProtocol = "TCP" @@ -10,19 +14,22 @@ const ( PYTHON TaskType = "python" ) -// we need the package id and the args, the args need to be filled in -// how to represent dependencies within the yaml??? +// We need the package id and the args, the args need to be filled in +// the instructions likely come with the args filled in already, but what if no args are passed in? are they left as variables? + +// How to represent dependencies within the yaml??? // say a service config refers to another files artifact -// the conversions are + +// some conversions are: // add_service -> use service config and returned info to create a ServiceObject // remove_service -> remove that from the plan representation // upload_files -> FilesArtifact // render_template -> FilesArtifact // run_sh -> Task but returns a files artifact so create that // run_python -> Task but returns a files artifact so create that - -// go through all the kurtosis builtins and figure out which ones we need to accommodate for // +// go through all the kurtosis builtins and figure out which ones we need to accommodate for and which ones we don't need to accomodate for + // PlanYamlGenerator generates a yaml representation of a [plan]. type PlanYamlGenerator interface { // GenerateYaml converts [plan] into a byte array that represents a yaml with information in the plan. @@ -51,84 +58,122 @@ type PlanYamlGenerator interface { // tasks: // // - // - // - // - // + GenerateYaml(plan instructions_plan.InstructionsPlan) ([]byte, error) } type PlanYamlGeneratorImpl struct { + // Plan generetated by an interpretation of a starlark script of package plan *instructions_plan.InstructionsPlan - componentIndex map[string]bool - - services []*Service - - filesArtifacts []*FilesArtifact - - tasks []*Task + // Representation of plan in yaml the plan is being processed, the yaml gets updated + planYaml *PlanYaml } func NewPlanYamlGenerator(plan *instructions_plan.InstructionsPlan) *PlanYamlGeneratorImpl { return &PlanYamlGeneratorImpl{ - plan: plan, + plan: plan, + planYaml: &PlanYaml{}, } } func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { - // first thing: get list of instructions - // second thing: iterate through list of instructions - // depending on type of instruction, update the plan - // at the very end, convert the plan into a yaml - return []byte{}, nil + instructionsSequence, err := pyg.plan.GeneratePlan() + if err != nil { + return nil, err + } + + // iterate over the sequence of instructions + for _, scheduledInstruction := range instructionsSequence { + // based on the instruction, update the plan yaml representation accordingly + switch getBuiltinNameFromInstruction(scheduledInstruction) { + case add_service.AddServiceBuiltinName: + pyg.updatePlanYamlFromAddService(scheduledInstruction) + default: + return nil, nil + } + } + + // at the very end, convert the plan yaml representation into a yaml + return convertPlanYamlToYaml(pyg.planYaml) +} + +func convertPlanYamlToYaml(planYaml *PlanYaml) ([]byte, error) { + yamlBytes, err := yaml.Marshal(planYaml) + if err != nil { + return []byte{}, err + } + return yamlBytes, nil +} + +func getBuiltinNameFromInstruction(instruction *instructions_plan.ScheduledInstruction) string { + return instruction.GetInstruction().GetCanonicalInstruction(false).GetInstructionName() } +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruction *instructions_plan.ScheduledInstruction) { + +} + +type PlanYaml struct { + PackageId string `yaml:"packageId,omitempty"` + Services []*Service `yaml:"services,omitempty"` + FilesArtifacts []*FilesArtifact `yaml:"filesArtifacts,omitempty"` + Tasks []*Task `yaml:"tasks,omitempty"` +} + +// Service represents a service in the system. type Service struct { - uuid string - name string - image string - envVars []*EnvironmentVariable - ports []*Port - files []*FileMount + Uuid string `yaml:"uuid,omitempty"` + Name string `yaml:"name,omitempty"` + Image string `yaml:"image,omitempty"` + EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` + Ports []*Port `yaml:"ports,omitempty"` + Files []*FileMount `yaml:"files,omitempty"` } +// FilesArtifact represents a collection of files. type FilesArtifact struct { - uuid string - name string - files map[string]string + Uuid string `yaml:"uuid,omitempty"` + Name string `yaml:"name,omitempty"` + Files map[string]string `yaml:"files,omitempty"` } +// EnvironmentVariable represents an environment variable. type EnvironmentVariable struct { - key string - value string + Key string `yaml:"key,omitempty"` + Value string `yaml:"value,omitempty"` } +// Port represents a port. type Port struct { - portName string - portNum uint16 - transportProtocol ApplicationProtocol + TransportProtocol ApplicationProtocol `yaml:"transportProtocol,omitempty"` + + PortName string `yaml:"portName,omitempty"` + PortNum uint16 `yaml:"portNum,omitempty"` } +// ApplicationProtocol represents the application protocol used. type ApplicationProtocol string +// FileMount represents a mount point for files. type FileMount struct { - mountPath string - - filesArtifactUuid string - filesArtifactName string + MountPath string `yaml:"mountPath,omitempty"` + FilesArtifactUuid string `yaml:"filesArtifactUuid,omitempty"` + FilesArtifactName string `yaml:"filesArtifactName,omitempty"` } +// Task represents a task to be executed. type Task struct { - taskType TaskType - name string - command string - image string - envVar []*EnvironmentVariable - files []*FileMount - store []string - shouldWait bool - wait string + TaskType TaskType `yaml:"taskType,omitempty"` + Name string `yaml:"name,omitempty"` + Command string `yaml:"command,omitempty"` + Image string `yaml:"image,omitempty"` + EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` + Files []*FileMount `yaml:"files,omitempty"` + Store []string `yaml:"store,omitempty"` + ShouldWait bool `yaml:"shouldWait,omitempty"` + Wait string `yaml:"wait,omitempty"` } +// TaskType represents the type of task. type TaskType string diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 229ca1a57f..259e4b817a 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -57,7 +57,44 @@ func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() } -func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGenerator() { +func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorVerySimpleScript() { + script := ` +def run(plan): + + service_name = "%v" + + config = ServiceConfig( + image = "` + testContainerImageName + `", + ports = { + "grpc": PortSpec(number = 1323, transport_protocol = "TCP", application_protocol = "http") + }, + ) + datastore_service = plan.add_service(name = service_name, config = config) +` + + _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, useDefaultMainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, script, startosis_constants.EmptyInputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 1, instructionsPlan.Size()) + + pyg := NewPlanYamlGenerator(instructionsPlan) + yamlBytes, err := pyg.GenerateYaml() + require.NoError(suite.T(), err) + + expectedYamlString := + ` +packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT +services: + name: + image: kurtosistech/example-datastore-server + ports: + name: grpc + transportProtocol: TCP + number: 1323 +` + require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) +} + +func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorSimpleScript() { script := ` service_name = "example-datastore-server" ports = [1323, 1324, 1325] @@ -94,3 +131,251 @@ def run(plan): require.Equal(suite.T(), yamlBytes, []byte{}) } + +func TestConvertPlanYamlToYamlBytes(t *testing.T) { + PackageId := "github.com/kurtosis-tech/postgres-package" + + services := []*Service{ + { + Name: "tedi", + Uuid: "uuid", + Image: "postgres:alpine", + EnvVars: []*EnvironmentVariable{ + { + Key: "kevin", + Value: "dag", + }, + }, + }, + { + Name: "kaleb", + Uuid: "uuid", + Image: "postgres:alpine", + EnvVars: []*EnvironmentVariable{ + { + Key: "kevin", + Value: "dag", + }, + }, + }, + } + filesArtifacts := []*FilesArtifact{ + { + Uuid: "something", + Name: "something", + Files: nil, + }, + } + tasks := []*Task{ + { + TaskType: PYTHON, + Name: "updateSomething", + Command: "do something", + Image: "jqcurl", + EnvVars: []*EnvironmentVariable{}, + }, + } + + planYaml := PlanYaml{ + PackageId: PackageId, + Services: services, + FilesArtifacts: filesArtifacts, + Tasks: tasks, + } + + yamlBytes, err := convertPlanYamlToYaml(&planYaml) + require.NoError(t, err) + require.Equal(t, "", string(yamlBytes)) +} + +//func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorPostgresPackage() { +// packageId := "github.com/kurtosis-tech/postgres-package" +// mainFunctionName := "" +// relativePathToMainFile := "main.star" +// serializedStarlark := +// `adminer_module = import_module("github.com/bharath-123/db-adminer-package/main.star") +//PORT_NAME = "postgresql" +//APPLICATION_PROTOCOL = "postgresql" +//PG_DRIVER = "pgsql" +// +//CONFIG_FILE_MOUNT_DIRPATH = "/config" +//SEED_FILE_MOUNT_PATH = "/docker-entrypoint-initdb.d" +//DATA_DIRECTORY_PATH = "/data/" +// +//CONFIG_FILENAME = "postgresql.conf" # Expected to be in the artifact +// +//POSTGRES_MIN_CPU = 10 +//POSTGRES_MAX_CPU = 1000 +//POSTGRES_MIN_MEMORY = 32 +//POSTGRES_MAX_MEMORY = 1024 +// +// def run( +// plan, +// image="postgres:alpine", +// service_name="postgres", +// user="postgres", +// password="MyPassword1!", +// database="postgres", +// config_file_artifact_name="", +// seed_file_artifact_name="", +// extra_configs=[], +// persistent=True, +// launch_adminer=False, +// min_cpu=POSTGRES_MIN_CPU, +// max_cpu=POSTGRES_MAX_CPU, +// min_memory=POSTGRES_MIN_MEMORY, +// max_memory=POSTGRES_MAX_MEMORY, +// node_selectors=None, +// ): +// """Launches a Postgresql database instance, optionally seeding it with a SQL file script +// +// Args: +// image (string): The container image that the Postgres service will be started with +// service_name (string): The name to give the Postgres service +// user (string): The user to create the Postgres database with +// password (string): The password to give to the created user +// database (string): The name of the database to create +// config_file_artifact_name (string): The name of a files artifact that contains a Postgres config file in it +// If not empty, this will be used to configure the Postgres server +// seed_file_artifact_name (string): The name of a files artifact containing seed data +// If not empty, the Postgres server will be populated with the data upon start +// extra_configs (list[string]): Each argument gets passed as a '-c' argument to the Postgres server +// persistent (bool): Whether the data should be persisted. Defaults to True; Note that this isn't supported on multi node k8s cluster as of 2023-10-16 +// launch_adminer (bool): Whether to launch adminer which launches a website to inspect postgres database entries. Defaults to False. +// min_cpu (int): Define how much CPU millicores the service should be assigned at least. +// max_cpu (int): Define how much CPU millicores the service should be assign max. +// min_memory (int): Define how much MB of memory the service should be assigned at least. +// max_memory (int): Define how much MB of memory the service should be assigned max. +// node_selectors (dict[string, string]): Define a dict of node selectors - only works in kubernetes example: {"kubernetes.io/hostname": node-name-01} +// Returns: +// An object containing useful information about the Postgres database running inside the enclave: +// { +// "database": "postgres", +// "password": "MyPassword1!", +// "port": { +// "application_protocol": "postgresql", +// "number": 5432, +// "transport_protocol": "TCP", +// "wait": "2m0s" +// }, +// "service": { +// "hostname": "postgres", +// "ip_address": "172.16.0.4", +// "name": "postgres", +// "ports": { +// "postgresql": { +// "application_protocol": "postgresql", +// "number": 5432, +// "transport_protocol": "TCP", +// "wait": "2m0s" +// } +// } +// }, +// "url": "postgresql://postgres:MyPassword1!@postgres/postgres", +// "user": "postgres" +// } +// """ +// cmd = [] +// files = {} +// env_vars = { +// "POSTGRES_DB": database, +// "POSTGRES_USER": user, +// "POSTGRES_PASSWORD": password, +// } +// +// if persistent: +// files[DATA_DIRECTORY_PATH] = Directory( +// persistent_key= "data-{0}".format(service_name), +// ) +// env_vars["PGDATA"] = DATA_DIRECTORY_PATH + "/pgdata" +// if node_selectors == None: +// node_selectors = {} +// if config_file_artifact_name != "": +// config_filepath = CONFIG_FILE_MOUNT_DIRPATH + "/" + CONFIG_FILENAME +// cmd += ["-c", "config_file=" + config_filepath] +// files[CONFIG_FILE_MOUNT_DIRPATH] = config_file_artifact_name +// +// # append cmd with postgres config overrides passed by users +// if len(extra_configs) > 0: +// for config in extra_configs: +// cmd += ["-c", config] +// +// if seed_file_artifact_name != "": +// files[SEED_FILE_MOUNT_PATH] = seed_file_artifact_name +// +// postgres_service = plan.add_service( +// name=service_name, +// config=ServiceConfig( +// image=image, +// ports={ +// PORT_NAME: PortSpec( +// number=5432, +// application_protocol=APPLICATION_PROTOCOL, +// ) +// }, +// cmd=cmd, +// files=files, +// env_vars=env_vars, +// min_cpu=min_cpu, +// max_cpu=max_cpu, +// min_memory=min_memory, +// max_memory=max_memory, +// node_selectors=node_selectors, +// ), +// ) +// +// if launch_adminer: +// adminer = adminer_module.run( +// plan, +// default_db=database, +// default_driver=PG_DRIVER, +// default_password=password, +// default_server=postgres_service.hostname, +// default_username=user, +// ) +// +// url = "{protocol}://{user}:{password}@{hostname}/{database}".format( +// protocol=APPLICATION_PROTOCOL, +// user=user, +// password=password, +// hostname=postgres_service.hostname, +// database=database, +// ) +// +// return struct( +// url=url, +// service=postgres_service, +// port=postgres_service.ports[PORT_NAME], +// user=user, +// password=password, +// database=database, +// min_cpu=min_cpu, +// max_cpu=max_cpu, +// min_memory=min_memory, +// max_memory=max_memory, +// node_selectors=node_selectors, +// ) +// +// def run_query(plan, service, user, password, database, query): +// url = "{protocol}://{user}:{password}@{hostname}/{database}".format( +// protocol=APPLICATION_PROTOCOL, +// user=user, +// password=password, +// hostname=service.hostname, +// database=database, +// ) +// return plan.exec( +// service.name, recipe=ExecRecipe(command=["psql", url, "-c", query]) +// ) +//` +// serializedJsonParams := "" +// _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedStarlark, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) +// require.Nil(suite.T(), interpretationError) +// require.Equal(suite.T(), 8, instructionsPlan.Size()) +// +// //pyg := NewPlanYamlGenerator(instructionsPlan) +// //yamlBytes, err := pyg.GenerateYaml() +// //require.NoError(suite.T(), err) +// // +// //require.Equal(suite.T(), yamlBytes, []byte{}) +//} From d22b7d2398a3a360492cc877b4df03b6dadc8e14 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 15 Feb 2024 18:03:38 -0500 Subject: [PATCH 03/75] add scaffolding --- .../server/startosis_engine/plan_yaml.go | 73 ++++++++++++++ .../startosis_engine/plan_yaml_generator.go | 99 ++++++------------- 2 files changed, 101 insertions(+), 71 deletions(-) create mode 100644 core/server/api_container/server/startosis_engine/plan_yaml.go diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go new file mode 100644 index 0000000000..d295e5a779 --- /dev/null +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -0,0 +1,73 @@ +package startosis_engine + +const ( + TCP ApplicationProtocol = "TCP" + UDP ApplicationProtocol = "UDP" + + SHELL TaskType = "sh" + PYTHON TaskType = "python" +) + +type PlanYaml struct { + PackageId string `yaml:"packageId,omitempty"` + Services []*Service `yaml:"services,omitempty"` + FilesArtifacts []*FilesArtifact `yaml:"filesArtifacts,omitempty"` + Tasks []*Task `yaml:"tasks,omitempty"` +} + +// Service represents a service in the system. +type Service struct { + Uuid string `yaml:"uuid,omitempty"` + Name string `yaml:"name,omitempty"` + Image string `yaml:"image,omitempty"` + EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` + Ports []*Port `yaml:"ports,omitempty"` + Files []*FileMount `yaml:"files,omitempty"` +} + +// FilesArtifact represents a collection of files. +type FilesArtifact struct { + Uuid string `yaml:"uuid,omitempty"` + Name string `yaml:"name,omitempty"` + Files map[string]string `yaml:"files,omitempty"` +} + +// EnvironmentVariable represents an environment variable. +type EnvironmentVariable struct { + Key string `yaml:"key,omitempty"` + Value string `yaml:"value,omitempty"` +} + +// Port represents a port. +type Port struct { + TransportProtocol ApplicationProtocol `yaml:"transportProtocol,omitempty"` + + PortName string `yaml:"portName,omitempty"` + PortNum uint16 `yaml:"portNum,omitempty"` +} + +// ApplicationProtocol represents the application protocol used. +type ApplicationProtocol string + +// FileMount represents a mount point for files. +type FileMount struct { + MountPath string `yaml:"mountPath,omitempty"` + FilesArtifactUuid string `yaml:"filesArtifactUuid,omitempty"` + FilesArtifactName string `yaml:"filesArtifactName,omitempty"` +} + +// Task represents a task to be executed. +type Task struct { + TaskType TaskType `yaml:"taskType,omitempty"` + Name string `yaml:"name,omitempty"` + Command string `yaml:"command,omitempty"` + Image string `yaml:"image,omitempty"` + EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` + Files []*FileMount `yaml:"files,omitempty"` + Store []string `yaml:"store,omitempty"` + ShouldWait bool `yaml:"shouldWait,omitempty"` + Wait string `yaml:"wait,omitempty"` +} + +// TaskType represents the type of task. +type TaskType string diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 78a0cc4e52..f491f53477 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -4,14 +4,8 @@ import ( "github.com/go-yaml/yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service" -) - -const ( - TCP ApplicationProtocol = "TCP" - UDP ApplicationProtocol = "UDP" - - SHELL TaskType = "sh" - PYTHON TaskType = "python" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks" ) // We need the package id and the args, the args need to be filled in @@ -89,6 +83,12 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { switch getBuiltinNameFromInstruction(scheduledInstruction) { case add_service.AddServiceBuiltinName: pyg.updatePlanYamlFromAddService(scheduledInstruction) + case remove_service.RemoveServiceBuiltinName: + pyg.updatePlanYamlFromRemoveService(scheduledInstruction) + case tasks.RunShBuiltinName: + pyg.updatePlanYamlFromRunSh(scheduledInstruction) + case tasks.RunPythonBuiltinName: + pyg.updatePlanYamlFromRunPython(scheduledInstruction) default: return nil, nil } @@ -98,82 +98,39 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { return convertPlanYamlToYaml(pyg.planYaml) } -func convertPlanYamlToYaml(planYaml *PlanYaml) ([]byte, error) { - yamlBytes, err := yaml.Marshal(planYaml) - if err != nil { - return []byte{}, err - } - return yamlBytes, nil -} - -func getBuiltinNameFromInstruction(instruction *instructions_plan.ScheduledInstruction) string { - return instruction.GetInstruction().GetCanonicalInstruction(false).GetInstructionName() -} - +// is there anyway i can make this type more specific for type safety func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruction *instructions_plan.ScheduledInstruction) { - + // TODO: update the plan yaml based on an add_service } -type PlanYaml struct { - PackageId string `yaml:"packageId,omitempty"` - Services []*Service `yaml:"services,omitempty"` - FilesArtifacts []*FilesArtifact `yaml:"filesArtifacts,omitempty"` - Tasks []*Task `yaml:"tasks,omitempty"` +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(RemoveServiceInstruction *instructions_plan.ScheduledInstruction) { + // TODO: update the plan yaml based on an add_service } -// Service represents a service in the system. -type Service struct { - Uuid string `yaml:"uuid,omitempty"` - Name string `yaml:"name,omitempty"` - Image string `yaml:"image,omitempty"` - EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` - Ports []*Port `yaml:"ports,omitempty"` - Files []*FileMount `yaml:"files,omitempty"` +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(addServiceInstruction *instructions_plan.ScheduledInstruction) { + // TODO: update the plan yaml based on an add_service } -// FilesArtifact represents a collection of files. -type FilesArtifact struct { - Uuid string `yaml:"uuid,omitempty"` - Name string `yaml:"name,omitempty"` - Files map[string]string `yaml:"files,omitempty"` +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(addServiceInstruction *instructions_plan.ScheduledInstruction) { + // TODO: update the plan yaml based on an add_service } -// EnvironmentVariable represents an environment variable. -type EnvironmentVariable struct { - Key string `yaml:"key,omitempty"` - Value string `yaml:"value,omitempty"` +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(addServiceInstruction *instructions_plan.ScheduledInstruction) { + // TODO: update the plan yaml based on an add_service } -// Port represents a port. -type Port struct { - TransportProtocol ApplicationProtocol `yaml:"transportProtocol,omitempty"` - - PortName string `yaml:"portName,omitempty"` - PortNum uint16 `yaml:"portNum,omitempty"` +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(addServiceInstruction *instructions_plan.ScheduledInstruction) { + // TODO: update the plan yaml based on an add_service } -// ApplicationProtocol represents the application protocol used. -type ApplicationProtocol string - -// FileMount represents a mount point for files. -type FileMount struct { - MountPath string `yaml:"mountPath,omitempty"` - FilesArtifactUuid string `yaml:"filesArtifactUuid,omitempty"` - FilesArtifactName string `yaml:"filesArtifactName,omitempty"` +func convertPlanYamlToYaml(planYaml *PlanYaml) ([]byte, error) { + yamlBytes, err := yaml.Marshal(planYaml) + if err != nil { + return []byte{}, err + } + return yamlBytes, nil } -// Task represents a task to be executed. -type Task struct { - TaskType TaskType `yaml:"taskType,omitempty"` - Name string `yaml:"name,omitempty"` - Command string `yaml:"command,omitempty"` - Image string `yaml:"image,omitempty"` - EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` - Files []*FileMount `yaml:"files,omitempty"` - Store []string `yaml:"store,omitempty"` - ShouldWait bool `yaml:"shouldWait,omitempty"` - Wait string `yaml:"wait,omitempty"` +func getBuiltinNameFromInstruction(instruction *instructions_plan.ScheduledInstruction) string { + return instruction.GetInstruction().GetCanonicalInstruction(false).GetInstructionName() } - -// TaskType represents the type of task. -type TaskType string From 46fae9d2f2007f1e9fd477d46177087208825e68 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 16 Feb 2024 12:54:21 -0500 Subject: [PATCH 04/75] add get arguments to kurtosis instruction interface --- .../kurtosis_instruction.go | 3 + .../mock_kurtosis_instruction.go | 48 ++++++- .../startosis_engine/plan_yaml_generator.go | 31 ++++- .../plan_yaml_generator_test.go | 120 +++++++++--------- 4 files changed, 135 insertions(+), 67 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go index 89d809662b..6bcdf73c6a 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go @@ -6,6 +6,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_plan_persistence" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_structure" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" ) @@ -33,4 +34,6 @@ type KurtosisInstruction interface { // It returns a builder and not the built object b/c the caller of this method might want to set some attributes // itself. In the current case, this is called in the executor, and it sets the UUID and the returned value. GetPersistableAttributes() *enclave_plan_persistence.EnclavePlanInstructionBuilder + + GetArguments() *builtin_argument.ArgumentValuesSet } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/mock_instruction/mock_kurtosis_instruction.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/mock_instruction/mock_kurtosis_instruction.go index 5801836154..8dd95447f0 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/mock_instruction/mock_kurtosis_instruction.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/mock_instruction/mock_kurtosis_instruction.go @@ -1,11 +1,14 @@ -// Code generated by mockery v2.22.1. DO NOT EDIT. +// Code generated by mockery v2.23.1. DO NOT EDIT. package mock_instruction import ( context "context" + builtin_argument "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" + enclave_plan_persistence "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_plan_persistence" + enclave_structure "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_structure" kurtosis_core_rpc_api_bindings "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" @@ -84,6 +87,49 @@ func (_c *MockKurtosisInstruction_Execute_Call) RunAndReturn(run func(context.Co return _c } +// GetArguments provides a mock function with given fields: +func (_m *MockKurtosisInstruction) GetArguments() *builtin_argument.ArgumentValuesSet { + ret := _m.Called() + + var r0 *builtin_argument.ArgumentValuesSet + if rf, ok := ret.Get(0).(func() *builtin_argument.ArgumentValuesSet); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*builtin_argument.ArgumentValuesSet) + } + } + + return r0 +} + +// MockKurtosisInstruction_GetArguments_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetArguments' +type MockKurtosisInstruction_GetArguments_Call struct { + *mock.Call +} + +// GetArguments is a helper method to define mock.On call +func (_e *MockKurtosisInstruction_Expecter) GetArguments() *MockKurtosisInstruction_GetArguments_Call { + return &MockKurtosisInstruction_GetArguments_Call{Call: _e.mock.On("GetArguments")} +} + +func (_c *MockKurtosisInstruction_GetArguments_Call) Run(run func()) *MockKurtosisInstruction_GetArguments_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockKurtosisInstruction_GetArguments_Call) Return(_a0 *builtin_argument.ArgumentValuesSet) *MockKurtosisInstruction_GetArguments_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockKurtosisInstruction_GetArguments_Call) RunAndReturn(run func() *builtin_argument.ArgumentValuesSet) *MockKurtosisInstruction_GetArguments_Call { + _c.Call.Return(run) + return _c +} + // GetCanonicalInstruction provides a mock function with given fields: isSkipped func (_m *MockKurtosisInstruction) GetCanonicalInstruction(isSkipped bool) *kurtosis_core_rpc_api_bindings.StarlarkInstruction { ret := _m.Called(isSkipped) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index f491f53477..6c4985a86c 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -36,10 +36,10 @@ type PlanYamlGenerator interface { // services: // - uuid: // - name: - // service_config: - // image: - // env_var: - // ... + // service_config: + // image: + // env_var: + // ... // // // files_artifacts: @@ -79,10 +79,11 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { // iterate over the sequence of instructions for _, scheduledInstruction := range instructionsSequence { + var err error // based on the instruction, update the plan yaml representation accordingly switch getBuiltinNameFromInstruction(scheduledInstruction) { case add_service.AddServiceBuiltinName: - pyg.updatePlanYamlFromAddService(scheduledInstruction) + err = pyg.updatePlanYamlFromAddService(scheduledInstruction) case remove_service.RemoveServiceBuiltinName: pyg.updatePlanYamlFromRemoveService(scheduledInstruction) case tasks.RunShBuiltinName: @@ -92,6 +93,9 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { default: return nil, nil } + if err != nil { + return nil, err + } } // at the very end, convert the plan yaml representation into a yaml @@ -99,8 +103,23 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { } // is there anyway i can make this type more specific for type safety -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruction *instructions_plan.ScheduledInstruction) { + +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruction *instructions_plan.ScheduledInstruction) error { // TODO: update the plan yaml based on an add_service + kurtosisInstruction := addServiceInstruction.GetInstruction() + instructionArgsList := kurtosisInstruction.GetCanonicalInstruction(false).Arguments + + // get name and config arg from args list + nameArg := instructionArgsList[0] + configArg := instructionArgsList[1] + + // start building Service Yaml object + service := &Service{} + service.Uuid = string(addServiceInstruction.GetUuid()) // uuid of the object is the uuid of the instruction that created that object + service.Name = nameArg.GetSerializedArgValue() + + _ = configArg // find some way to get the config arg but just not as a string + return nil } func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(RemoveServiceInstruction *instructions_plan.ScheduledInstruction) { diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 259e4b817a..12733016fd 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -12,7 +12,6 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "testing" ) type PlanYamlGeneratorTestSuite struct { @@ -49,9 +48,9 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.serviceNetwork.EXPECT().ExistServiceRegistration(testServiceName).Maybe().Return(true, nil) } -func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { - suite.Run(t, new(PlanYamlGeneratorTestSuite)) -} +//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { +// suite.Run(t, new(PlanYamlGeneratorTestSuite)) +//} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() @@ -61,7 +60,7 @@ func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorVerySimpleScript() script := ` def run(plan): - service_name = "%v" + service_name = "partyService" config = ServiceConfig( image = "` + testContainerImageName + `", @@ -132,61 +131,62 @@ def run(plan): require.Equal(suite.T(), yamlBytes, []byte{}) } -func TestConvertPlanYamlToYamlBytes(t *testing.T) { - PackageId := "github.com/kurtosis-tech/postgres-package" - - services := []*Service{ - { - Name: "tedi", - Uuid: "uuid", - Image: "postgres:alpine", - EnvVars: []*EnvironmentVariable{ - { - Key: "kevin", - Value: "dag", - }, - }, - }, - { - Name: "kaleb", - Uuid: "uuid", - Image: "postgres:alpine", - EnvVars: []*EnvironmentVariable{ - { - Key: "kevin", - Value: "dag", - }, - }, - }, - } - filesArtifacts := []*FilesArtifact{ - { - Uuid: "something", - Name: "something", - Files: nil, - }, - } - tasks := []*Task{ - { - TaskType: PYTHON, - Name: "updateSomething", - Command: "do something", - Image: "jqcurl", - EnvVars: []*EnvironmentVariable{}, - }, - } - - planYaml := PlanYaml{ - PackageId: PackageId, - Services: services, - FilesArtifacts: filesArtifacts, - Tasks: tasks, - } - - yamlBytes, err := convertPlanYamlToYaml(&planYaml) - require.NoError(t, err) - require.Equal(t, "", string(yamlBytes)) -} +// +//func TestConvertPlanYamlToYamlBytes(t *testing.T) { +// PackageId := "github.com/kurtosis-tech/postgres-package" +// +// services := []*Service{ +// { +// Name: "tedi", +// Uuid: "uuid", +// Image: "postgres:alpine", +// EnvVars: []*EnvironmentVariable{ +// { +// Key: "kevin", +// Value: "dag", +// }, +// }, +// }, +// { +// Name: "kaleb", +// Uuid: "uuid", +// Image: "postgres:alpine", +// EnvVars: []*EnvironmentVariable{ +// { +// Key: "kevin", +// Value: "dag", +// }, +// }, +// }, +// } +// filesArtifacts := []*FilesArtifact{ +// { +// Uuid: "something", +// Name: "something", +// Files: nil, +// }, +// } +// tasks := []*Task{ +// { +// TaskType: PYTHON, +// Name: "updateSomething", +// Command: "do something", +// Image: "jqcurl", +// EnvVars: []*EnvironmentVariable{}, +// }, +// } +// +// planYaml := PlanYaml{ +// PackageId: PackageId, +// Services: services, +// FilesArtifacts: filesArtifacts, +// Tasks: tasks, +// } +// +// yamlBytes, err := convertPlanYamlToYaml(&planYaml) +// require.NoError(t, err) +// require.Equal(t, "", string(yamlBytes)) +//} //func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorPostgresPackage() { // packageId := "github.com/kurtosis-tech/postgres-package" From 1b437e44689d0048b71f283195e95af12b9f5d93 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 16 Feb 2024 13:39:55 -0500 Subject: [PATCH 05/75] adjust plan yaml generator to get service config --- .../service_config/service_config.go | 1 + .../server/startosis_engine/plan_yaml.go | 8 +- .../startosis_engine/plan_yaml_generator.go | 73 +++++++++++++++---- .../plan_yaml_generator_test.go | 27 +++++-- .../startosis_engine/startosis_runner.go | 9 ++- 5 files changed, 96 insertions(+), 22 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go b/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go index 8e014b3608..d832e8ac23 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go @@ -263,6 +263,7 @@ func (config *ServiceConfig) ToKurtosisType( if !found { return nil, startosis_errors.NewInterpretationError("Required attribute '%s' could not be found on type '%s'", ImageAttr, ServiceConfigTypeName) } + // TODO: refactor image build spec into a common interface imageName, maybeImageBuildSpec, maybeImageRegistrySpec, maybeNixBuildSpec, interpretationErr = convertImage( rawImageAttrValue, locatorOfModuleInWhichThisBuiltInIsBeingCalled, diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index d295e5a779..923ec9b9b4 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -1,8 +1,9 @@ package startosis_engine const ( - TCP ApplicationProtocol = "TCP" - UDP ApplicationProtocol = "UDP" + HTTP ApplicationProtocol = "HTTP" + UDP TransportProtocol = "UDP" + TCP TransportProtocol = "TCP" SHELL TaskType = "sh" PYTHON TaskType = "python" @@ -49,6 +50,9 @@ type Port struct { // ApplicationProtocol represents the application protocol used. type ApplicationProtocol string +// TransportProtocol represents transport protocol used. +type TransportProtocol string + // FileMount represents a mount point for files. type FileMount struct { MountPath string `yaml:"mountPath,omitempty"` diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 6c4985a86c..bc09c640b0 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -2,10 +2,16 @@ package startosis_engine import ( "github.com/go-yaml/yaml" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" + "go.starlark.net/starlark" ) // We need the package id and the args, the args need to be filled in @@ -60,14 +66,34 @@ type PlanYamlGeneratorImpl struct { // Plan generetated by an interpretation of a starlark script of package plan *instructions_plan.InstructionsPlan + serviceNetwork service_network.ServiceNetwork + + packageContentProvider startosis_packages.PackageContentProvider + + locatorOfModuleInWhichThisBuiltInIsBeingCalled string + + packageReplaceOptions map[string]string + // Representation of plan in yaml the plan is being processed, the yaml gets updated planYaml *PlanYaml } -func NewPlanYamlGenerator(plan *instructions_plan.InstructionsPlan) *PlanYamlGeneratorImpl { +func NewPlanYamlGenerator( + plan *instructions_plan.InstructionsPlan, + serviceNetwork service_network.ServiceNetwork, + packageId string, + packageContentProvider startosis_packages.PackageContentProvider, + locatorOfModuleInWhichThisBuiltInIsBeingCalled string, + packageReplaceOptions map[string]string) *PlanYamlGeneratorImpl { return &PlanYamlGeneratorImpl{ - plan: plan, - planYaml: &PlanYaml{}, + plan: plan, + serviceNetwork: serviceNetwork, + packageContentProvider: packageContentProvider, + packageReplaceOptions: packageReplaceOptions, + locatorOfModuleInWhichThisBuiltInIsBeingCalled: locatorOfModuleInWhichThisBuiltInIsBeingCalled, + planYaml: &PlanYaml{ + PackageId: packageId, + }, } } @@ -102,23 +128,42 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { return convertPlanYamlToYaml(pyg.planYaml) } -// is there anyway i can make this type more specific for type safety - -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruction *instructions_plan.ScheduledInstruction) error { - // TODO: update the plan yaml based on an add_service +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruction *instructions_plan.ScheduledInstruction) error { // for type safety, it would be great to be more specific than scheduled instruction kurtosisInstruction := addServiceInstruction.GetInstruction() - instructionArgsList := kurtosisInstruction.GetCanonicalInstruction(false).Arguments - - // get name and config arg from args list - nameArg := instructionArgsList[0] - configArg := instructionArgsList[1] + arguments := kurtosisInstruction.GetArguments() // start building Service Yaml object service := &Service{} service.Uuid = string(addServiceInstruction.GetUuid()) // uuid of the object is the uuid of the instruction that created that object - service.Name = nameArg.GetSerializedArgValue() - _ = configArg // find some way to get the config arg but just not as a string + serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", add_service.ServiceNameArgName) + } + service.Name = string(serviceName) + + starlarkServiceConfig, err := builtin_argument.ExtractArgumentValue[*service_config.ServiceConfig](arguments, add_service.ServiceConfigArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", add_service.ServiceConfigArgName) + } + serviceConfig, err := starlarkServiceConfig.ToKurtosisType( // is this an expensive call + pyg.serviceNetwork, + pyg.locatorOfModuleInWhichThisBuiltInIsBeingCalled, + pyg.planYaml.PackageId, + pyg.packageContentProvider, + pyg.packageReplaceOptions) + + service.Image = serviceConfig.GetContainerImageName() // TODO: support image build specs + service.Ports = []*Port{} + for portName, configPort := range serviceConfig.GetPrivatePorts() { // TODO: support public ports + port := &Port{ + TransportProtocol: ApplicationProtocol(configPort.GetTransportProtocol().String()), + PortName: portName, + PortNum: configPort.GetNumber(), + } + service.Ports = append(service.Ports, port) + } + return nil } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 12733016fd..64f8314f3c 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -12,6 +12,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "testing" ) type PlanYamlGeneratorTestSuite struct { @@ -24,14 +25,18 @@ type PlanYamlGeneratorTestSuite struct { } func (suite *PlanYamlGeneratorTestSuite) SetupTest() { + // mock package content provider suite.packageContentProvider = mock_package_content_provider.NewMockPackageContentProvider() enclaveDb := getEnclaveDBForTest(suite.T()) dummySerde := shared_helpers.NewDummyStarlarkValueSerDeForTest() + // mock runtime value store runtimeValueStore, err := runtime_value_store.CreateRuntimeValueStore(dummySerde, enclaveDb) require.NoError(suite.T(), err) suite.runtimeValueStore = runtimeValueStore + + // mock service network suite.serviceNetwork = service_network.NewMockServiceNetwork(suite.T()) suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "") @@ -48,9 +53,9 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.serviceNetwork.EXPECT().ExistServiceRegistration(testServiceName).Maybe().Return(true, nil) } -//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { -// suite.Run(t, new(PlanYamlGeneratorTestSuite)) -//} +func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { + suite.Run(t, new(PlanYamlGeneratorTestSuite)) +} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() @@ -75,7 +80,13 @@ def run(plan): require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 1, instructionsPlan.Size()) - pyg := NewPlanYamlGenerator(instructionsPlan) + pyg := NewPlanYamlGenerator( + instructionsPlan, + suite.serviceNetwork, + startosis_constants.PackageIdPlaceholderForStandaloneScript, + suite.packageContentProvider, + "", // figure out if this is needed + noPackageReplaceOptions) yamlBytes, err := pyg.GenerateYaml() require.NoError(suite.T(), err) @@ -124,7 +135,13 @@ def run(plan): require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 8, instructionsPlan.Size()) - pyg := NewPlanYamlGenerator(instructionsPlan) + pyg := NewPlanYamlGenerator( + instructionsPlan, + suite.serviceNetwork, + startosis_constants.PackageIdPlaceholderForStandaloneScript, + suite.packageContentProvider, + "", // figure out if this is needed + noPackageReplaceOptions) yamlBytes, err := pyg.GenerateYaml() require.NoError(suite.T(), err) diff --git a/core/server/api_container/server/startosis_engine/startosis_runner.go b/core/server/api_container/server/startosis_engine/startosis_runner.go index f3db65d0b4..367c8b1b48 100644 --- a/core/server/api_container/server/startosis_engine/startosis_runner.go +++ b/core/server/api_container/server/startosis_engine/startosis_runner.go @@ -165,7 +165,14 @@ func (runner *StartosisRunner) Run( starlarkRunResponseLines <- progressInfo if dryRun { - pyg := NewPlanYamlGenerator(instructionsPlan) + pyg := NewPlanYamlGenerator( + instructionsPlan, + runner.startosisInterpreter.serviceNetwork, + packageId, + runner.startosisInterpreter.packageContentProvider, + "", // don't think this matters? but figure out if it does + packageReplaceOptions, + ) planYaml, err := pyg.GenerateYaml() if err != nil { starlarkRunResponseLines <- binding_constructors.NewStarlarkRunResponseLineFromWarning(err.Error()) From f4b31525316bf5bb44fec0c99e4190c8fecc0548 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 16 Feb 2024 16:14:56 -0500 Subject: [PATCH 06/75] add postgres package test --- .../server/api_container_service.go | 2 +- .../server/startosis_engine/plan_yaml.go | 26 +- .../startosis_engine/plan_yaml_generator.go | 62 +- .../plan_yaml_generator_test.go | 552 ++++++++++-------- 4 files changed, 365 insertions(+), 277 deletions(-) diff --git a/core/server/api_container/server/api_container_service.go b/core/server/api_container/server/api_container_service.go index 1a7ad86e3c..49592a4b83 100644 --- a/core/server/api_container/server/api_container_service.go +++ b/core/server/api_container/server/api_container_service.go @@ -294,7 +294,7 @@ func (apicService *ApiContainerService) RunStarlarkPackage(args *kurtosis_core_r logrus.Warn("An error occurred tracking kurtosis run event") } - logrus.Infof("package id: %v\n main func name: %v\n actual relative path to main file: %v\n script with run func: %v\n serialized params:%v\n%v", + logrus.Infof("package id: %v\n main func name: %v\n actual relative path to main file: %v\n script with run func: %v\n serialized params:%v\n", detectedPackageId, mainFuncName, actualRelativePathToMainFile, diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 923ec9b9b4..de15722d6f 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -18,12 +18,14 @@ type PlanYaml struct { // Service represents a service in the system. type Service struct { - Uuid string `yaml:"uuid,omitempty"` - Name string `yaml:"name,omitempty"` - Image string `yaml:"image,omitempty"` - EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` - Ports []*Port `yaml:"ports,omitempty"` - Files []*FileMount `yaml:"files,omitempty"` + Uuid string `yaml:"uuid,omitempty"` // done + Name string `yaml:"name,omitempty"` // done + Image string `yaml:"image,omitempty"` // done + Cmd []string `yaml:"command,omitempty"` // done + Entrypoint []string `yaml:"entrypoint,omitempty"` // done + EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` // done + Ports []*Port `yaml:"ports,omitempty"` // done + Files []*FileMount `yaml:"files,omitempty"` } // FilesArtifact represents a collection of files. @@ -41,10 +43,11 @@ type EnvironmentVariable struct { // Port represents a port. type Port struct { - TransportProtocol ApplicationProtocol `yaml:"transportProtocol,omitempty"` + Name string `yaml:"name,omitempty"` + Number uint16 `yaml:"number,omitempty"` - PortName string `yaml:"portName,omitempty"` - PortNum uint16 `yaml:"portNum,omitempty"` + TransportProtocol TransportProtocol `yaml:"transportProtocol,omitempty"` + ApplicationProtocol ApplicationProtocol `yaml:"applicationProtocol,omitempty"` } // ApplicationProtocol represents the application protocol used. @@ -55,9 +58,8 @@ type TransportProtocol string // FileMount represents a mount point for files. type FileMount struct { - MountPath string `yaml:"mountPath,omitempty"` - FilesArtifactUuid string `yaml:"filesArtifactUuid,omitempty"` - FilesArtifactName string `yaml:"filesArtifactName,omitempty"` + MountPath string `yaml:"mountPath,omitempty"` + filesArtifacts []*FilesArtifact // TODO: support persistent directories } // Task represents a task to be executed. diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index bc09c640b0..0cb5c82d9b 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -74,6 +74,10 @@ type PlanYamlGeneratorImpl struct { packageReplaceOptions map[string]string + // index of files artifact uuid + // this provides a look up to see what files artifacts have been processed + filesArtifactIndex map[string]bool + // Representation of plan in yaml the plan is being processed, the yaml gets updated planYaml *PlanYaml } @@ -134,7 +138,8 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // start building Service Yaml object service := &Service{} - service.Uuid = string(addServiceInstruction.GetUuid()) // uuid of the object is the uuid of the instruction that created that object + // TODO: mock uuid generator so I can add uuids + //service.Uuid = string(addServiceInstruction.GetUuid()) // uuid of the object is the uuid of the instruction that created that object serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) if err != nil { @@ -146,7 +151,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc if err != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", add_service.ServiceConfigArgName) } - serviceConfig, err := starlarkServiceConfig.ToKurtosisType( // is this an expensive call + serviceConfig, err := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? it's made twice - once during interpretation pyg.serviceNetwork, pyg.locatorOfModuleInWhichThisBuiltInIsBeingCalled, pyg.planYaml.PackageId, @@ -154,16 +159,63 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc pyg.packageReplaceOptions) service.Image = serviceConfig.GetContainerImageName() // TODO: support image build specs + service.Cmd = serviceConfig.GetCmdArgs() + service.Entrypoint = serviceConfig.GetEntrypointArgs() + + // ports service.Ports = []*Port{} for portName, configPort := range serviceConfig.GetPrivatePorts() { // TODO: support public ports port := &Port{ - TransportProtocol: ApplicationProtocol(configPort.GetTransportProtocol().String()), - PortName: portName, - PortNum: configPort.GetNumber(), + TransportProtocol: TransportProtocol(configPort.GetTransportProtocol().String()), + ApplicationProtocol: ApplicationProtocol(*configPort.GetMaybeApplicationProtocol()), + Name: portName, + Number: configPort.GetNumber(), } service.Ports = append(service.Ports, port) } + // env vars + service.EnvVars = []*EnvironmentVariable{} + for key, val := range serviceConfig.GetEnvVars() { + envVar := &EnvironmentVariable{ + Key: key, + Value: val, + } + service.EnvVars = append(service.EnvVars, envVar) + } + + // adding a file, also means adding a files artifact IF it doesn't exist already + // 1. create the files artifact, with the correct identifier + // 2. add the files artifact to the plan yaml if it doesn't alrady exist + service.Files = []*FileMount{} + // but the question is where did the artifact identifier come from? is it a new one or is it an old one? + // if it's an old one that was already created, how do we know that it was already created + // but there's a difference between it being created and it coming from somewhere + for mountPath, artifactIdentifiers := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { + // create files artifact objects + filesArtifacts := []*FilesArtifact{} + for _, identifier := range artifactIdentifiers { + filesArtifact := &FilesArtifact{ + Uuid: identifier, + Name: "", // TODO: how do we get this if the FilesArtifact wasn't created by a different instruction + Files: map[string]string{}, // TODO: how do we get this if FilesArtifact wasn't created by a different instruction + } + // if the files artifact haven't already been tracked, add it to list of known files artifacts + if _, ok := pyg.filesArtifactIndex[identifier]; !ok { + pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) + pyg.filesArtifactIndex[identifier] = true + } + filesArtifacts = append(filesArtifacts, filesArtifact) + } + + fileMount := &FileMount{ + MountPath: mountPath, + filesArtifacts: filesArtifacts, + } + service.Files = append(service.Files, fileMount) + } + + pyg.planYaml.Services = append(pyg.planYaml.Services, service) return nil } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 64f8314f3c..191cc6514f 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -12,6 +12,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "net" "testing" ) @@ -51,11 +52,16 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.serviceNetwork.EXPECT().GetUniqueNameForFileArtifact().Maybe().Return(mockFileArtifactName, nil) suite.serviceNetwork.EXPECT().GetEnclaveUuid().Maybe().Return(enclave.EnclaveUUID(mockEnclaveUuid)) suite.serviceNetwork.EXPECT().ExistServiceRegistration(testServiceName).Maybe().Return(true, nil) + apiContainerInfo := service_network.NewApiContainerInfo( + net.IP{}, + 51243, + "134123") + suite.serviceNetwork.EXPECT().GetApiContainerInfo().Return(apiContainerInfo) } -func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { - suite.Run(t, new(PlanYamlGeneratorTestSuite)) -} +//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { +// suite.Run(t, new(PlanYamlGeneratorTestSuite)) +//} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() @@ -64,14 +70,65 @@ func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorVerySimpleScript() { script := ` def run(plan): + service_name = "partyService" + config = ServiceConfig( + image = "` + testContainerImageName + `", + ports = { + "grpc": PortSpec(number = 1323, transport_protocol = "TCP", application_protocol = "http") + }, + ) + datastore_service = plan.add_service(name = service_name, config = config) +` + + _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, useDefaultMainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, script, startosis_constants.EmptyInputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 1, instructionsPlan.Size()) + pyg := NewPlanYamlGenerator( + instructionsPlan, + suite.serviceNetwork, + startosis_constants.PackageIdPlaceholderForStandaloneScript, + suite.packageContentProvider, + "", // figure out if this is needed + noPackageReplaceOptions) + yamlBytes, err := pyg.GenerateYaml() + require.NoError(suite.T(), err) + + expectedYamlString := + `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT +services: +- name: partyService + image: kurtosistech/example-datastore-server + ports: + - name: grpc + number: 1323 + transportProtocol: TCP + applicationProtocol: http +` + require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) +} + +func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorSimplerScripButNotSoSimple() { + script := ` +def run(plan): + + service_name = "partyService" config = ServiceConfig( image = "` + testContainerImageName + `", + cmd=["echo", "Hello"], ports = { "grpc": PortSpec(number = 1323, transport_protocol = "TCP", application_protocol = "http") }, + env_vars = { + "POSTGRES_DB": "tedi", + "POSTGRES_USERNAME": "dag", + }, + files = { + "/usr/": "", # TODO: how do you model a files artifact + "/bin/": "", # TODO: how do you model a files artifact + } ) datastore_service = plan.add_service(name = service_name, config = config) ` @@ -91,15 +148,15 @@ def run(plan): require.NoError(suite.T(), err) expectedYamlString := - ` -packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT + `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT services: - name: - image: kurtosistech/example-datastore-server - ports: - name: grpc - transportProtocol: TCP - number: 1323 +- name: partyService + image: kurtosistech/example-datastore-server + ports: + - name: grpc + number: 1323 + transportProtocol: TCP + applicationProtocol: http ` require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) } @@ -145,254 +202,231 @@ def run(plan): yamlBytes, err := pyg.GenerateYaml() require.NoError(suite.T(), err) - require.Equal(suite.T(), yamlBytes, []byte{}) + expectedYamlString := `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT +services: +- name: partyService + image: kurtosistech/example-datastore-server + ports: + - name: grpc + number: 1323 + transportProtocol: TCP + applicationProtocol: http +` + require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) } -// -//func TestConvertPlanYamlToYamlBytes(t *testing.T) { -// PackageId := "github.com/kurtosis-tech/postgres-package" -// -// services := []*Service{ -// { -// Name: "tedi", -// Uuid: "uuid", -// Image: "postgres:alpine", -// EnvVars: []*EnvironmentVariable{ -// { -// Key: "kevin", -// Value: "dag", -// }, -// }, -// }, -// { -// Name: "kaleb", -// Uuid: "uuid", -// Image: "postgres:alpine", -// EnvVars: []*EnvironmentVariable{ -// { -// Key: "kevin", -// Value: "dag", -// }, -// }, -// }, -// } -// filesArtifacts := []*FilesArtifact{ -// { -// Uuid: "something", -// Name: "something", -// Files: nil, -// }, -// } -// tasks := []*Task{ -// { -// TaskType: PYTHON, -// Name: "updateSomething", -// Command: "do something", -// Image: "jqcurl", -// EnvVars: []*EnvironmentVariable{}, -// }, -// } -// -// planYaml := PlanYaml{ -// PackageId: PackageId, -// Services: services, -// FilesArtifacts: filesArtifacts, -// Tasks: tasks, -// } -// -// yamlBytes, err := convertPlanYamlToYaml(&planYaml) -// require.NoError(t, err) -// require.Equal(t, "", string(yamlBytes)) -//} +func (suite *PlanYamlGeneratorTestSuite) TestConvertPlanYamlToYamlBytes(t *testing.T) { + PackageId := "github.com/kurtosis-tech/postgres-package" -//func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorPostgresPackage() { -// packageId := "github.com/kurtosis-tech/postgres-package" -// mainFunctionName := "" -// relativePathToMainFile := "main.star" -// serializedStarlark := -// `adminer_module = import_module("github.com/bharath-123/db-adminer-package/main.star") -//PORT_NAME = "postgresql" -//APPLICATION_PROTOCOL = "postgresql" -//PG_DRIVER = "pgsql" -// -//CONFIG_FILE_MOUNT_DIRPATH = "/config" -//SEED_FILE_MOUNT_PATH = "/docker-entrypoint-initdb.d" -//DATA_DIRECTORY_PATH = "/data/" -// -//CONFIG_FILENAME = "postgresql.conf" # Expected to be in the artifact -// -//POSTGRES_MIN_CPU = 10 -//POSTGRES_MAX_CPU = 1000 -//POSTGRES_MIN_MEMORY = 32 -//POSTGRES_MAX_MEMORY = 1024 -// -// def run( -// plan, -// image="postgres:alpine", -// service_name="postgres", -// user="postgres", -// password="MyPassword1!", -// database="postgres", -// config_file_artifact_name="", -// seed_file_artifact_name="", -// extra_configs=[], -// persistent=True, -// launch_adminer=False, -// min_cpu=POSTGRES_MIN_CPU, -// max_cpu=POSTGRES_MAX_CPU, -// min_memory=POSTGRES_MIN_MEMORY, -// max_memory=POSTGRES_MAX_MEMORY, -// node_selectors=None, -// ): -// """Launches a Postgresql database instance, optionally seeding it with a SQL file script -// -// Args: -// image (string): The container image that the Postgres service will be started with -// service_name (string): The name to give the Postgres service -// user (string): The user to create the Postgres database with -// password (string): The password to give to the created user -// database (string): The name of the database to create -// config_file_artifact_name (string): The name of a files artifact that contains a Postgres config file in it -// If not empty, this will be used to configure the Postgres server -// seed_file_artifact_name (string): The name of a files artifact containing seed data -// If not empty, the Postgres server will be populated with the data upon start -// extra_configs (list[string]): Each argument gets passed as a '-c' argument to the Postgres server -// persistent (bool): Whether the data should be persisted. Defaults to True; Note that this isn't supported on multi node k8s cluster as of 2023-10-16 -// launch_adminer (bool): Whether to launch adminer which launches a website to inspect postgres database entries. Defaults to False. -// min_cpu (int): Define how much CPU millicores the service should be assigned at least. -// max_cpu (int): Define how much CPU millicores the service should be assign max. -// min_memory (int): Define how much MB of memory the service should be assigned at least. -// max_memory (int): Define how much MB of memory the service should be assigned max. -// node_selectors (dict[string, string]): Define a dict of node selectors - only works in kubernetes example: {"kubernetes.io/hostname": node-name-01} -// Returns: -// An object containing useful information about the Postgres database running inside the enclave: -// { -// "database": "postgres", -// "password": "MyPassword1!", -// "port": { -// "application_protocol": "postgresql", -// "number": 5432, -// "transport_protocol": "TCP", -// "wait": "2m0s" -// }, -// "service": { -// "hostname": "postgres", -// "ip_address": "172.16.0.4", -// "name": "postgres", -// "ports": { -// "postgresql": { -// "application_protocol": "postgresql", -// "number": 5432, -// "transport_protocol": "TCP", -// "wait": "2m0s" -// } -// } -// }, -// "url": "postgresql://postgres:MyPassword1!@postgres/postgres", -// "user": "postgres" -// } -// """ -// cmd = [] -// files = {} -// env_vars = { -// "POSTGRES_DB": database, -// "POSTGRES_USER": user, -// "POSTGRES_PASSWORD": password, -// } -// -// if persistent: -// files[DATA_DIRECTORY_PATH] = Directory( -// persistent_key= "data-{0}".format(service_name), -// ) -// env_vars["PGDATA"] = DATA_DIRECTORY_PATH + "/pgdata" -// if node_selectors == None: -// node_selectors = {} -// if config_file_artifact_name != "": -// config_filepath = CONFIG_FILE_MOUNT_DIRPATH + "/" + CONFIG_FILENAME -// cmd += ["-c", "config_file=" + config_filepath] -// files[CONFIG_FILE_MOUNT_DIRPATH] = config_file_artifact_name -// -// # append cmd with postgres config overrides passed by users -// if len(extra_configs) > 0: -// for config in extra_configs: -// cmd += ["-c", config] -// -// if seed_file_artifact_name != "": -// files[SEED_FILE_MOUNT_PATH] = seed_file_artifact_name -// -// postgres_service = plan.add_service( -// name=service_name, -// config=ServiceConfig( -// image=image, -// ports={ -// PORT_NAME: PortSpec( -// number=5432, -// application_protocol=APPLICATION_PROTOCOL, -// ) -// }, -// cmd=cmd, -// files=files, -// env_vars=env_vars, -// min_cpu=min_cpu, -// max_cpu=max_cpu, -// min_memory=min_memory, -// max_memory=max_memory, -// node_selectors=node_selectors, -// ), -// ) -// -// if launch_adminer: -// adminer = adminer_module.run( -// plan, -// default_db=database, -// default_driver=PG_DRIVER, -// default_password=password, -// default_server=postgres_service.hostname, -// default_username=user, -// ) -// -// url = "{protocol}://{user}:{password}@{hostname}/{database}".format( -// protocol=APPLICATION_PROTOCOL, -// user=user, -// password=password, -// hostname=postgres_service.hostname, -// database=database, -// ) -// -// return struct( -// url=url, -// service=postgres_service, -// port=postgres_service.ports[PORT_NAME], -// user=user, -// password=password, -// database=database, -// min_cpu=min_cpu, -// max_cpu=max_cpu, -// min_memory=min_memory, -// max_memory=max_memory, -// node_selectors=node_selectors, -// ) -// -// def run_query(plan, service, user, password, database, query): -// url = "{protocol}://{user}:{password}@{hostname}/{database}".format( -// protocol=APPLICATION_PROTOCOL, -// user=user, -// password=password, -// hostname=service.hostname, -// database=database, -// ) -// return plan.exec( -// service.name, recipe=ExecRecipe(command=["psql", url, "-c", query]) -// ) -//` -// serializedJsonParams := "" -// _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedStarlark, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) -// require.Nil(suite.T(), interpretationError) -// require.Equal(suite.T(), 8, instructionsPlan.Size()) -// -// //pyg := NewPlanYamlGenerator(instructionsPlan) -// //yamlBytes, err := pyg.GenerateYaml() -// //require.NoError(suite.T(), err) -// // -// //require.Equal(suite.T(), yamlBytes, []byte{}) -//} + services := []*Service{ + { + Name: "tedi", + Uuid: "uuid", + Image: "postgres:alpine", + EnvVars: []*EnvironmentVariable{ + { + Key: "kevin", + Value: "dag", + }, + }, + }, + { + Name: "kaleb", + Uuid: "uuid", + Image: "postgres:alpine", + EnvVars: []*EnvironmentVariable{ + { + Key: "kevin", + Value: "dag", + }, + }, + }, + } + filesArtifacts := []*FilesArtifact{ + { + Uuid: "something", + Name: "something", + Files: nil, + }, + } + tasks := []*Task{ + { + TaskType: PYTHON, + Name: "updateSomething", + Command: "do something", + Image: "jqcurl", + EnvVars: []*EnvironmentVariable{}, + }, + } + + planYaml := PlanYaml{ + PackageId: PackageId, + Services: services, + FilesArtifacts: filesArtifacts, + Tasks: tasks, + } + + yamlBytes, err := convertPlanYamlToYaml(&planYaml) + require.NoError(t, err) + + expectedYamlString := `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT +services: +- name: partyService + image: kurtosistech/example-datastore-server + ports: + - name: grpc + number: 1323 + transportProtocol: TCP + applicationProtocol: http +` + require.Equal(t, expectedYamlString, string(yamlBytes)) +} + +func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorPostgresPackageSimplified() { + packageId := "github.com/kurtosis-tech/postgres-package" + mainFunctionName := "" + relativePathToMainFile := "main.star" + + serializedPostgresPackageStarlark := `PORT_NAME = "postgresql" +APPLICATION_PROTOCOL = "postgresql" +PG_DRIVER = "pgsql" + +CONFIG_FILE_MOUNT_DIRPATH = "/config" +SEED_FILE_MOUNT_PATH = "/docker-entrypoint-initdb.d" +DATA_DIRECTORY_PATH = "/data/" + +CONFIG_FILENAME = "postgresql.conf" # Expected to be in the artifact + +POSTGRES_MIN_CPU = 10 +POSTGRES_MAX_CPU = 1000 +POSTGRES_MIN_MEMORY = 32 +POSTGRES_MAX_MEMORY = 1024 + +def run( + plan, + image="postgres:alpine", + service_name="postgres", + user="postgres", + password="MyPassword1!", + database="postgres", + config_file_artifact_name="", + seed_file_artifact_name="", + extra_configs=[], + persistent=True, + launch_adminer=False, + min_cpu=POSTGRES_MIN_CPU, + max_cpu=POSTGRES_MAX_CPU, + min_memory=POSTGRES_MIN_MEMORY, + max_memory=POSTGRES_MAX_MEMORY, + node_selectors=None, +): + cmd = [] # 34 + files = {} + env_vars = { + "POSTGRES_DB": database, + "POSTGRES_USER": user, + "POSTGRES_PASSWORD": password, + } + + if persistent: + files[DATA_DIRECTORY_PATH] = Directory( + persistent_key= "data-{0}".format(service_name), + ) + env_vars["PGDATA"] = DATA_DIRECTORY_PATH + "/pgdata" + if node_selectors == None: + node_selectors = {} + if config_file_artifact_name != "": + config_filepath = CONFIG_FILE_MOUNT_DIRPATH + "/" + CONFIG_FILENAME + cmd += ["-c", "config_file=" + config_filepath] + files[CONFIG_FILE_MOUNT_DIRPATH] = config_file_artifact_name + + # append cmd with postgres config overrides passed by users + if len(extra_configs) > 0: + for config in extra_configs: + cmd += ["-c", config] + + if seed_file_artifact_name != "": + files[SEED_FILE_MOUNT_PATH] = seed_file_artifact_name + + postgres_service = plan.add_service( + name=service_name, + config=ServiceConfig( + image=image, + ports={ + PORT_NAME: PortSpec( + number=5432, + application_protocol=APPLICATION_PROTOCOL, + ) + }, + cmd=cmd, + files=files, + env_vars=env_vars, + min_cpu=min_cpu, + max_cpu=max_cpu, + min_memory=min_memory, + max_memory=max_memory, + node_selectors=node_selectors, + ), + ) + + url = "{protocol}://{user}:{password}@{hostname}/{database}".format( + protocol=APPLICATION_PROTOCOL, + user=user, + password=password, + hostname=postgres_service.hostname, + database=database, + ) + + return struct( + url=url, + service=postgres_service, + port=postgres_service.ports[PORT_NAME], + user=user, + password=password, + database=database, + min_cpu=min_cpu, + max_cpu=max_cpu, + min_memory=min_memory, + max_memory=max_memory, + node_selectors=node_selectors, + ) +` + serializedJsonParams := "{}" + _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedPostgresPackageStarlark, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 1, instructionsPlan.Size()) + + pyg := NewPlanYamlGenerator( + instructionsPlan, + suite.serviceNetwork, + packageId, + suite.packageContentProvider, + "", // figure out if this is needed + noPackageReplaceOptions, + ) + yamlBytes, err := pyg.GenerateYaml() + require.NoError(suite.T(), err) + + expectedYamlString := `packageId: github.com/kurtosis-tech/postgres-package +services: +- name: postgres + image: postgres:alpine + envVars: + - key: POSTGRES_USER + value: postgres + - key: POSTGRES_PASSWORD + value: MyPassword1! + - key: PGDATA + value: /data//pgdata + - key: POSTGRES_DB + value: postgres + ports: + - name: postgresql + number: 5432 + transportProtocol: TCP + applicationProtocol: postgresql + files: + +` + require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) +} From 908ad7d729ecde7ea0c071158de5f2f4fdad062f Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Sat, 17 Feb 2024 10:53:35 -0500 Subject: [PATCH 07/75] start render templates impl --- .../startosis_engine/plan_yaml_generator.go | 86 ++++++++++++++++--- .../plan_yaml_generator_test.go | 83 +++++++++++++++++- .../startosis_engine/startosis_runner.go | 1 + 3 files changed, 155 insertions(+), 15 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 0cb5c82d9b..61bc97e7ac 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -6,6 +6,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" @@ -76,7 +77,11 @@ type PlanYamlGeneratorImpl struct { // index of files artifact uuid // this provides a look up to see what files artifacts have been processed - filesArtifactIndex map[string]bool + filesArtifactIndex map[string]*FilesArtifact + + serviceIndex map[string]*Service + + taskIndex map[string]*Task // Representation of plan in yaml the plan is being processed, the yaml gets updated planYaml *PlanYaml @@ -120,6 +125,8 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { pyg.updatePlanYamlFromRunSh(scheduledInstruction) case tasks.RunPythonBuiltinName: pyg.updatePlanYamlFromRunPython(scheduledInstruction) + case render_templates.RenderTemplatesBuiltinName: + err = pyg.updatePlanYamlFromRenderTemplates(scheduledInstruction) default: return nil, nil } @@ -195,15 +202,32 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // create files artifact objects filesArtifacts := []*FilesArtifact{} for _, identifier := range artifactIdentifiers { - filesArtifact := &FilesArtifact{ - Uuid: identifier, - Name: "", // TODO: how do we get this if the FilesArtifact wasn't created by a different instruction - Files: map[string]string{}, // TODO: how do we get this if FilesArtifact wasn't created by a different instruction + // is there already a files artifact that exists with this name from a previous instruction? + // is so, use that + var filesArtifact *FilesArtifact + if potentialFilesArtifact, ok := pyg.filesArtifactIndex[identifier]; ok { + // if so use that one + filesArtifacts = append(filesArtifacts, &FilesArtifact{ + Uuid: potentialFilesArtifact.Uuid, + Name: potentialFilesArtifact.Name, + Files: nil, // leave out the files for the services part of the yaml + }) + } else { + // otherwise create a new one + // the only information we have about a files artifact that didn't already exist is the name + // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args + filesArtifact = &FilesArtifact{ + Name: identifier, // TODO: check that the identifier the files artifact name and NOT a files artifact uuid + } + pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) + + // add it to the index + pyg.filesArtifactIndex[identifier] = filesArtifact } // if the files artifact haven't already been tracked, add it to list of known files artifacts if _, ok := pyg.filesArtifactIndex[identifier]; !ok { pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) - pyg.filesArtifactIndex[identifier] = true + pyg.filesArtifactIndex[identifier] = filesArtifact } filesArtifacts = append(filesArtifacts, filesArtifact) } @@ -219,27 +243,65 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc return nil } -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(RemoveServiceInstruction *instructions_plan.ScheduledInstruction) { +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(RemoveServiceInstruction *instructions_plan.ScheduledInstruction) error { + panic("remove service not implemented yet") + return nil // TODO: update the plan yaml based on an add_service } -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(addServiceInstruction *instructions_plan.ScheduledInstruction) { +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(addServiceInstruction *instructions_plan.ScheduledInstruction) error { + panic("run sh not implemented yet") + return nil // TODO: update the plan yaml based on an add_service } -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(addServiceInstruction *instructions_plan.ScheduledInstruction) { +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(addServiceInstruction *instructions_plan.ScheduledInstruction) error { + panic("run python not implemented yet") + return nil // TODO: update the plan yaml based on an add_service } -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(addServiceInstruction *instructions_plan.ScheduledInstruction) { +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(addServiceInstruction *instructions_plan.ScheduledInstruction) error { + panic("remove service not implemented yet") + return nil // TODO: update the plan yaml based on an add_service } -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(addServiceInstruction *instructions_plan.ScheduledInstruction) { - // TODO: update the plan yaml based on an add_service +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(addServiceInstruction *instructions_plan.ScheduledInstruction) error { + // all i really want from a rendered template is the files artifact name + // the name is in the returned value + // so then i can add this to the plan yaml files artifacts with the name, uuid of the instruction that it originated from + arguments := addServiceInstruction.GetInstruction().GetArguments() + renderTemplateConfig, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, render_templates.TemplateAndDataByDestinationRelFilepathArg) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to parse '%s'", render_templates.TemplateAndDataByDestinationRelFilepathArg) + } + + files := map[string]string{} + for _, filepath := range renderTemplateConfig.AttrNames() { + files[filepath] = "" + } + + returnedFilesArtifactNameStarlarkVal := addServiceInstruction.GetReturnedValue() + returnedFilesArtifactName := returnedFilesArtifactNameStarlarkVal.String() + instructionUuid := string(addServiceInstruction.GetUuid()) + + filesArtifact := &FilesArtifact{ + Uuid: instructionUuid, + Name: returnedFilesArtifactName, + Files: files, + } + pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) + // add the files artifact to all known files artifacts + pyg.filesArtifactIndex[returnedFilesArtifactName] = filesArtifact + + return nil } func convertPlanYamlToYaml(planYaml *PlanYaml) ([]byte, error) { + // unravel all the indices and add them to the plan + // add some sort of tie breaking so yaml's are deterministic + yamlBytes, err := yaml.Marshal(planYaml) if err != nil { return []byte{}, err diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 191cc6514f..df8d8feab0 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -59,9 +59,9 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.serviceNetwork.EXPECT().GetApiContainerInfo().Return(apiContainerInfo) } -//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { -// suite.Run(t, new(PlanYamlGeneratorTestSuite)) -//} +func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { + suite.Run(t, new(PlanYamlGeneratorTestSuite)) +} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() @@ -430,3 +430,80 @@ services: ` require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) } + +func (suite *PlanYamlGeneratorTestSuite) TestSimpleScriptWithFilesArtifact() { + packageId := "github.com/kurtosis-tech/plan-yaml-prac" + mainFunctionName := "" + relativePathToMainFile := "main.star" + + serializedScript := `def run(plan, args): + hi_files_artifact = plan.render_templates( + config={ + "hi.txt":struct( + template="hello world!", + data={} + ) + }, + name="hi-file" + ) + + plan.add_service( + name="tedi", + config=ServiceConfig( + image="ubuntu:latest", + cmd=["cat", "/root/hi.txt"], + ports={ + "dashboard":PortSpec( + number=1234, + application_protocol="http", + transport_protocol="TCP" + ) + }, + env_vars={ + "PASSWORD": "tedi" + }, + files={ + "/root": hi_files_artifact, + } + ) + ) +` + serializedJsonParams := "{}" + _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 2, instructionsPlan.Size()) + + pyg := NewPlanYamlGenerator( + instructionsPlan, + suite.serviceNetwork, + packageId, + suite.packageContentProvider, + "", // figure out if this is needed + noPackageReplaceOptions, + ) + yamlBytes, err := pyg.GenerateYaml() + require.NoError(suite.T(), err) + + expectedYamlString := `packageId: github.com/kurtosis-tech/postgres-package +services: +- name: postgres + image: postgres:alpine + envVars: + - key: POSTGRES_USER + value: postgres + - key: POSTGRES_PASSWORD + value: MyPassword1! + - key: PGDATA + value: /data//pgdata + - key: POSTGRES_DB + value: postgres + ports: + - name: postgresql + number: 5432 + transportProtocol: TCP + applicationProtocol: postgresql + files: + +` + require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) +} diff --git a/core/server/api_container/server/startosis_engine/startosis_runner.go b/core/server/api_container/server/startosis_engine/startosis_runner.go index 367c8b1b48..294472c7f7 100644 --- a/core/server/api_container/server/startosis_engine/startosis_runner.go +++ b/core/server/api_container/server/startosis_engine/startosis_runner.go @@ -177,6 +177,7 @@ func (runner *StartosisRunner) Run( if err != nil { starlarkRunResponseLines <- binding_constructors.NewStarlarkRunResponseLineFromWarning(err.Error()) } + logrus.Infof("PLAN YAML:\n %v", string(planYaml)) starlarkRunResponseLines <- binding_constructors.NewStarlarkRunResponseLineFromInfoMsg(string(planYaml)) return } From a4e7031dda37abeef7bd3d0d2df6f3d1eb97225e Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Sat, 17 Feb 2024 11:26:14 -0500 Subject: [PATCH 08/75] finish render templates impl --- .../startosis_engine/plan_yaml_generator.go | 87 +++++++++---------- .../plan_yaml_generator_test.go | 75 ++++++++++++++++ 2 files changed, 114 insertions(+), 48 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 61bc97e7ac..877d55eabb 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -145,8 +145,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // start building Service Yaml object service := &Service{} - // TODO: mock uuid generator so I can add uuids - //service.Uuid = string(addServiceInstruction.GetUuid()) // uuid of the object is the uuid of the instruction that created that object + //service.Uuid = string(addServiceInstruction.GetUuid()) // TODO: mock uuid generator so I can add uuids, uuid of the object is the uuid of the instruction that created that object serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) if err != nil { @@ -158,14 +157,14 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc if err != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", add_service.ServiceConfigArgName) } - serviceConfig, err := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? it's made twice - once during interpretation + serviceConfig, err := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? pyg.serviceNetwork, pyg.locatorOfModuleInWhichThisBuiltInIsBeingCalled, pyg.planYaml.PackageId, pyg.packageContentProvider, pyg.packageReplaceOptions) - service.Image = serviceConfig.GetContainerImageName() // TODO: support image build specs + service.Image = serviceConfig.GetContainerImageName() // TODO: support image build specs, image registry specs, nix build specs service.Cmd = serviceConfig.GetCmdArgs() service.Entrypoint = serviceConfig.GetEntrypointArgs() @@ -191,27 +190,29 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc service.EnvVars = append(service.EnvVars, envVar) } - // adding a file, also means adding a files artifact IF it doesn't exist already - // 1. create the files artifact, with the correct identifier - // 2. add the files artifact to the plan yaml if it doesn't alrady exist + // file mounts have two cases: + // 1. the referenced files artifact already exists in the plan, in which case add the referenced files artifact + // 2. the referenced files artifact does not already exist in the plan, in which case the file MUST have been passed in via a top level arg OR is invalid + // in this case, + // - create new files artifact + // - add it to the service's file mount accordingly + // - add the files artifact to the plan service.Files = []*FileMount{} - // but the question is where did the artifact identifier come from? is it a new one or is it an old one? - // if it's an old one that was already created, how do we know that it was already created - // but there's a difference between it being created and it coming from somewhere for mountPath, artifactIdentifiers := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { - // create files artifact objects - filesArtifacts := []*FilesArtifact{} + var fileMount *FileMount + fileMount = &FileMount{ + MountPath: mountPath, + } + + var serviceFilesArtifacts []*FilesArtifact for _, identifier := range artifactIdentifiers { - // is there already a files artifact that exists with this name from a previous instruction? - // is so, use that var filesArtifact *FilesArtifact + // if there's already a files artifact that exists with this name from a previous instruction, reference that if potentialFilesArtifact, ok := pyg.filesArtifactIndex[identifier]; ok { - // if so use that one - filesArtifacts = append(filesArtifacts, &FilesArtifact{ - Uuid: potentialFilesArtifact.Uuid, - Name: potentialFilesArtifact.Name, - Files: nil, // leave out the files for the services part of the yaml - }) + filesArtifact = &FilesArtifact{ + Uuid: potentialFilesArtifact.Uuid, + Name: potentialFilesArtifact.Name, + } } else { // otherwise create a new one // the only information we have about a files artifact that didn't already exist is the name @@ -220,26 +221,17 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc Name: identifier, // TODO: check that the identifier the files artifact name and NOT a files artifact uuid } pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) - - // add it to the index - pyg.filesArtifactIndex[identifier] = filesArtifact - } - // if the files artifact haven't already been tracked, add it to list of known files artifacts - if _, ok := pyg.filesArtifactIndex[identifier]; !ok { - pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) pyg.filesArtifactIndex[identifier] = filesArtifact } - filesArtifacts = append(filesArtifacts, filesArtifact) + serviceFilesArtifacts = append(serviceFilesArtifacts, filesArtifact) } - fileMount := &FileMount{ - MountPath: mountPath, - filesArtifacts: filesArtifacts, - } + fileMount.filesArtifacts = serviceFilesArtifacts service.Files = append(service.Files, fileMount) } pyg.planYaml.Services = append(pyg.planYaml.Services, service) + pyg.serviceIndex[service.Name] = service return nil } @@ -268,32 +260,31 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(addServiceInstru } func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(addServiceInstruction *instructions_plan.ScheduledInstruction) error { - // all i really want from a rendered template is the files artifact name - // the name is in the returned value - // so then i can add this to the plan yaml files artifacts with the name, uuid of the instruction that it originated from + var filesArtifact *FilesArtifact + + // get the name of returned files artifact + // give the FilesArtifact the uuid of the originating instruction + filesArtifactName := addServiceInstruction.GetReturnedValue().String() + filesArtifact = &FilesArtifact{ + Uuid: string(addServiceInstruction.GetUuid()), + Name: filesArtifactName, + } + + // get files of returned files artifact off render templates config arguments := addServiceInstruction.GetInstruction().GetArguments() renderTemplateConfig, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, render_templates.TemplateAndDataByDestinationRelFilepathArg) if err != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to parse '%s'", render_templates.TemplateAndDataByDestinationRelFilepathArg) } - files := map[string]string{} for _, filepath := range renderTemplateConfig.AttrNames() { - files[filepath] = "" + files[filepath] = "" // TODO: are files just the file names/the paths at those files? is it possible to get any other information about them } + filesArtifact.Files = files - returnedFilesArtifactNameStarlarkVal := addServiceInstruction.GetReturnedValue() - returnedFilesArtifactName := returnedFilesArtifactNameStarlarkVal.String() - instructionUuid := string(addServiceInstruction.GetUuid()) - - filesArtifact := &FilesArtifact{ - Uuid: instructionUuid, - Name: returnedFilesArtifactName, - Files: files, - } + // add the files artifact to the yaml and index pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) - // add the files artifact to all known files artifacts - pyg.filesArtifactIndex[returnedFilesArtifactName] = filesArtifact + pyg.filesArtifactIndex[filesArtifactName] = filesArtifact return nil } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index df8d8feab0..2f592a6a49 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -67,6 +67,81 @@ func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() } +func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { + packageId := "github.com/kurtosis-tech/plan-yaml-prac" + mainFunctionName := "" + relativePathToMainFile := "main.star" + + serializedScript := `def run(plan, args): + hi_files_artifact = plan.render_templates( + config={ + "hi.txt":struct( + template="hello world!", + data={} + ) + }, + name="hi-file" + ) + + plan.add_service( + name="tedi", + config=ServiceConfig( + image="ubuntu:latest", + cmd=["cat", "/root/hi.txt"], + ports={ + "dashboard":PortSpec( + number=1234, + application_protocol="http", + transport_protocol="TCP" + ) + }, + env_vars={ + "PASSWORD": "tedi" + }, + files={ + "/root": hi_files_artifact, + } + ) + ) +` + serializedJsonParams := "{}" + _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 2, instructionsPlan.Size()) + + pyg := NewPlanYamlGenerator( + instructionsPlan, + suite.serviceNetwork, + packageId, + suite.packageContentProvider, + "", // figure out if this is needed + noPackageReplaceOptions, + ) + yamlBytes, err := pyg.GenerateYaml() + require.NoError(suite.T(), err) + + expectedYamlString := `packageId: github.com/kurtosis-tech/postgres-package +services: +- name: tedi + image: ubuntu:latest + envVars: + - key: PASSWORD + value: tedi + ports: + - name: dashboard + number: 1234 + transportProtocol: TCP + applicationProtocol: http + files: + - name: hi_files_artifact +files_artifacts: + - name: hi_files_artifact + files: + - "/root" +` + require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) +} + func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorVerySimpleScript() { script := ` def run(plan): From 03a7535e367408f5b61b5a9c8b3533743f9cda06 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Sat, 17 Feb 2024 12:00:13 -0500 Subject: [PATCH 09/75] fix render templates impl --- .../server/startosis_engine/plan.yml | 33 +++++++++++++++++++ .../server/startosis_engine/plan_yaml.go | 2 +- .../startosis_engine/plan_yaml_generator.go | 20 +++++++---- .../plan_yaml_generator_test.go | 3 ++ 4 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 core/server/api_container/server/startosis_engine/plan.yml diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml new file mode 100644 index 0000000000..97c3b52cfd --- /dev/null +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -0,0 +1,33 @@ +packageId: github.com/kurtosis-tech/plan-yaml-prac +services: +- name: tedi + image: ubuntu:latest + command: + - cat + - /root/hi.txt + envVars: + - key: PASSWORD + value: tedi + ports: + - name: dashboard + number: 1234 + transportProtocol: TCP + applicationProtocol: http + files: + - mountPath: /root + filesArtifacts: + - uuid: dd21662c2137448d8ba42e50d7f41287 + name: hi-file +filesArtifacts: +- uuid: dd21662c2137448d8ba42e50d7f41287 + name: hi-file + files: + clear: "" + get: "" + items: "" + keys: "" + pop: "" + popitem: "" + setdefault: "" + update: "" + values: "" diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index de15722d6f..6064de76ab 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -59,7 +59,7 @@ type TransportProtocol string // FileMount represents a mount point for files. type FileMount struct { MountPath string `yaml:"mountPath,omitempty"` - filesArtifacts []*FilesArtifact // TODO: support persistent directories + FilesArtifacts []*FilesArtifact `yaml:"filesArtifacts,omitempty"` // TODO: support persistent directories } // Task represents a task to be executed. diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 877d55eabb..c772763077 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -103,6 +103,9 @@ func NewPlanYamlGenerator( planYaml: &PlanYaml{ PackageId: packageId, }, + filesArtifactIndex: map[string]*FilesArtifact{}, + serviceIndex: map[string]*Service{}, + taskIndex: map[string]*Task{}, } } @@ -218,7 +221,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // the only information we have about a files artifact that didn't already exist is the name // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args filesArtifact = &FilesArtifact{ - Name: identifier, // TODO: check that the identifier the files artifact name and NOT a files artifact uuid + Name: identifier, } pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) pyg.filesArtifactIndex[identifier] = filesArtifact @@ -226,7 +229,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc serviceFilesArtifacts = append(serviceFilesArtifacts, filesArtifact) } - fileMount.filesArtifacts = serviceFilesArtifacts + fileMount.FilesArtifacts = serviceFilesArtifacts service.Files = append(service.Files, fileMount) } @@ -259,19 +262,22 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(addServiceInstru // TODO: update the plan yaml based on an add_service } -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(addServiceInstruction *instructions_plan.ScheduledInstruction) error { +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(renderTemplatesInstruction *instructions_plan.ScheduledInstruction) error { + arguments := renderTemplatesInstruction.GetInstruction().GetArguments() var filesArtifact *FilesArtifact // get the name of returned files artifact - // give the FilesArtifact the uuid of the originating instruction - filesArtifactName := addServiceInstruction.GetReturnedValue().String() + artifactName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, render_templates.ArtifactNameArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to parse '%s'", render_templates.ArtifactNameArgName) + } + filesArtifactName := artifactName.GoString() filesArtifact = &FilesArtifact{ - Uuid: string(addServiceInstruction.GetUuid()), + Uuid: string(renderTemplatesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction Name: filesArtifactName, } // get files of returned files artifact off render templates config - arguments := addServiceInstruction.GetInstruction().GetArguments() renderTemplateConfig, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, render_templates.TemplateAndDataByDestinationRelFilepathArg) if err != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to parse '%s'", render_templates.TemplateAndDataByDestinationRelFilepathArg) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 2f592a6a49..6d8cab8dc2 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "net" + "os" "testing" ) @@ -139,6 +140,8 @@ files_artifacts: files: - "/root" ` + err = os.WriteFile("./plan.yml", yamlBytes, 0644) + require.NoError(suite.T(), err) require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) } From aef291ef25417cf46439714ab509809bc34c4c81 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Sat, 17 Feb 2024 12:47:43 -0500 Subject: [PATCH 10/75] impl upload files --- .../server/startosis_engine/plan.yml | 33 ------------ .../server/startosis_engine/plan_yaml.go | 10 ++-- .../startosis_engine/plan_yaml_generator.go | 50 +++++++++++++++---- .../plan_yaml_generator_test.go | 41 ++++----------- 4 files changed, 56 insertions(+), 78 deletions(-) delete mode 100644 core/server/api_container/server/startosis_engine/plan.yml diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml deleted file mode 100644 index 97c3b52cfd..0000000000 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ /dev/null @@ -1,33 +0,0 @@ -packageId: github.com/kurtosis-tech/plan-yaml-prac -services: -- name: tedi - image: ubuntu:latest - command: - - cat - - /root/hi.txt - envVars: - - key: PASSWORD - value: tedi - ports: - - name: dashboard - number: 1234 - transportProtocol: TCP - applicationProtocol: http - files: - - mountPath: /root - filesArtifacts: - - uuid: dd21662c2137448d8ba42e50d7f41287 - name: hi-file -filesArtifacts: -- uuid: dd21662c2137448d8ba42e50d7f41287 - name: hi-file - files: - clear: "" - get: "" - items: "" - keys: "" - pop: "" - popitem: "" - setdefault: "" - update: "" - values: "" diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 6064de76ab..50c57871ad 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -25,14 +25,16 @@ type Service struct { Entrypoint []string `yaml:"entrypoint,omitempty"` // done EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` // done Ports []*Port `yaml:"ports,omitempty"` // done - Files []*FileMount `yaml:"files,omitempty"` + Files []*FileMount `yaml:"files,omitempty"` // done + + // TODO: support remaining fields in the ServiceConfig } // FilesArtifact represents a collection of files. type FilesArtifact struct { - Uuid string `yaml:"uuid,omitempty"` - Name string `yaml:"name,omitempty"` - Files map[string]string `yaml:"files,omitempty"` + Uuid string `yaml:"uuid,omitempty"` + Name string `yaml:"name,omitempty"` + Files []string `yaml:"files,omitempty"` } // EnvironmentVariable represents an environment variable. diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index c772763077..dee90d184e 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -8,7 +8,9 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" @@ -130,6 +132,8 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { pyg.updatePlanYamlFromRunPython(scheduledInstruction) case render_templates.RenderTemplatesBuiltinName: err = pyg.updatePlanYamlFromRenderTemplates(scheduledInstruction) + case upload_files.UploadFilesBuiltinName: + err = pyg.updatePlanYamlFromUploadFiles(scheduledInstruction) default: return nil, nil } @@ -256,35 +260,59 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(addServiceInstruct // TODO: update the plan yaml based on an add_service } -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(addServiceInstruction *instructions_plan.ScheduledInstruction) error { - panic("remove service not implemented yet") +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(uploadFilesInstruction *instructions_plan.ScheduledInstruction) error { + var filesArtifact *FilesArtifact + + // get the name of returned files artifact + filesArtifactName, castErr := kurtosis_types.SafeCastToString(uploadFilesInstruction.GetReturnedValue(), "files artifact name") + if castErr != nil { + return castErr + } + filesArtifact = &FilesArtifact{ + Uuid: string(uploadFilesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction + Name: filesArtifactName, + } + + // get files of returned files artifact off render templates config + arguments := uploadFilesInstruction.GetInstruction().GetArguments() + src, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, upload_files.SrcArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", upload_files.SrcArgName) + } + filesArtifact.Files = []string{src.GoString()} + + // add the files artifact to the yaml and index + pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) + pyg.filesArtifactIndex[filesArtifactName] = filesArtifact return nil - // TODO: update the plan yaml based on an add_service } func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(renderTemplatesInstruction *instructions_plan.ScheduledInstruction) error { - arguments := renderTemplatesInstruction.GetInstruction().GetArguments() var filesArtifact *FilesArtifact // get the name of returned files artifact - artifactName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, render_templates.ArtifactNameArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to parse '%s'", render_templates.ArtifactNameArgName) + filesArtifactName, castErr := kurtosis_types.SafeCastToString(renderTemplatesInstruction.GetReturnedValue(), "files artifact name") + if castErr != nil { + return castErr } - filesArtifactName := artifactName.GoString() filesArtifact = &FilesArtifact{ Uuid: string(renderTemplatesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction Name: filesArtifactName, } // get files of returned files artifact off render templates config + arguments := renderTemplatesInstruction.GetInstruction().GetArguments() renderTemplateConfig, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, render_templates.TemplateAndDataByDestinationRelFilepathArg) if err != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to parse '%s'", render_templates.TemplateAndDataByDestinationRelFilepathArg) } - files := map[string]string{} - for _, filepath := range renderTemplateConfig.AttrNames() { - files[filepath] = "" // TODO: are files just the file names/the paths at those files? is it possible to get any other information about them + files := []string{} + for _, filepath := range renderTemplateConfig.Keys() { + filepathStr, castErr := kurtosis_types.SafeCastToString(filepath, "filepath") + if castErr != nil { + return castErr + } + files = append(files, filepathStr) } filesArtifact.Files = files diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 6d8cab8dc2..a7cd23d6b3 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -60,27 +60,28 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.serviceNetwork.EXPECT().GetApiContainerInfo().Return(apiContainerInfo) } -func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { - suite.Run(t, new(PlanYamlGeneratorTestSuite)) -} +//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { +// suite.Run(t, new(PlanYamlGeneratorTestSuite)) +//} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() } func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { + barModulePath := "github.com/foo/bar/hi.txt" + seedModules := map[string]string{ + barModulePath: "a=\"World!\"", + } + require.Nil(suite.T(), suite.packageContentProvider.BulkAddFileContent(seedModules)) + packageId := "github.com/kurtosis-tech/plan-yaml-prac" mainFunctionName := "" relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - hi_files_artifact = plan.render_templates( - config={ - "hi.txt":struct( - template="hello world!", - data={} - ) - }, + hi_files_artifact = plan.upload_files( + src="github.com/foo/bar/hi.txt", name="hi-file" ) @@ -121,28 +122,8 @@ func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { yamlBytes, err := pyg.GenerateYaml() require.NoError(suite.T(), err) - expectedYamlString := `packageId: github.com/kurtosis-tech/postgres-package -services: -- name: tedi - image: ubuntu:latest - envVars: - - key: PASSWORD - value: tedi - ports: - - name: dashboard - number: 1234 - transportProtocol: TCP - applicationProtocol: http - files: - - name: hi_files_artifact -files_artifacts: - - name: hi_files_artifact - files: - - "/root" -` err = os.WriteFile("./plan.yml", yamlBytes, 0644) require.NoError(suite.T(), err) - require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) } func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorVerySimpleScript() { From 458fd754266d24db6b4db9fc73cfedd50c0ba00e Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Sat, 17 Feb 2024 13:45:59 -0500 Subject: [PATCH 11/75] start impl run sh --- .../server/startosis_engine/plan.yml | 9 ++ .../server/startosis_engine/plan_yaml.go | 16 ++- .../startosis_engine/plan_yaml_generator.go | 111 +++++++++--------- .../plan_yaml_generator_test.go | 27 ++--- 4 files changed, 83 insertions(+), 80 deletions(-) create mode 100644 core/server/api_container/server/startosis_engine/plan.yml diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml new file mode 100644 index 0000000000..e35923feb5 --- /dev/null +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -0,0 +1,9 @@ +packageId: github.com/kurtosis-tech/plan-yaml-prac +services: +- name: database + image: postgres:latest +- name: tedi + image: ubuntu:latest + envVars: + - key: DB_URL + value: '{{kurtosis:7e76b78877ff4b8189840894ebee2664:ip_address.runtime_value}}' diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 50c57871ad..4d0cb9fa01 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -66,15 +66,13 @@ type FileMount struct { // Task represents a task to be executed. type Task struct { - TaskType TaskType `yaml:"taskType,omitempty"` - Name string `yaml:"name,omitempty"` - Command string `yaml:"command,omitempty"` - Image string `yaml:"image,omitempty"` - EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` - Files []*FileMount `yaml:"files,omitempty"` - Store []string `yaml:"store,omitempty"` - ShouldWait bool `yaml:"shouldWait,omitempty"` - Wait string `yaml:"wait,omitempty"` + TaskType TaskType `yaml:"taskType,omitempty"` + Name string `yaml:"name,omitempty"` + Command string `yaml:"command,omitempty"` + Image string `yaml:"image,omitempty"` + EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` + Files []*FileMount `yaml:"files,omitempty"` + Store []*FilesArtifact `yaml:"store,omitempty"` } // TaskType represents the type of task. diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index dee90d184e..44a482b77f 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -66,7 +66,7 @@ type PlanYamlGenerator interface { } type PlanYamlGeneratorImpl struct { - // Plan generetated by an interpretation of a starlark script of package + // Plan generated by an interpretation of a Starlark script of package plan *instructions_plan.InstructionsPlan serviceNetwork service_network.ServiceNetwork @@ -77,13 +77,9 @@ type PlanYamlGeneratorImpl struct { packageReplaceOptions map[string]string - // index of files artifact uuid - // this provides a look up to see what files artifacts have been processed filesArtifactIndex map[string]*FilesArtifact - - serviceIndex map[string]*Service - - taskIndex map[string]*Task + serviceIndex map[string]*Service + taskIndex map[string]*Task // Representation of plan in yaml the plan is being processed, the yaml gets updated planYaml *PlanYaml @@ -125,11 +121,11 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { case add_service.AddServiceBuiltinName: err = pyg.updatePlanYamlFromAddService(scheduledInstruction) case remove_service.RemoveServiceBuiltinName: - pyg.updatePlanYamlFromRemoveService(scheduledInstruction) + err = pyg.updatePlanYamlFromRemoveService(scheduledInstruction) case tasks.RunShBuiltinName: - pyg.updatePlanYamlFromRunSh(scheduledInstruction) + err = pyg.updatePlanYamlFromRunSh(scheduledInstruction) case tasks.RunPythonBuiltinName: - pyg.updatePlanYamlFromRunPython(scheduledInstruction) + err = pyg.updatePlanYamlFromRunPython(scheduledInstruction) case render_templates.RenderTemplatesBuiltinName: err = pyg.updatePlanYamlFromRenderTemplates(scheduledInstruction) case upload_files.UploadFilesBuiltinName: @@ -205,36 +201,40 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // - add it to the service's file mount accordingly // - add the files artifact to the plan service.Files = []*FileMount{} - for mountPath, artifactIdentifiers := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { - var fileMount *FileMount - fileMount = &FileMount{ - MountPath: mountPath, - } + serviceFilesArtifactExpansions := serviceConfig.GetFilesArtifactsExpansion() + if serviceFilesArtifactExpansions != nil { + for mountPath, artifactIdentifiers := range serviceFilesArtifactExpansions.ServiceDirpathsToArtifactIdentifiers { + var fileMount *FileMount + fileMount = &FileMount{ + MountPath: mountPath, + } - var serviceFilesArtifacts []*FilesArtifact - for _, identifier := range artifactIdentifiers { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if potentialFilesArtifact, ok := pyg.filesArtifactIndex[identifier]; ok { - filesArtifact = &FilesArtifact{ - Uuid: potentialFilesArtifact.Uuid, - Name: potentialFilesArtifact.Name, - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ - Name: identifier, + var serviceFilesArtifacts []*FilesArtifact + for _, identifier := range artifactIdentifiers { + var filesArtifact *FilesArtifact + // if there's already a files artifact that exists with this name from a previous instruction, reference that + if potentialFilesArtifact, ok := pyg.filesArtifactIndex[identifier]; ok { + filesArtifact = &FilesArtifact{ + Uuid: potentialFilesArtifact.Uuid, + Name: potentialFilesArtifact.Name, + } + } else { + // otherwise create a new one + // the only information we have about a files artifact that didn't already exist is the name + // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args + filesArtifact = &FilesArtifact{ + Name: identifier, + } + pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) + pyg.filesArtifactIndex[identifier] = filesArtifact } - pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) - pyg.filesArtifactIndex[identifier] = filesArtifact + serviceFilesArtifacts = append(serviceFilesArtifacts, filesArtifact) } - serviceFilesArtifacts = append(serviceFilesArtifacts, filesArtifact) + + fileMount.FilesArtifacts = serviceFilesArtifacts + service.Files = append(service.Files, fileMount) } - fileMount.FilesArtifacts = serviceFilesArtifacts - service.Files = append(service.Files, fileMount) } pyg.planYaml.Services = append(pyg.planYaml.Services, service) @@ -242,24 +242,6 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc return nil } -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(RemoveServiceInstruction *instructions_plan.ScheduledInstruction) error { - panic("remove service not implemented yet") - return nil - // TODO: update the plan yaml based on an add_service -} - -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(addServiceInstruction *instructions_plan.ScheduledInstruction) error { - panic("run sh not implemented yet") - return nil - // TODO: update the plan yaml based on an add_service -} - -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(addServiceInstruction *instructions_plan.ScheduledInstruction) error { - panic("run python not implemented yet") - return nil - // TODO: update the plan yaml based on an add_service -} - func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(uploadFilesInstruction *instructions_plan.ScheduledInstruction) error { var filesArtifact *FilesArtifact @@ -323,6 +305,29 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(renderTempla return nil } +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *instructions_plan.ScheduledInstruction) error { + panic("run sh not implemented yet") + return nil + // TODO: update the plan yaml based on an add_service +} + +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstruction *instructions_plan.ScheduledInstruction) error { + panic("run python not implemented yet") + return nil + // TODO: update the plan yaml based on an add_service +} + +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreService(storeServiceInstruction *instructions_plan.ScheduledInstruction) error { + panic("") + return nil +} + +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(RemoveServiceInstruction *instructions_plan.ScheduledInstruction) error { + panic("remove service not implemented yet") + return nil + // TODO: update the plan yaml based on an add_service +} + func convertPlanYamlToYaml(planYaml *PlanYaml) ([]byte, error) { // unravel all the indices and add them to the plan // add some sort of tie breaking so yaml's are deterministic diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index a7cd23d6b3..4f6e6f5100 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -60,9 +60,9 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.serviceNetwork.EXPECT().GetApiContainerInfo().Return(apiContainerInfo) } -//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { -// suite.Run(t, new(PlanYamlGeneratorTestSuite)) -//} +func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { + suite.Run(t, new(PlanYamlGeneratorTestSuite)) +} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() @@ -80,29 +80,20 @@ func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - hi_files_artifact = plan.upload_files( - src="github.com/foo/bar/hi.txt", - name="hi-file" + database = plan.add_service( + name="database", + config=ServiceConfig( + image="postgres:latest", + ) ) plan.add_service( name="tedi", config=ServiceConfig( image="ubuntu:latest", - cmd=["cat", "/root/hi.txt"], - ports={ - "dashboard":PortSpec( - number=1234, - application_protocol="http", - transport_protocol="TCP" - ) - }, env_vars={ - "PASSWORD": "tedi" + "DB_URL": database.ip_address }, - files={ - "/root": hi_files_artifact, - } ) ) ` From 9f5f44264ea42efc7f23dc2663c2546fc169706f Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 20 Feb 2024 15:12:39 -0500 Subject: [PATCH 12/75] adjust task yaml def --- .../server/startosis_engine/plan_yaml.go | 22 ++++++++++++------- .../startosis_engine/plan_yaml_generator.go | 2 +- .../plan_yaml_generator_test.go | 2 -- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 4d0cb9fa01..8f43c1c523 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -66,14 +66,20 @@ type FileMount struct { // Task represents a task to be executed. type Task struct { - TaskType TaskType `yaml:"taskType,omitempty"` - Name string `yaml:"name,omitempty"` - Command string `yaml:"command,omitempty"` - Image string `yaml:"image,omitempty"` - EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` - Files []*FileMount `yaml:"files,omitempty"` - Store []*FilesArtifact `yaml:"store,omitempty"` + TaskType TaskType `yaml:"taskType,omitempty"` + Uuid string `yaml:"uuid"` + RunCmd string `yaml:"command,omitempty"` + Image string `yaml:"image,omitempty"` + Files []*FileMount `yaml:"files,omitempty"` + Store []*FilesArtifact `yaml:"store,omitempty"` + + // only exists on SHELL tasks + EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` + + // only exists on PYTHON tasks + PythonPackages []string `yaml:"pythonPackages"` + PythonArgs []string `yaml:"pythonArgs"` } -// TaskType represents the type of task. +// TaskType represents the type of task (either PYTHON or SHELL) type TaskType string diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 44a482b77f..c9824ba627 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -31,7 +31,7 @@ import ( // run_sh -> Task but returns a files artifact so create that // run_python -> Task but returns a files artifact so create that // -// go through all the kurtosis builtins and figure out which ones we need to accommodate for and which ones we don't need to accomodate for +// go through all the kurtosis builtins and figure out which ones we need to accommodate for and which ones we don't need to accommodate for // PlanYamlGenerator generates a yaml representation of a [plan]. type PlanYamlGenerator interface { diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 4f6e6f5100..778b1520dd 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -302,8 +302,6 @@ func (suite *PlanYamlGeneratorTestSuite) TestConvertPlanYamlToYamlBytes(t *testi tasks := []*Task{ { TaskType: PYTHON, - Name: "updateSomething", - Command: "do something", Image: "jqcurl", EnvVars: []*EnvironmentVariable{}, }, From 52f003c70881baee790589641998ec3ff28fffea Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 20 Feb 2024 16:57:29 -0500 Subject: [PATCH 13/75] impl run sh checkpoint --- .../kurtosis_instruction/tasks/run_sh.go | 4 +- .../server/startosis_engine/plan.yml | 21 ++-- .../server/startosis_engine/plan_yaml.go | 5 +- .../startosis_engine/plan_yaml_generator.go | 117 +++++++++++++++++- .../plan_yaml_generator_test.go | 32 +++-- 5 files changed, 149 insertions(+), 30 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go index 4935dacb60..a95f945b33 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go @@ -26,7 +26,7 @@ import ( const ( RunShBuiltinName = "run_sh" - defaultRunShImageName = "badouralix/curl-jq" + DefaultRunShImageName = "badouralix/curl-jq" ) func NewRunShService(serviceNetwork service_network.ServiceNetwork, runtimeValueStore *runtime_value_store.RuntimeValueStore, nonBlockingMode bool) *kurtosis_plan_instruction.KurtosisPlanInstruction { @@ -131,7 +131,7 @@ func (builtin *RunShCapabilities) Interpret(_ string, arguments *builtin_argumen } image = imageStarlark.GoString() } else { - image = defaultRunShImageName + image = DefaultRunShImageName } var filesArtifactExpansion *service_directory.FilesArtifactsExpansion diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index e35923feb5..18a0f1ada8 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,9 +1,14 @@ packageId: github.com/kurtosis-tech/plan-yaml-prac -services: -- name: database - image: postgres:latest -- name: tedi - image: ubuntu:latest - envVars: - - key: DB_URL - value: '{{kurtosis:7e76b78877ff4b8189840894ebee2664:ip_address.runtime_value}}' +filesArtifacts: +- uuid: a623b3ee1e794f788a2308f3fecdcd05 + name: bye-file + files: + - bye.txt +tasks: +- taskType: sh + uuid: 50022233681a4c398489e5d79818aeed + command: echo $(cat /root/bye.txt) > hi.txt + image: badouralix/curl-jq + envVar: + - key: HELLO + value: Hello! diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 8f43c1c523..26db3e0bfc 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -9,6 +9,7 @@ const ( PYTHON TaskType = "python" ) +// TODO: there's really no point in making any of these references, consider just making them copies type PlanYaml struct { PackageId string `yaml:"packageId,omitempty"` Services []*Service `yaml:"services,omitempty"` @@ -77,8 +78,8 @@ type Task struct { EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` // only exists on PYTHON tasks - PythonPackages []string `yaml:"pythonPackages"` - PythonArgs []string `yaml:"pythonArgs"` + PythonPackages []string `yaml:"pythonPackages,omitempty"` + PythonArgs []string `yaml:"pythonArgs,omitempty"` } // TaskType represents the type of task (either PYTHON or SHELL) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index c9824ba627..8af9b0efa6 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -33,6 +33,8 @@ import ( // // go through all the kurtosis builtins and figure out which ones we need to accommodate for and which ones we don't need to accommodate for +// TODO: refactor this so plan yaml is generated as instructionsPlan is created, otherwise a lot of duplicate operations happen to parse the arguments + // PlanYamlGenerator generates a yaml representation of a [plan]. type PlanYamlGenerator interface { // GenerateYaml converts [plan] into a byte array that represents a yaml with information in the plan. @@ -77,9 +79,18 @@ type PlanYamlGeneratorImpl struct { packageReplaceOptions map[string]string + // stores all future references returned from instructions so they can be referenced later + futureReferencesStore map[string]string + + // technically files artifacts are future references but we store them separately bc they are easily identifiable + // and have a distinct structure (FilesArtifact) filesArtifactIndex map[string]*FilesArtifact - serviceIndex map[string]*Service - taskIndex map[string]*Task + + // Store service index needed to see in case a service is referenced by a remove service, or store service later in the plan + serviceIndex map[string]*Service + + // TODO: do we need a task index? + taskIndex map[string]*Task // Representation of plan in yaml the plan is being processed, the yaml gets updated planYaml *PlanYaml @@ -306,9 +317,105 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(renderTempla } func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *instructions_plan.ScheduledInstruction) error { - panic("run sh not implemented yet") + var task *Task + + // set instruction uuid + task = &Task{ + Uuid: string(runShInstruction.GetUuid()), + TaskType: SHELL, + } + + // get runcmd, image, env vars and set them in the yaml + arguments := runShInstruction.GetInstruction().GetArguments() + runCommand, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, tasks.RunArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.RunArgName) + } + task.RunCmd = runCommand.GoString() + + var image string + if arguments.IsSet(tasks.ImageNameArgName) { + imageStarlark, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, tasks.ImageNameArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.ImageNameArgName) + } + image = imageStarlark.GoString() + } else { + image = tasks.DefaultRunShImageName + } + task.Image = image + + var envVars []*EnvironmentVariable + var envVarsMap map[string]string + if arguments.IsSet(tasks.EnvVarsArgName) { + envVarsStarlark, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, tasks.EnvVarsArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.EnvVarsArgName) + } + if envVarsStarlark != nil && envVarsStarlark.Len() > 0 { + var interpretationErr *startosis_errors.InterpretationError + envVarsMap, interpretationErr = kurtosis_types.SafeCastToMapStringString(envVarsStarlark, tasks.EnvVarsArgName) + if interpretationErr != nil { + return interpretationErr + } + } + } + for key, val := range envVarsMap { + envVars = append(envVars, &EnvironmentVariable{ + Key: key, + Value: val, + }) + } + task.EnvVars = envVars + + // for files: + // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid + // 2. the referenced files artifact is new, in which case we add it to the plan + if arguments.IsSet(tasks.FilesArgName) { + filesStarlark, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, tasks.FilesArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.FilesArgName) + } + if filesStarlark.Len() > 0 { + filesArtifactMountDirPaths, interpretationErr := kurtosis_types.SafeCastToMapStringString(filesStarlark, tasks.FilesArgName) + if interpretationErr != nil { + return interpretationErr + } + for mountPath, fileArtifactName := range filesArtifactMountDirPaths { + var filesArtifact *FilesArtifact + // if there's already a files artifact that exists with this name from a previous instruction, reference that + if potentialFilesArtifact, ok := pyg.filesArtifactIndex[fileArtifactName]; ok { + filesArtifact = &FilesArtifact{ + Uuid: potentialFilesArtifact.Uuid, + Name: potentialFilesArtifact.Name, + } + } else { + // otherwise create a new one + // the only information we have about a files artifact that didn't already exist is the name + // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args + filesArtifact = &FilesArtifact{ + Name: fileArtifactName, + } + pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) + pyg.filesArtifactIndex[fileArtifactName] = filesArtifact + } + + task.Files = append(task.Files, &FileMount{ + MountPath: mountPath, + FilesArtifacts: []*FilesArtifact{filesArtifact}, + }) + } + } + } + + // for store + // - all files artifacts product from store are new files artifact that are added to the plan + // - add them to files artifacts list + // - add them to the store section of run sh + + // add task to index, do we even need a tasks index? + pyg.planYaml.Tasks = append(pyg.planYaml.Tasks, task) return nil - // TODO: update the plan yaml based on an add_service } func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstruction *instructions_plan.ScheduledInstruction) error { @@ -318,7 +425,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi } func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreService(storeServiceInstruction *instructions_plan.ScheduledInstruction) error { - panic("") + panic("store service not implemented yet") return nil } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 778b1520dd..3c73701694 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -80,21 +80,27 @@ func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - database = plan.add_service( - name="database", - config=ServiceConfig( - image="postgres:latest", - ) + bye_files_artifact = plan.render_templates( + name="bye-file", + config={ + "bye.txt": struct( + template="Bye bye!", + data={} + ) + } ) - plan.add_service( - name="tedi", - config=ServiceConfig( - image="ubuntu:latest", - env_vars={ - "DB_URL": database.ip_address - }, - ) + plan.run_sh( + run="echo $(cat /root/bye.txt) > hi.txt", + env_vars = { + "HELLO": "Hello!" + }, + files = { + "/root": bye_files_artifact, + }, + store=[ + StoreSpec(src="/hi.txt", name="hi-file") + ] ) ` serializedJsonParams := "{}" From eff877f897640c094a611cab59234e57983de61e Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 20 Feb 2024 20:03:51 -0500 Subject: [PATCH 14/75] finish run sh impl --- .../kurtosis_instruction/tasks/run_python.go | 2 +- .../kurtosis_instruction/tasks/run_sh.go | 2 +- .../tasks/tasks_shared.go | 2 +- .../server/startosis_engine/plan.yml | 17 ++++++++-- .../server/startosis_engine/plan_yaml.go | 15 +++++---- .../startosis_engine/plan_yaml_generator.go | 32 +++++++++++++++++-- 6 files changed, 56 insertions(+), 14 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go index e23aa1e328..d0b346719c 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go @@ -217,7 +217,7 @@ func (builtin *RunPythonCapabilities) Interpret(_ string, arguments *builtin_arg } if arguments.IsSet(StoreFilesArgName) { - storeSpecList, interpretationErr := parseStoreFilesArg(builtin.serviceNetwork, arguments) + storeSpecList, interpretationErr := ParseStoreFilesArg(builtin.serviceNetwork, arguments) if interpretationErr != nil { return nil, interpretationErr } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go index a95f945b33..19c8d39531 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go @@ -168,7 +168,7 @@ func (builtin *RunShCapabilities) Interpret(_ string, arguments *builtin_argumen } if arguments.IsSet(StoreFilesArgName) { - storeSpecList, interpretationErr := parseStoreFilesArg(builtin.serviceNetwork, arguments) + storeSpecList, interpretationErr := ParseStoreFilesArg(builtin.serviceNetwork, arguments) if interpretationErr != nil { return nil, interpretationErr } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/tasks_shared.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/tasks_shared.go index 9e683100bf..1c88b702f4 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/tasks_shared.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/tasks_shared.go @@ -50,7 +50,7 @@ const ( var runTailCommandToPreventContainerToStopOnCreating = []string{"tail", "-f", "/dev/null"} -func parseStoreFilesArg(serviceNetwork service_network.ServiceNetwork, arguments *builtin_argument.ArgumentValuesSet) ([]*store_spec.StoreSpec, *startosis_errors.InterpretationError) { +func ParseStoreFilesArg(serviceNetwork service_network.ServiceNetwork, arguments *builtin_argument.ArgumentValuesSet) ([]*store_spec.StoreSpec, *startosis_errors.InterpretationError) { var result []*store_spec.StoreSpec storeFilesList, err := builtin_argument.ExtractArgumentValue[*starlark.List](arguments, StoreFilesArgName) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index 18a0f1ada8..fb490a44c7 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,14 +1,27 @@ packageId: github.com/kurtosis-tech/plan-yaml-prac filesArtifacts: -- uuid: a623b3ee1e794f788a2308f3fecdcd05 +- uuid: 3be6717c9bd74d9292f085bf87e8aef0 name: bye-file files: - bye.txt +- uuid: 4960a37e86e24f06966e17a2f2a78e7e + name: hi-file + files: + - /hi.txt tasks: - taskType: sh - uuid: 50022233681a4c398489e5d79818aeed + uuid: 4960a37e86e24f06966e17a2f2a78e7e command: echo $(cat /root/bye.txt) > hi.txt image: badouralix/curl-jq + files: + - mountPath: /root + filesArtifacts: + - uuid: 3be6717c9bd74d9292f085bf87e8aef0 + name: bye-file + store: + - name: hi-file + files: + - /hi.txt envVar: - key: HELLO value: Hello! diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 26db3e0bfc..4a9ad87f3a 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -67,15 +67,16 @@ type FileMount struct { // Task represents a task to be executed. type Task struct { - TaskType TaskType `yaml:"taskType,omitempty"` - Uuid string `yaml:"uuid"` - RunCmd string `yaml:"command,omitempty"` - Image string `yaml:"image,omitempty"` - Files []*FileMount `yaml:"files,omitempty"` - Store []*FilesArtifact `yaml:"store,omitempty"` + TaskType TaskType `yaml:"taskType,omitempty"` // done + Uuid string `yaml:"uuid"` // done + Name string `yaml:"name,omitempty"` // done + RunCmd string `yaml:"command,omitempty"` // done + Image string `yaml:"image,omitempty"` // done + Files []*FileMount `yaml:"files,omitempty"` // done + Store []*FilesArtifact `yaml:"store,omitempty"` // done // only exists on SHELL tasks - EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` + EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` // done // only exists on PYTHON tasks PythonPackages []string `yaml:"pythonPackages,omitempty"` diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 8af9b0efa6..369cfac350 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -159,7 +159,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // start building Service Yaml object service := &Service{} - //service.Uuid = string(addServiceInstruction.GetUuid()) // TODO: mock uuid generator so I can add uuids, uuid of the object is the uuid of the instruction that created that object + service.Uuid = string(addServiceInstruction.GetUuid()) // TODO: mock uuid generator for testing serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) if err != nil { @@ -320,8 +320,14 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst var task *Task // set instruction uuid + instructionUuid := string(runShInstruction.GetUuid()) + // get the name of + //runShInstructionName, castErr := kurtosis_types.SafeCastToString(runShInstruction.GetInstruction(), "") + //if castErr != nil { + // return castErr + //} task = &Task{ - Uuid: string(runShInstruction.GetUuid()), + Uuid: instructionUuid, TaskType: SHELL, } @@ -396,6 +402,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst filesArtifact = &FilesArtifact{ Name: fileArtifactName, } + // add to the index and append to the plan yaml pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) pyg.filesArtifactIndex[fileArtifactName] = filesArtifact } @@ -412,6 +419,27 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst // - all files artifacts product from store are new files artifact that are added to the plan // - add them to files artifacts list // - add them to the store section of run sh + var store []*FilesArtifact + storeSpecs, err := tasks.ParseStoreFilesArg(pyg.serviceNetwork, arguments) + // TODO: catch this error + //if err != startosis_errors.WrapWithInterpretationError(nil, "") { catch this error + // return err + //} + for _, storeSpec := range storeSpecs { + // add the FilesArtifact to list of all files artifacts and index + var newFilesArtifactFromStoreSpec = &FilesArtifact{ + Uuid: instructionUuid, + Name: storeSpec.GetName(), + Files: []string{storeSpec.GetSrc()}, + } + pyg.filesArtifactIndex[storeSpec.GetName()] = newFilesArtifactFromStoreSpec + pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, newFilesArtifactFromStoreSpec) + store = append(store, &FilesArtifact{ + Name: storeSpec.GetName(), + Files: []string{storeSpec.GetSrc()}, + }) + } + task.Store = store // TODO: be consistent about how I'm setting lists in the plan yamls, probably should add wrappers to the plan yaml // add task to index, do we even need a tasks index? pyg.planYaml.Tasks = append(pyg.planYaml.Tasks, task) From 32b53b11398c5d1498f388094020a70f080e999c Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 20 Feb 2024 21:09:11 -0500 Subject: [PATCH 15/75] impl run python --- .../server/startosis_engine/plan.yml | 23 +-- .../startosis_engine/plan_yaml_generator.go | 157 +++++++++++++++++- .../plan_yaml_generator_test.go | 19 ++- 3 files changed, 182 insertions(+), 17 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index fb490a44c7..fdc0b24f4d 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,27 +1,30 @@ packageId: github.com/kurtosis-tech/plan-yaml-prac filesArtifacts: -- uuid: 3be6717c9bd74d9292f085bf87e8aef0 +- uuid: e620890750a54f1ca98ac962c7bd3b06 name: bye-file files: - bye.txt -- uuid: 4960a37e86e24f06966e17a2f2a78e7e +- uuid: b09ae123685241fdae0c59b8b2ba0171 name: hi-file files: - /hi.txt tasks: -- taskType: sh - uuid: 4960a37e86e24f06966e17a2f2a78e7e - command: echo $(cat /root/bye.txt) > hi.txt - image: badouralix/curl-jq +- taskType: python + uuid: b09ae123685241fdae0c59b8b2ba0171 + command: "\nimport requests\nresponse = requests.get(\"https://docs.kurtosis.com\")\nprint(response.status_code) + \ \n " + image: python:3.11-alpine files: - mountPath: /root filesArtifacts: - - uuid: 3be6717c9bd74d9292f085bf87e8aef0 + - uuid: e620890750a54f1ca98ac962c7bd3b06 name: bye-file store: - name: hi-file files: - /hi.txt - envVar: - - key: HELLO - value: Hello! + pythonPackages: + - selenium + - requests + pythonArgs: + - something diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 369cfac350..b1344446b7 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -447,9 +447,162 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst } func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstruction *instructions_plan.ScheduledInstruction) error { - panic("run python not implemented yet") + var task *Task + + // set instruction uuid + instructionUuid := string(runPythonInstruction.GetUuid()) + // get the name of + //runShInstructionName, castErr := kurtosis_types.SafeCastToString(runShInstruction.GetInstruction(), "") + //if castErr != nil { + // return castErr + //} + task = &Task{ + Uuid: instructionUuid, + TaskType: PYTHON, + } + + // get runcmd, image and set them in the yaml + arguments := runPythonInstruction.GetInstruction().GetArguments() + runCommand, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, tasks.RunArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.RunArgName) + } + task.RunCmd = runCommand.GoString() + + var image string + if arguments.IsSet(tasks.ImageNameArgName) { + imageStarlark, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, tasks.ImageNameArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.ImageNameArgName) + } + image = imageStarlark.GoString() + } else { + image = tasks.DefaultRunShImageName + } + task.Image = image + + var envVars []*EnvironmentVariable + var envVarsMap map[string]string + if arguments.IsSet(tasks.EnvVarsArgName) { + envVarsStarlark, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, tasks.EnvVarsArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.EnvVarsArgName) + } + if envVarsStarlark != nil && envVarsStarlark.Len() > 0 { + var interpretationErr *startosis_errors.InterpretationError + envVarsMap, interpretationErr = kurtosis_types.SafeCastToMapStringString(envVarsStarlark, tasks.EnvVarsArgName) + if interpretationErr != nil { + return interpretationErr + } + } + } + for key, val := range envVarsMap { + envVars = append(envVars, &EnvironmentVariable{ + Key: key, + Value: val, + }) + } + task.EnvVars = envVars + + // python args and python packages + if arguments.IsSet(tasks.PythonArgumentsArgName) { + argsValue, err := builtin_argument.ExtractArgumentValue[*starlark.List](arguments, tasks.PythonArgumentsArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "error occurred while extracting passed argument information") + } + argsList, sliceParsingErr := kurtosis_types.SafeCastToStringSlice(argsValue, tasks.PythonArgumentsArgName) + if sliceParsingErr != nil { + return startosis_errors.WrapWithInterpretationError(err, "error occurred while converting Starlark list of passed arguments to a golang string slice") + } + for _, arg := range argsList { + task.PythonArgs = append(task.PythonArgs, arg) + } + } + + if arguments.IsSet(tasks.PackagesArgName) { + packagesValue, err := builtin_argument.ExtractArgumentValue[*starlark.List](arguments, tasks.PackagesArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "error occurred while extracting packages information") + } + packagesList, sliceParsingErr := kurtosis_types.SafeCastToStringSlice(packagesValue, tasks.PackagesArgName) + if sliceParsingErr != nil { + return startosis_errors.WrapWithInterpretationError(err, "error occurred while converting Starlark list of packages to a golang string slice") + } + for _, pkg := range packagesList { + task.PythonPackages = append(task.PythonPackages, pkg) + } + } + + // for files: + // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid + // 2. the referenced files artifact is new, in which case we add it to the plan + if arguments.IsSet(tasks.FilesArgName) { + filesStarlark, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, tasks.FilesArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.FilesArgName) + } + if filesStarlark.Len() > 0 { + filesArtifactMountDirPaths, interpretationErr := kurtosis_types.SafeCastToMapStringString(filesStarlark, tasks.FilesArgName) + if interpretationErr != nil { + return interpretationErr + } + for mountPath, fileArtifactName := range filesArtifactMountDirPaths { + var filesArtifact *FilesArtifact + // if there's already a files artifact that exists with this name from a previous instruction, reference that + if potentialFilesArtifact, ok := pyg.filesArtifactIndex[fileArtifactName]; ok { + filesArtifact = &FilesArtifact{ + Uuid: potentialFilesArtifact.Uuid, + Name: potentialFilesArtifact.Name, + } + } else { + // otherwise create a new one + // the only information we have about a files artifact that didn't already exist is the name + // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args + filesArtifact = &FilesArtifact{ + Name: fileArtifactName, + } + // add to the index and append to the plan yaml + pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) + pyg.filesArtifactIndex[fileArtifactName] = filesArtifact + } + + task.Files = append(task.Files, &FileMount{ + MountPath: mountPath, + FilesArtifacts: []*FilesArtifact{filesArtifact}, + }) + } + } + } + + // for store + // - all files artifacts product from store are new files artifact that are added to the plan + // - add them to files artifacts list + // - add them to the store section of run sh + var store []*FilesArtifact + storeSpecs, err := tasks.ParseStoreFilesArg(pyg.serviceNetwork, arguments) + // TODO: catch this error + //if err != startosis_errors.WrapWithInterpretationError(nil, "") { catch this error + // return err + //} + for _, storeSpec := range storeSpecs { + // add the FilesArtifact to list of all files artifacts and index + var newFilesArtifactFromStoreSpec = &FilesArtifact{ + Uuid: instructionUuid, + Name: storeSpec.GetName(), + Files: []string{storeSpec.GetSrc()}, + } + pyg.filesArtifactIndex[storeSpec.GetName()] = newFilesArtifactFromStoreSpec + pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, newFilesArtifactFromStoreSpec) + store = append(store, &FilesArtifact{ + Name: storeSpec.GetName(), + Files: []string{storeSpec.GetSrc()}, + }) + } + task.Store = store // TODO: be consistent about how I'm setting lists in the plan yamls, probably should add wrappers to the plan yaml + + // add task to index, do we even need a tasks index? + pyg.planYaml.Tasks = append(pyg.planYaml.Tasks, task) return nil - // TODO: update the plan yaml based on an add_service } func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreService(storeServiceInstruction *instructions_plan.ScheduledInstruction) error { diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 3c73701694..f08e81d535 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -90,11 +90,20 @@ func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { } ) - plan.run_sh( - run="echo $(cat /root/bye.txt) > hi.txt", - env_vars = { - "HELLO": "Hello!" - }, + plan.run_python( + run = """ +import requests +response = requests.get("https://docs.kurtosis.com") +print(response.status_code) + """, + image = "python:3.11-alpine", + args = [ + "something", + ], + packages = [ + "selenium", + "requests", + ], files = { "/root": bye_files_artifact, }, From ee35ddaa15a85062c1e4cce4216521fbe1b5abb6 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 20 Feb 2024 21:17:10 -0500 Subject: [PATCH 16/75] commento out tests for now --- .../server/startosis_engine/plan_yaml_generator_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index f08e81d535..b678cc01a6 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -60,9 +60,9 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.serviceNetwork.EXPECT().GetApiContainerInfo().Return(apiContainerInfo) } -func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { - suite.Run(t, new(PlanYamlGeneratorTestSuite)) -} +//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { +// suite.Run(t, new(PlanYamlGeneratorTestSuite)) +//} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() From f8c6939be4567f26d12ace6a367a50f84a19d2cf Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Wed, 21 Feb 2024 11:03:39 -0500 Subject: [PATCH 17/75] impl store service --- .../server/startosis_engine/plan.yml | 35 +++------ .../startosis_engine/plan_yaml_generator.go | 77 ++++++++++++++----- .../plan_yaml_generator_test.go | 38 +++------ 3 files changed, 78 insertions(+), 72 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index fdc0b24f4d..0edc3f193d 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,30 +1,13 @@ packageId: github.com/kurtosis-tech/plan-yaml-prac +services: +- uuid: 2418173d9f184bd5a850b4ae8a1d0e06 + name: tedi + image: postgres:alpine + command: + - touch + - hi.txt filesArtifacts: -- uuid: e620890750a54f1ca98ac962c7bd3b06 - name: bye-file - files: - - bye.txt -- uuid: b09ae123685241fdae0c59b8b2ba0171 +- uuid: 2418173d9f184bd5a850b4ae8a1d0e06 name: hi-file files: - - /hi.txt -tasks: -- taskType: python - uuid: b09ae123685241fdae0c59b8b2ba0171 - command: "\nimport requests\nresponse = requests.get(\"https://docs.kurtosis.com\")\nprint(response.status_code) - \ \n " - image: python:3.11-alpine - files: - - mountPath: /root - filesArtifacts: - - uuid: e620890750a54f1ca98ac962c7bd3b06 - name: bye-file - store: - - name: hi-file - files: - - /hi.txt - pythonPackages: - - selenium - - requests - pythonArgs: - - something + - hi.txt diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index b1344446b7..09dae3b3ff 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -7,6 +7,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" @@ -42,25 +43,25 @@ type PlanYamlGenerator interface { // // // - // packageId: github.com/kurtosis-tech/postgres-package + //packageId: github.com/kurtosis-tech/postgres-package // - // services: - // - uuid: + //services: + // - uuid: // - name: - // service_config: + // service_config: // image: // env_var: // ... // // - // files_artifacts: + //files_artifacts: // // // // // // - // tasks: + //tasks: // // @@ -141,8 +142,11 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { err = pyg.updatePlanYamlFromRenderTemplates(scheduledInstruction) case upload_files.UploadFilesBuiltinName: err = pyg.updatePlanYamlFromUploadFiles(scheduledInstruction) + case store_service_files.StoreServiceFilesBuiltinName: + err = pyg.updatePlanYamlFromStoreServiceFiles(scheduledInstruction) default: - return nil, nil + // skip if this instruction is not one that will update the plan yaml + continue } if err != nil { return nil, err @@ -185,12 +189,16 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // ports service.Ports = []*Port{} for portName, configPort := range serviceConfig.GetPrivatePorts() { // TODO: support public ports + port := &Port{ - TransportProtocol: TransportProtocol(configPort.GetTransportProtocol().String()), - ApplicationProtocol: ApplicationProtocol(*configPort.GetMaybeApplicationProtocol()), - Name: portName, - Number: configPort.GetNumber(), + TransportProtocol: TransportProtocol(configPort.GetTransportProtocol().String()), + Name: portName, + Number: configPort.GetNumber(), + } + if configPort.GetMaybeApplicationProtocol() != nil { + port.ApplicationProtocol = ApplicationProtocol(*configPort.GetMaybeApplicationProtocol()) } + service.Ports = append(service.Ports, port) } @@ -435,8 +443,8 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst pyg.filesArtifactIndex[storeSpec.GetName()] = newFilesArtifactFromStoreSpec pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, newFilesArtifactFromStoreSpec) store = append(store, &FilesArtifact{ - Name: storeSpec.GetName(), - Files: []string{storeSpec.GetSrc()}, + Uuid: instructionUuid, + Name: storeSpec.GetName(), }) } task.Store = store // TODO: be consistent about how I'm setting lists in the plan yamls, probably should add wrappers to the plan yaml @@ -594,8 +602,8 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi pyg.filesArtifactIndex[storeSpec.GetName()] = newFilesArtifactFromStoreSpec pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, newFilesArtifactFromStoreSpec) store = append(store, &FilesArtifact{ - Name: storeSpec.GetName(), - Files: []string{storeSpec.GetSrc()}, + Uuid: instructionUuid, + Name: storeSpec.GetName(), }) } task.Store = store // TODO: be consistent about how I'm setting lists in the plan yamls, probably should add wrappers to the plan yaml @@ -605,15 +613,48 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi return nil } -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreService(storeServiceInstruction *instructions_plan.ScheduledInstruction) error { - panic("store service not implemented yet") +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreServiceFiles(storeServiceFilesInstruction *instructions_plan.ScheduledInstruction) error { + var filesArtifact *FilesArtifact + + // get the name of returned files artifact + filesArtifactName, castErr := kurtosis_types.SafeCastToString(storeServiceFilesInstruction.GetReturnedValue(), "files artifact name") + if castErr != nil { + return castErr + } + filesArtifact = &FilesArtifact{ + Uuid: string(storeServiceFilesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction + Name: filesArtifactName, + } + + arguments := storeServiceFilesInstruction.GetInstruction().GetArguments() + // set the uuid to be the uuid of the service that this files artifact comes from + serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, store_service_files.ServiceNameArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", store_service_files.ServiceNameArgName) + } + if service, ok := pyg.serviceIndex[serviceName.GoString()]; !ok { + return startosis_errors.NewInterpretationError("A service that hasn't been tracked was found on a store service instruction.") + } else { + filesArtifact.Uuid = service.Uuid + } + + // parse for files + src, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, store_service_files.SrcArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", store_service_files.SrcArgName) + } + filesArtifact.Files = []string{src.GoString()} + + // add it to the index and the plan yaml + pyg.filesArtifactIndex[filesArtifactName] = filesArtifact + pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) return nil } func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(RemoveServiceInstruction *instructions_plan.ScheduledInstruction) error { + // TODO: update the plan yaml based on an add_service panic("remove service not implemented yet") return nil - // TODO: update the plan yaml based on an add_service } func convertPlanYamlToYaml(planYaml *PlanYaml) ([]byte, error) { diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index b678cc01a6..226e4d8f91 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -80,36 +80,18 @@ func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - bye_files_artifact = plan.render_templates( - name="bye-file", - config={ - "bye.txt": struct( - template="Bye bye!", - data={} - ) - } + plan.add_service( + name="tedi", + config=ServiceConfig( + image="postgres:alpine", + cmd=["touch", "hi.txt"], + ) ) - plan.run_python( - run = """ -import requests -response = requests.get("https://docs.kurtosis.com") -print(response.status_code) - """, - image = "python:3.11-alpine", - args = [ - "something", - ], - packages = [ - "selenium", - "requests", - ], - files = { - "/root": bye_files_artifact, - }, - store=[ - StoreSpec(src="/hi.txt", name="hi-file") - ] + hi_files_artifact = plan.store_service_files( + name="hi-file", + src="hi.txt", + service_name="tedi", ) ` serializedJsonParams := "{}" From 5ecf11a96a5e49b818c7ce075643376029ba0b43 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Wed, 21 Feb 2024 11:26:21 -0500 Subject: [PATCH 18/75] change order of name and uuid --- .../api_container/server/startosis_engine/plan_yaml.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 4a9ad87f3a..44d2cfefa7 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -19,8 +19,8 @@ type PlanYaml struct { // Service represents a service in the system. type Service struct { - Uuid string `yaml:"uuid,omitempty"` // done Name string `yaml:"name,omitempty"` // done + Uuid string `yaml:"uuid,omitempty"` // done Image string `yaml:"image,omitempty"` // done Cmd []string `yaml:"command,omitempty"` // done Entrypoint []string `yaml:"entrypoint,omitempty"` // done @@ -33,8 +33,8 @@ type Service struct { // FilesArtifact represents a collection of files. type FilesArtifact struct { - Uuid string `yaml:"uuid,omitempty"` Name string `yaml:"name,omitempty"` + Uuid string `yaml:"uuid,omitempty"` Files []string `yaml:"files,omitempty"` } @@ -67,9 +67,9 @@ type FileMount struct { // Task represents a task to be executed. type Task struct { - TaskType TaskType `yaml:"taskType,omitempty"` // done - Uuid string `yaml:"uuid"` // done Name string `yaml:"name,omitempty"` // done + Uuid string `yaml:"uuid"` // done + TaskType TaskType `yaml:"taskType,omitempty"` // done RunCmd string `yaml:"command,omitempty"` // done Image string `yaml:"image,omitempty"` // done Files []*FileMount `yaml:"files,omitempty"` // done From 6146fc14971f19f5aa592b4ccd8d5f3519301190 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Wed, 21 Feb 2024 13:48:28 -0500 Subject: [PATCH 19/75] catch service config err --- .../server/startosis_engine/plan_yaml_generator.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 09dae3b3ff..bc81e45cd4 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -181,6 +181,9 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc pyg.planYaml.PackageId, pyg.packageContentProvider, pyg.packageReplaceOptions) + if err != nil { + return err + } service.Image = serviceConfig.GetContainerImageName() // TODO: support image build specs, image registry specs, nix build specs service.Cmd = serviceConfig.GetCmdArgs() From 9daaabcafc59299e65bf96ce41428a63215198ed Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 22 Feb 2024 09:51:58 -0500 Subject: [PATCH 20/75] add plan yaml endpoint to protobuf --- api/protobuf/core/api_container_service.proto | 38 +++++++++++++++++++ .../server/startosis_engine/plan_yaml.go | 2 +- .../kurtosis_enclave_manager_api.proto | 24 ++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/api/protobuf/core/api_container_service.proto b/api/protobuf/core/api_container_service.proto index 01049313e3..fde18b1af4 100644 --- a/api/protobuf/core/api_container_service.proto +++ b/api/protobuf/core/api_container_service.proto @@ -53,6 +53,13 @@ service ApiContainerService { // Get last Starlark run rpc GetStarlarkRun(google.protobuf.Empty) returns (GetStarlarkRunResponse) {}; + + // Gets yaml representing the plan the script will execute in an enclave + rpc GetStarlarkScriptPlanYaml(StarlarkScriptPlanYamlArgs) returns (PlanYaml) {}; + + + // Gets yaml representing the plan the package will execute in an enclave + rpc GetStarlarkPackaePlanYaml(StarlarkPackagePlanYamlArgs) returns (PlanYaml) {}; } // ============================================================================================== @@ -564,3 +571,34 @@ message GetStarlarkRunResponse { RestartPolicy restart_policy = 8; } + +// ============================================================================================== +// Get Starlark Plan Yaml +// ============================================================================================== + +message PlanYaml { + string plan_yaml = 1; +} + +message StarlarkScriptPlanYamlArgs { + string serialized_script = 1; + + optional string serialized_params = 2; + + // The name of the main function, the default value is "run" + optional string main_function_name = 5; +} + +message StarlarkPackagePlanYamlArgs { + string package_id = 1; + + // Serialized parameters data for the Starlark package main function + // This should be a valid JSON string + optional string serialized_params = 2; + + // The relative main file filepath, the default value is the "main.star" file in the root of a package + optional string relative_path_to_main_file = 3; + + // The name of the main function, the default value is "run" + optional string main_function_name = 4; +} \ No newline at end of file diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 44d2cfefa7..a5f6091e2e 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -68,7 +68,7 @@ type FileMount struct { // Task represents a task to be executed. type Task struct { Name string `yaml:"name,omitempty"` // done - Uuid string `yaml:"uuid"` // done + Uuid string `yaml:"uuid,omitempty"` // done TaskType TaskType `yaml:"taskType,omitempty"` // done RunCmd string `yaml:"command,omitempty"` // done Image string `yaml:"image,omitempty"` // done diff --git a/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto b/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto index 76a9512bf4..b7fe22a5da 100644 --- a/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto +++ b/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto @@ -21,6 +21,8 @@ service KurtosisEnclaveManagerServer { rpc DownloadFilesArtifact(DownloadFilesArtifactRequest) returns (stream api_container_api.StreamedDataChunk) {}; rpc DestroyEnclave(engine_api.DestroyEnclaveArgs) returns (google.protobuf.Empty) {}; rpc GetStarlarkRun(GetStarlarkRunRequest) returns (api_container_api.GetStarlarkRunResponse) {}; + rpc GetStarlarkScriptPlanYaml(StarlarkScriptPlanYamlArgs) returns (PlanYaml) {}; + rpc GetStarlarkPackaePlanYaml(StarlarkPackagePlanYamlArgs) returns (PlanYaml) {}; } message HealthCheckRequest { @@ -75,3 +77,25 @@ message GetStarlarkRunRequest{ string apic_ip_address = 1; int32 apic_port = 2; } + + +// ============================================================================================== +// Get Starlark Plan Yaml +// ============================================================================================== + +message PlanYaml { + string plan_yaml = 1; +} + +message StarlarkScriptPlanYamlArgs { + string apic_ip_address = 1; + int32 apic_port = 2; + + api_container_api.GetStarlarkPackagePlanYamlRequest starlark_package_plan_yaml_args = 3; +} + +message StarlarkPackagePlanYamlArgs { + string apic_ip_address = 1; + int32 apic_port = 2; + api_container_api.GetStarlarkScriptPlanYamlRequest starlark_script_plan_yaml_args = 3; +} \ No newline at end of file From 29b3f2cb7133b28ceb61a4531f054386b3a04249 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 22 Feb 2024 10:35:30 -0500 Subject: [PATCH 21/75] regenerate proto bindings --- .../api_container_service.pb.go | 596 +++++++++++---- .../api_container_service_grpc.pb.go | 78 ++ .../api_container_service.connect.go | 59 ++ api/protobuf/core/api_container_service.proto | 3 +- api/rust/src/api_container_api.rs | 197 +++++ .../api_container_service_grpc_pb.d.ts | 10 + .../api_container_service_grpc_pb.js | 57 ++ .../api_container_service_grpc_web_pb.d.ts | 24 + .../api_container_service_grpc_web_pb.js | 122 +++ .../api_container_service_pb.d.ts | 109 +++ .../api_container_service_pb.js | 696 ++++++++++++++++++ .../api_container_service_connect.d.ts | 24 +- .../connect/api_container_service_connect.js | 24 +- .../connect/api_container_service_pb.d.ts | 106 +++ .../connect/api_container_service_pb.js | 35 + .../server/api_container_service.go | 4 + .../kurtosis_enclave_manager_api.pb.go | 553 ++++++++++---- .../kurtosis_enclave_manager_api.connect.go | 56 ++ .../kurtosis_enclave_manager_api_grpc.pb.go | 76 +- .../kurtosis_enclave_manager_api.proto | 6 +- .../kurtosis_enclave_manager_api_connect.ts | 22 +- .../src/kurtosis_enclave_manager_api_pb.ts | 139 +++- 22 files changed, 2682 insertions(+), 314 deletions(-) diff --git a/api/golang/core/kurtosis_core_rpc_api_bindings/api_container_service.pb.go b/api/golang/core/kurtosis_core_rpc_api_bindings/api_container_service.pb.go index 6407ae89b5..d5d6ddb5e7 100644 --- a/api/golang/core/kurtosis_core_rpc_api_bindings/api_container_service.pb.go +++ b/api/golang/core/kurtosis_core_rpc_api_bindings/api_container_service.pb.go @@ -3289,6 +3289,192 @@ func (x *GetStarlarkRunResponse) GetRestartPolicy() RestartPolicy { return RestartPolicy_NEVER } +type PlanYaml struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PlanYaml string `protobuf:"bytes,1,opt,name=plan_yaml,json=planYaml,proto3" json:"plan_yaml,omitempty"` +} + +func (x *PlanYaml) Reset() { + *x = PlanYaml{} + if protoimpl.UnsafeEnabled { + mi := &file_api_container_service_proto_msgTypes[42] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PlanYaml) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PlanYaml) ProtoMessage() {} + +func (x *PlanYaml) ProtoReflect() protoreflect.Message { + mi := &file_api_container_service_proto_msgTypes[42] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PlanYaml.ProtoReflect.Descriptor instead. +func (*PlanYaml) Descriptor() ([]byte, []int) { + return file_api_container_service_proto_rawDescGZIP(), []int{42} +} + +func (x *PlanYaml) GetPlanYaml() string { + if x != nil { + return x.PlanYaml + } + return "" +} + +type StarlarkScriptPlanYamlArgs struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SerializedScript string `protobuf:"bytes,1,opt,name=serialized_script,json=serializedScript,proto3" json:"serialized_script,omitempty"` + SerializedParams *string `protobuf:"bytes,2,opt,name=serialized_params,json=serializedParams,proto3,oneof" json:"serialized_params,omitempty"` + // The name of the main function, the default value is "run" + MainFunctionName *string `protobuf:"bytes,5,opt,name=main_function_name,json=mainFunctionName,proto3,oneof" json:"main_function_name,omitempty"` +} + +func (x *StarlarkScriptPlanYamlArgs) Reset() { + *x = StarlarkScriptPlanYamlArgs{} + if protoimpl.UnsafeEnabled { + mi := &file_api_container_service_proto_msgTypes[43] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StarlarkScriptPlanYamlArgs) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StarlarkScriptPlanYamlArgs) ProtoMessage() {} + +func (x *StarlarkScriptPlanYamlArgs) ProtoReflect() protoreflect.Message { + mi := &file_api_container_service_proto_msgTypes[43] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StarlarkScriptPlanYamlArgs.ProtoReflect.Descriptor instead. +func (*StarlarkScriptPlanYamlArgs) Descriptor() ([]byte, []int) { + return file_api_container_service_proto_rawDescGZIP(), []int{43} +} + +func (x *StarlarkScriptPlanYamlArgs) GetSerializedScript() string { + if x != nil { + return x.SerializedScript + } + return "" +} + +func (x *StarlarkScriptPlanYamlArgs) GetSerializedParams() string { + if x != nil && x.SerializedParams != nil { + return *x.SerializedParams + } + return "" +} + +func (x *StarlarkScriptPlanYamlArgs) GetMainFunctionName() string { + if x != nil && x.MainFunctionName != nil { + return *x.MainFunctionName + } + return "" +} + +type StarlarkPackagePlanYamlArgs struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PackageId string `protobuf:"bytes,1,opt,name=package_id,json=packageId,proto3" json:"package_id,omitempty"` + // Serialized parameters data for the Starlark package main function + // This should be a valid JSON string + SerializedParams *string `protobuf:"bytes,2,opt,name=serialized_params,json=serializedParams,proto3,oneof" json:"serialized_params,omitempty"` + // The relative main file filepath, the default value is the "main.star" file in the root of a package + RelativePathToMainFile *string `protobuf:"bytes,3,opt,name=relative_path_to_main_file,json=relativePathToMainFile,proto3,oneof" json:"relative_path_to_main_file,omitempty"` + // The name of the main function, the default value is "run" + MainFunctionName *string `protobuf:"bytes,4,opt,name=main_function_name,json=mainFunctionName,proto3,oneof" json:"main_function_name,omitempty"` +} + +func (x *StarlarkPackagePlanYamlArgs) Reset() { + *x = StarlarkPackagePlanYamlArgs{} + if protoimpl.UnsafeEnabled { + mi := &file_api_container_service_proto_msgTypes[44] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StarlarkPackagePlanYamlArgs) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StarlarkPackagePlanYamlArgs) ProtoMessage() {} + +func (x *StarlarkPackagePlanYamlArgs) ProtoReflect() protoreflect.Message { + mi := &file_api_container_service_proto_msgTypes[44] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StarlarkPackagePlanYamlArgs.ProtoReflect.Descriptor instead. +func (*StarlarkPackagePlanYamlArgs) Descriptor() ([]byte, []int) { + return file_api_container_service_proto_rawDescGZIP(), []int{44} +} + +func (x *StarlarkPackagePlanYamlArgs) GetPackageId() string { + if x != nil { + return x.PackageId + } + return "" +} + +func (x *StarlarkPackagePlanYamlArgs) GetSerializedParams() string { + if x != nil && x.SerializedParams != nil { + return *x.SerializedParams + } + return "" +} + +func (x *StarlarkPackagePlanYamlArgs) GetRelativePathToMainFile() string { + if x != nil && x.RelativePathToMainFile != nil { + return *x.RelativePathToMainFile + } + return "" +} + +func (x *StarlarkPackagePlanYamlArgs) GetMainFunctionName() string { + if x != nil && x.MainFunctionName != nil { + return *x.MainFunctionName + } + return "" +} + var File_api_container_service_proto protoreflect.FileDescriptor var file_api_container_service_proto_rawDesc = []byte{ @@ -3845,139 +4031,188 @@ var file_api_container_service_proto_rawDesc = []byte{ 0x6c, 0x69, 0x63, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0d, 0x72, 0x65, - 0x73, 0x74, 0x61, 0x72, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2a, 0x36, 0x0a, 0x0d, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, - 0x53, 0x54, 0x4f, 0x50, 0x50, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x55, 0x4e, - 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, - 0x4e, 0x10, 0x02, 0x2a, 0x2c, 0x0a, 0x11, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x44, 0x6f, 0x77, 0x6e, - 0x6c, 0x6f, 0x61, 0x64, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x61, 0x6c, 0x77, 0x61, - 0x79, 0x73, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x10, - 0x01, 0x2a, 0x26, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x0b, 0x0a, 0x07, - 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x4f, 0x5f, - 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x10, 0x01, 0x2a, 0x32, 0x0a, 0x13, 0x4b, 0x75, 0x72, - 0x74, 0x6f, 0x73, 0x69, 0x73, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x46, 0x6c, 0x61, 0x67, - 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x4f, 0x5f, 0x49, 0x4e, 0x53, 0x54, 0x52, 0x55, 0x43, 0x54, 0x49, - 0x4f, 0x4e, 0x53, 0x5f, 0x43, 0x41, 0x43, 0x48, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x2a, 0x26, 0x0a, - 0x0d, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x09, - 0x0a, 0x05, 0x4e, 0x45, 0x56, 0x45, 0x52, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x4c, 0x57, - 0x41, 0x59, 0x53, 0x10, 0x01, 0x32, 0xce, 0x0e, 0x0a, 0x13, 0x41, 0x70, 0x69, 0x43, 0x6f, 0x6e, - 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6d, 0x0a, - 0x11, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x12, 0x28, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, - 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, - 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x2a, 0x2e, 0x61, + 0x73, 0x74, 0x61, 0x72, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0x27, 0x0a, 0x08, 0x50, + 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x6c, 0x61, 0x6e, 0x5f, + 0x79, 0x61, 0x6d, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x6e, + 0x59, 0x61, 0x6d, 0x6c, 0x22, 0xdb, 0x01, 0x0a, 0x1a, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, + 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, + 0x72, 0x67, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, + 0x64, 0x5f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, + 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x12, 0x30, 0x0a, 0x11, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x70, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x10, 0x73, + 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x88, + 0x01, 0x01, 0x12, 0x31, 0x0a, 0x12, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x66, 0x75, 0x6e, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, + 0x52, 0x10, 0x6d, 0x61, 0x69, 0x6e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, + 0x6d, 0x65, 0x88, 0x01, 0x01, 0x42, 0x14, 0x0a, 0x12, 0x5f, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, + 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x15, 0x0a, 0x13, 0x5f, + 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x22, 0xae, 0x02, 0x0a, 0x1b, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, + 0x67, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x49, + 0x64, 0x12, 0x30, 0x0a, 0x11, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x10, + 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x88, 0x01, 0x01, 0x12, 0x3f, 0x0a, 0x1a, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, + 0x70, 0x61, 0x74, 0x68, 0x5f, 0x74, 0x6f, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x66, 0x69, 0x6c, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x16, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x54, 0x6f, 0x4d, 0x61, 0x69, 0x6e, 0x46, 0x69, 0x6c, + 0x65, 0x88, 0x01, 0x01, 0x12, 0x31, 0x0a, 0x12, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x66, 0x75, 0x6e, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x48, 0x02, 0x52, 0x10, 0x6d, 0x61, 0x69, 0x6e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x4e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x42, 0x14, 0x0a, 0x12, 0x5f, 0x73, 0x65, 0x72, 0x69, + 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x1d, 0x0a, + 0x1b, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x5f, + 0x74, 0x6f, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x42, 0x15, 0x0a, 0x13, + 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x2a, 0x36, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x54, 0x4f, 0x50, 0x50, 0x45, 0x44, 0x10, + 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x55, 0x4e, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0b, + 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x02, 0x2a, 0x2c, 0x0a, 0x11, 0x49, + 0x6d, 0x61, 0x67, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x4d, 0x6f, 0x64, 0x65, + 0x12, 0x0a, 0x0a, 0x06, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, + 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x10, 0x01, 0x2a, 0x26, 0x0a, 0x07, 0x43, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x10, + 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x4f, 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x10, + 0x01, 0x2a, 0x32, 0x0a, 0x13, 0x4b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x46, 0x65, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x4f, 0x5f, 0x49, + 0x4e, 0x53, 0x54, 0x52, 0x55, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x5f, 0x43, 0x41, 0x43, 0x48, + 0x49, 0x4e, 0x47, 0x10, 0x00, 0x2a, 0x26, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x45, 0x56, 0x45, 0x52, 0x10, + 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x4c, 0x57, 0x41, 0x59, 0x53, 0x10, 0x01, 0x32, 0xa6, 0x10, + 0x0a, 0x13, 0x41, 0x70, 0x69, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6d, 0x0a, 0x11, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, + 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x28, 0x2e, 0x61, 0x70, 0x69, + 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x52, + 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x41, 0x72, 0x67, 0x73, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, + 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4c, 0x69, 0x6e, 0x65, + 0x22, 0x00, 0x30, 0x01, 0x12, 0x59, 0x0a, 0x15, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x74, + 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x24, 0x2e, + 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, + 0x69, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x43, 0x68, + 0x75, 0x6e, 0x6b, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x28, 0x01, 0x12, + 0x6f, 0x0a, 0x12, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, + 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, + 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x41, 0x72, 0x67, 0x73, + 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, + 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x22, 0x00, 0x30, 0x01, + 0x12, 0x5b, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, + 0x22, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, + 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x41, + 0x72, 0x67, 0x73, 0x1a, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, + 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x8d, 0x01, + 0x0a, 0x2a, 0x47, 0x65, 0x74, 0x45, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x41, 0x6e, 0x64, + 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x73, 0x12, 0x16, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x45, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x78, 0x69, 0x73, + 0x74, 0x69, 0x6e, 0x67, 0x41, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, + 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, + 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5b, 0x0a, + 0x0b, 0x45, 0x78, 0x65, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, - 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x59, 0x0a, 0x15, - 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, - 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, - 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, - 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x1a, 0x16, 0x2e, 0x67, 0x6f, + 0x2e, 0x45, 0x78, 0x65, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x41, 0x72, 0x67, 0x73, + 0x1a, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, + 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x79, 0x0a, 0x22, 0x57, 0x61, + 0x69, 0x74, 0x46, 0x6f, 0x72, 0x48, 0x74, 0x74, 0x70, 0x47, 0x65, 0x74, 0x45, 0x6e, 0x64, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, + 0x12, 0x39, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, + 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x57, 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, 0x48, 0x74, 0x74, 0x70, + 0x47, 0x65, 0x74, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, + 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x22, 0x00, 0x28, 0x01, 0x12, 0x6f, 0x0a, 0x12, 0x52, 0x75, 0x6e, 0x53, 0x74, - 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x29, 0x2e, - 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, - 0x69, 0x2e, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, - 0x6b, 0x61, 0x67, 0x65, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, - 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, - 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x4c, 0x69, 0x6e, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x5b, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, - 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x26, 0x2e, 0x61, 0x70, - 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, - 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x8d, 0x01, 0x0a, 0x2a, 0x47, 0x65, 0x74, 0x45, 0x78, 0x69, - 0x73, 0x74, 0x69, 0x6e, 0x67, 0x41, 0x6e, 0x64, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, - 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, - 0x69, 0x65, 0x72, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x45, 0x2e, 0x61, + 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x7b, 0x0a, 0x23, 0x57, 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, + 0x48, 0x74, 0x74, 0x70, 0x50, 0x6f, 0x73, 0x74, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x3a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, - 0x2e, 0x47, 0x65, 0x74, 0x45, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x41, 0x6e, 0x64, 0x48, - 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5b, 0x0a, 0x0b, 0x45, 0x78, 0x65, 0x63, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, - 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x78, 0x65, - 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x79, 0x0a, 0x22, 0x57, 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, 0x48, 0x74, 0x74, - 0x70, 0x47, 0x65, 0x74, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x41, 0x76, 0x61, 0x69, - 0x6c, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x39, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, - 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x57, 0x61, 0x69, - 0x74, 0x46, 0x6f, 0x72, 0x48, 0x74, 0x74, 0x70, 0x47, 0x65, 0x74, 0x45, 0x6e, 0x64, 0x70, 0x6f, - 0x69, 0x6e, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x41, - 0x72, 0x67, 0x73, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x7b, 0x0a, - 0x23, 0x57, 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, 0x48, 0x74, 0x74, 0x70, 0x50, 0x6f, 0x73, 0x74, + 0x2e, 0x57, 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, 0x48, 0x74, 0x74, 0x70, 0x50, 0x6f, 0x73, 0x74, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x69, - 0x6c, 0x69, 0x74, 0x79, 0x12, 0x3a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x57, 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, - 0x48, 0x74, 0x74, 0x70, 0x50, 0x6f, 0x73, 0x74, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, - 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x41, 0x72, 0x67, 0x73, - 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x6f, 0x0a, 0x13, 0x55, 0x70, - 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, - 0x74, 0x12, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, - 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x64, 0x44, 0x61, - 0x74, 0x61, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x1a, 0x2e, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, - 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x55, 0x70, 0x6c, 0x6f, - 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x6f, 0x0a, 0x15, 0x44, - 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, - 0x66, 0x61, 0x63, 0x74, 0x12, 0x2c, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, - 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x41, 0x72, - 0x67, 0x73, 0x1a, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, - 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x64, 0x44, - 0x61, 0x74, 0x61, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x22, 0x00, 0x30, 0x01, 0x12, 0x79, 0x0a, 0x15, - 0x53, 0x74, 0x6f, 0x72, 0x65, 0x57, 0x65, 0x62, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, - 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x2c, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, - 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x57, - 0x65, 0x62, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x41, - 0x72, 0x67, 0x73, 0x1a, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, - 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x57, 0x65, 0x62, - 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x91, 0x01, 0x0a, 0x1d, 0x53, 0x74, 0x6f, 0x72, - 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x46, 0x72, - 0x6f, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x34, 0x2e, 0x61, 0x70, 0x69, 0x5f, + 0x6c, 0x69, 0x74, 0x79, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x22, 0x00, 0x12, 0x6f, 0x0a, 0x13, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, + 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, - 0x6f, 0x72, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, - 0x46, 0x72, 0x6f, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x41, 0x72, 0x67, 0x73, 0x1a, - 0x38, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, - 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, + 0x72, 0x65, 0x61, 0x6d, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x1a, + 0x2e, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, + 0x61, 0x70, 0x69, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, + 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x28, 0x01, 0x12, 0x6f, 0x0a, 0x15, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, + 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x2c, 0x2e, 0x61, + 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, + 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, + 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x24, 0x2e, 0x61, 0x70, 0x69, + 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x43, 0x68, 0x75, 0x6e, 0x6b, + 0x22, 0x00, 0x30, 0x01, 0x12, 0x79, 0x0a, 0x15, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x57, 0x65, 0x62, + 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x2c, 0x2e, + 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, + 0x69, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x57, 0x65, 0x62, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, + 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x30, 0x2e, 0x61, 0x70, + 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, + 0x53, 0x74, 0x6f, 0x72, 0x65, 0x57, 0x65, 0x62, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, + 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x91, 0x01, 0x0a, 0x1d, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x46, 0x72, 0x6f, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x75, 0x0a, 0x1e, 0x4c, - 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, - 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x55, 0x75, 0x69, 0x64, 0x73, 0x12, 0x16, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x39, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, - 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, - 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, - 0x41, 0x6e, 0x64, 0x55, 0x75, 0x69, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x91, 0x01, 0x0a, 0x1c, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, - 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x73, 0x12, 0x36, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, - 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, - 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x61, 0x70, + 0x65, 0x12, 0x34, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, + 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x46, 0x72, 0x6f, 0x6d, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x38, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x6f, 0x72, + 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x46, 0x72, + 0x6f, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x75, 0x0a, 0x1e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, + 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, + 0x55, 0x75, 0x69, 0x64, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x39, 0x2e, + 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, + 0x69, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, + 0x61, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x55, 0x75, 0x69, 0x64, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x91, 0x01, 0x0a, 0x1c, 0x49, + 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, + 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x36, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, - 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x67, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, - 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x5f, - 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, - 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x41, 0x72, 0x67, - 0x73, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, + 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, + 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x67, + 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x73, 0x12, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x55, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, - 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x5f, - 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, - 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x52, 0x5a, 0x50, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x76, 0x69, 0x63, 0x65, 0x73, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, + 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x55, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x74, + 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x1a, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, + 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x69, + 0x0a, 0x19, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x2d, 0x2e, 0x61, 0x70, + 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, + 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, + 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x1b, 0x2e, 0x61, 0x70, 0x69, + 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x50, + 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x22, 0x00, 0x12, 0x6b, 0x0a, 0x1a, 0x47, 0x65, 0x74, + 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x50, + 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x2e, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, + 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, + 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x6c, 0x61, 0x6e, + 0x59, 0x61, 0x6d, 0x6c, 0x22, 0x00, 0x42, 0x52, 0x5a, 0x50, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x2d, 0x74, 0x65, 0x63, 0x68, 0x2f, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x6b, 0x75, 0x72, 0x74, @@ -3999,7 +4234,7 @@ func file_api_container_service_proto_rawDescGZIP() []byte { } var file_api_container_service_proto_enumTypes = make([]protoimpl.EnumInfo, 7) -var file_api_container_service_proto_msgTypes = make([]protoimpl.MessageInfo, 47) +var file_api_container_service_proto_msgTypes = make([]protoimpl.MessageInfo, 50) var file_api_container_service_proto_goTypes = []interface{}{ (ServiceStatus)(0), // 0: api_container_api.ServiceStatus (ImageDownloadMode)(0), // 1: api_container_api.ImageDownloadMode @@ -4050,19 +4285,22 @@ var file_api_container_service_proto_goTypes = []interface{}{ (*ConnectServicesArgs)(nil), // 46: api_container_api.ConnectServicesArgs (*ConnectServicesResponse)(nil), // 47: api_container_api.ConnectServicesResponse (*GetStarlarkRunResponse)(nil), // 48: api_container_api.GetStarlarkRunResponse - nil, // 49: api_container_api.Container.EnvVarsEntry - nil, // 50: api_container_api.ServiceInfo.PrivatePortsEntry - nil, // 51: api_container_api.ServiceInfo.MaybePublicPortsEntry - nil, // 52: api_container_api.GetServicesArgs.ServiceIdentifiersEntry - nil, // 53: api_container_api.GetServicesResponse.ServiceInfoEntry - (*emptypb.Empty)(nil), // 54: google.protobuf.Empty + (*PlanYaml)(nil), // 49: api_container_api.PlanYaml + (*StarlarkScriptPlanYamlArgs)(nil), // 50: api_container_api.StarlarkScriptPlanYamlArgs + (*StarlarkPackagePlanYamlArgs)(nil), // 51: api_container_api.StarlarkPackagePlanYamlArgs + nil, // 52: api_container_api.Container.EnvVarsEntry + nil, // 53: api_container_api.ServiceInfo.PrivatePortsEntry + nil, // 54: api_container_api.ServiceInfo.MaybePublicPortsEntry + nil, // 55: api_container_api.GetServicesArgs.ServiceIdentifiersEntry + nil, // 56: api_container_api.GetServicesResponse.ServiceInfoEntry + (*emptypb.Empty)(nil), // 57: google.protobuf.Empty } var file_api_container_service_proto_depIdxs = []int32{ 5, // 0: api_container_api.Port.transport_protocol:type_name -> api_container_api.Port.TransportProtocol 6, // 1: api_container_api.Container.status:type_name -> api_container_api.Container.Status - 49, // 2: api_container_api.Container.env_vars:type_name -> api_container_api.Container.EnvVarsEntry - 50, // 3: api_container_api.ServiceInfo.private_ports:type_name -> api_container_api.ServiceInfo.PrivatePortsEntry - 51, // 4: api_container_api.ServiceInfo.maybe_public_ports:type_name -> api_container_api.ServiceInfo.MaybePublicPortsEntry + 52, // 2: api_container_api.Container.env_vars:type_name -> api_container_api.Container.EnvVarsEntry + 53, // 3: api_container_api.ServiceInfo.private_ports:type_name -> api_container_api.ServiceInfo.PrivatePortsEntry + 54, // 4: api_container_api.ServiceInfo.maybe_public_ports:type_name -> api_container_api.ServiceInfo.MaybePublicPortsEntry 0, // 5: api_container_api.ServiceInfo.service_status:type_name -> api_container_api.ServiceStatus 8, // 6: api_container_api.ServiceInfo.container:type_name -> api_container_api.Container 3, // 7: api_container_api.RunStarlarkScriptArgs.experimental_features:type_name -> api_container_api.KurtosisFeatureFlag @@ -4081,8 +4319,8 @@ var file_api_container_service_proto_depIdxs = []int32{ 20, // 20: api_container_api.StarlarkError.interpretation_error:type_name -> api_container_api.StarlarkInterpretationError 21, // 21: api_container_api.StarlarkError.validation_error:type_name -> api_container_api.StarlarkValidationError 22, // 22: api_container_api.StarlarkError.execution_error:type_name -> api_container_api.StarlarkExecutionError - 52, // 23: api_container_api.GetServicesArgs.service_identifiers:type_name -> api_container_api.GetServicesArgs.ServiceIdentifiersEntry - 53, // 24: api_container_api.GetServicesResponse.service_info:type_name -> api_container_api.GetServicesResponse.ServiceInfoEntry + 55, // 23: api_container_api.GetServicesArgs.service_identifiers:type_name -> api_container_api.GetServicesArgs.ServiceIdentifiersEntry + 56, // 24: api_container_api.GetServicesResponse.service_info:type_name -> api_container_api.GetServicesResponse.ServiceInfoEntry 27, // 25: api_container_api.GetExistingAndHistoricalServiceIdentifiersResponse.allIdentifiers:type_name -> api_container_api.ServiceIdentifiers 34, // 26: api_container_api.StreamedDataChunk.metadata:type_name -> api_container_api.DataChunkMetadata 41, // 27: api_container_api.ListFilesArtifactNamesAndUuidsResponse.file_names_and_uuids:type_name -> api_container_api.FilesArtifactNameAndUuid @@ -4098,7 +4336,7 @@ var file_api_container_service_proto_depIdxs = []int32{ 33, // 37: api_container_api.ApiContainerService.UploadStarlarkPackage:input_type -> api_container_api.StreamedDataChunk 11, // 38: api_container_api.ApiContainerService.RunStarlarkPackage:input_type -> api_container_api.RunStarlarkPackageArgs 25, // 39: api_container_api.ApiContainerService.GetServices:input_type -> api_container_api.GetServicesArgs - 54, // 40: api_container_api.ApiContainerService.GetExistingAndHistoricalServiceIdentifiers:input_type -> google.protobuf.Empty + 57, // 40: api_container_api.ApiContainerService.GetExistingAndHistoricalServiceIdentifiers:input_type -> google.protobuf.Empty 29, // 41: api_container_api.ApiContainerService.ExecCommand:input_type -> api_container_api.ExecCommandArgs 31, // 42: api_container_api.ApiContainerService.WaitForHttpGetEndpointAvailability:input_type -> api_container_api.WaitForHttpGetEndpointAvailabilityArgs 32, // 43: api_container_api.ApiContainerService.WaitForHttpPostEndpointAvailability:input_type -> api_container_api.WaitForHttpPostEndpointAvailabilityArgs @@ -4106,28 +4344,32 @@ var file_api_container_service_proto_depIdxs = []int32{ 36, // 45: api_container_api.ApiContainerService.DownloadFilesArtifact:input_type -> api_container_api.DownloadFilesArtifactArgs 37, // 46: api_container_api.ApiContainerService.StoreWebFilesArtifact:input_type -> api_container_api.StoreWebFilesArtifactArgs 39, // 47: api_container_api.ApiContainerService.StoreFilesArtifactFromService:input_type -> api_container_api.StoreFilesArtifactFromServiceArgs - 54, // 48: api_container_api.ApiContainerService.ListFilesArtifactNamesAndUuids:input_type -> google.protobuf.Empty + 57, // 48: api_container_api.ApiContainerService.ListFilesArtifactNamesAndUuids:input_type -> google.protobuf.Empty 43, // 49: api_container_api.ApiContainerService.InspectFilesArtifactContents:input_type -> api_container_api.InspectFilesArtifactContentsRequest 46, // 50: api_container_api.ApiContainerService.ConnectServices:input_type -> api_container_api.ConnectServicesArgs - 54, // 51: api_container_api.ApiContainerService.GetStarlarkRun:input_type -> google.protobuf.Empty - 12, // 52: api_container_api.ApiContainerService.RunStarlarkScript:output_type -> api_container_api.StarlarkRunResponseLine - 54, // 53: api_container_api.ApiContainerService.UploadStarlarkPackage:output_type -> google.protobuf.Empty - 12, // 54: api_container_api.ApiContainerService.RunStarlarkPackage:output_type -> api_container_api.StarlarkRunResponseLine - 26, // 55: api_container_api.ApiContainerService.GetServices:output_type -> api_container_api.GetServicesResponse - 28, // 56: api_container_api.ApiContainerService.GetExistingAndHistoricalServiceIdentifiers:output_type -> api_container_api.GetExistingAndHistoricalServiceIdentifiersResponse - 30, // 57: api_container_api.ApiContainerService.ExecCommand:output_type -> api_container_api.ExecCommandResponse - 54, // 58: api_container_api.ApiContainerService.WaitForHttpGetEndpointAvailability:output_type -> google.protobuf.Empty - 54, // 59: api_container_api.ApiContainerService.WaitForHttpPostEndpointAvailability:output_type -> google.protobuf.Empty - 35, // 60: api_container_api.ApiContainerService.UploadFilesArtifact:output_type -> api_container_api.UploadFilesArtifactResponse - 33, // 61: api_container_api.ApiContainerService.DownloadFilesArtifact:output_type -> api_container_api.StreamedDataChunk - 38, // 62: api_container_api.ApiContainerService.StoreWebFilesArtifact:output_type -> api_container_api.StoreWebFilesArtifactResponse - 40, // 63: api_container_api.ApiContainerService.StoreFilesArtifactFromService:output_type -> api_container_api.StoreFilesArtifactFromServiceResponse - 42, // 64: api_container_api.ApiContainerService.ListFilesArtifactNamesAndUuids:output_type -> api_container_api.ListFilesArtifactNamesAndUuidsResponse - 44, // 65: api_container_api.ApiContainerService.InspectFilesArtifactContents:output_type -> api_container_api.InspectFilesArtifactContentsResponse - 47, // 66: api_container_api.ApiContainerService.ConnectServices:output_type -> api_container_api.ConnectServicesResponse - 48, // 67: api_container_api.ApiContainerService.GetStarlarkRun:output_type -> api_container_api.GetStarlarkRunResponse - 52, // [52:68] is the sub-list for method output_type - 36, // [36:52] is the sub-list for method input_type + 57, // 51: api_container_api.ApiContainerService.GetStarlarkRun:input_type -> google.protobuf.Empty + 50, // 52: api_container_api.ApiContainerService.GetStarlarkScriptPlanYaml:input_type -> api_container_api.StarlarkScriptPlanYamlArgs + 51, // 53: api_container_api.ApiContainerService.GetStarlarkPackagePlanYaml:input_type -> api_container_api.StarlarkPackagePlanYamlArgs + 12, // 54: api_container_api.ApiContainerService.RunStarlarkScript:output_type -> api_container_api.StarlarkRunResponseLine + 57, // 55: api_container_api.ApiContainerService.UploadStarlarkPackage:output_type -> google.protobuf.Empty + 12, // 56: api_container_api.ApiContainerService.RunStarlarkPackage:output_type -> api_container_api.StarlarkRunResponseLine + 26, // 57: api_container_api.ApiContainerService.GetServices:output_type -> api_container_api.GetServicesResponse + 28, // 58: api_container_api.ApiContainerService.GetExistingAndHistoricalServiceIdentifiers:output_type -> api_container_api.GetExistingAndHistoricalServiceIdentifiersResponse + 30, // 59: api_container_api.ApiContainerService.ExecCommand:output_type -> api_container_api.ExecCommandResponse + 57, // 60: api_container_api.ApiContainerService.WaitForHttpGetEndpointAvailability:output_type -> google.protobuf.Empty + 57, // 61: api_container_api.ApiContainerService.WaitForHttpPostEndpointAvailability:output_type -> google.protobuf.Empty + 35, // 62: api_container_api.ApiContainerService.UploadFilesArtifact:output_type -> api_container_api.UploadFilesArtifactResponse + 33, // 63: api_container_api.ApiContainerService.DownloadFilesArtifact:output_type -> api_container_api.StreamedDataChunk + 38, // 64: api_container_api.ApiContainerService.StoreWebFilesArtifact:output_type -> api_container_api.StoreWebFilesArtifactResponse + 40, // 65: api_container_api.ApiContainerService.StoreFilesArtifactFromService:output_type -> api_container_api.StoreFilesArtifactFromServiceResponse + 42, // 66: api_container_api.ApiContainerService.ListFilesArtifactNamesAndUuids:output_type -> api_container_api.ListFilesArtifactNamesAndUuidsResponse + 44, // 67: api_container_api.ApiContainerService.InspectFilesArtifactContents:output_type -> api_container_api.InspectFilesArtifactContentsResponse + 47, // 68: api_container_api.ApiContainerService.ConnectServices:output_type -> api_container_api.ConnectServicesResponse + 48, // 69: api_container_api.ApiContainerService.GetStarlarkRun:output_type -> api_container_api.GetStarlarkRunResponse + 49, // 70: api_container_api.ApiContainerService.GetStarlarkScriptPlanYaml:output_type -> api_container_api.PlanYaml + 49, // 71: api_container_api.ApiContainerService.GetStarlarkPackagePlanYaml:output_type -> api_container_api.PlanYaml + 54, // [54:72] is the sub-list for method output_type + 36, // [36:54] is the sub-list for method input_type 36, // [36:36] is the sub-list for extension type_name 36, // [36:36] is the sub-list for extension extendee 0, // [0:36] is the sub-list for field type_name @@ -4643,6 +4885,42 @@ func file_api_container_service_proto_init() { return nil } } + file_api_container_service_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PlanYaml); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_container_service_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StarlarkScriptPlanYamlArgs); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_container_service_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StarlarkPackagePlanYamlArgs); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_api_container_service_proto_msgTypes[3].OneofWrappers = []interface{}{} file_api_container_service_proto_msgTypes[4].OneofWrappers = []interface{}{ @@ -4668,13 +4946,15 @@ func file_api_container_service_proto_init() { file_api_container_service_proto_msgTypes[24].OneofWrappers = []interface{}{} file_api_container_service_proto_msgTypes[25].OneofWrappers = []interface{}{} file_api_container_service_proto_msgTypes[38].OneofWrappers = []interface{}{} + file_api_container_service_proto_msgTypes[43].OneofWrappers = []interface{}{} + file_api_container_service_proto_msgTypes[44].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_api_container_service_proto_rawDesc, NumEnums: 7, - NumMessages: 47, + NumMessages: 50, NumExtensions: 0, NumServices: 1, }, diff --git a/api/golang/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc.pb.go b/api/golang/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc.pb.go index ca2ca2f836..b0740c5e5f 100644 --- a/api/golang/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc.pb.go +++ b/api/golang/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc.pb.go @@ -36,6 +36,8 @@ const ( ApiContainerService_InspectFilesArtifactContents_FullMethodName = "/api_container_api.ApiContainerService/InspectFilesArtifactContents" ApiContainerService_ConnectServices_FullMethodName = "/api_container_api.ApiContainerService/ConnectServices" ApiContainerService_GetStarlarkRun_FullMethodName = "/api_container_api.ApiContainerService/GetStarlarkRun" + ApiContainerService_GetStarlarkScriptPlanYaml_FullMethodName = "/api_container_api.ApiContainerService/GetStarlarkScriptPlanYaml" + ApiContainerService_GetStarlarkPackagePlanYaml_FullMethodName = "/api_container_api.ApiContainerService/GetStarlarkPackagePlanYaml" ) // ApiContainerServiceClient is the client API for ApiContainerService service. @@ -72,6 +74,10 @@ type ApiContainerServiceClient interface { ConnectServices(ctx context.Context, in *ConnectServicesArgs, opts ...grpc.CallOption) (*ConnectServicesResponse, error) // Get last Starlark run GetStarlarkRun(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*GetStarlarkRunResponse, error) + // Gets yaml representing the plan the script will execute in an enclave + GetStarlarkScriptPlanYaml(ctx context.Context, in *StarlarkScriptPlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) + // Gets yaml representing the plan the package will execute in an enclave + GetStarlarkPackagePlanYaml(ctx context.Context, in *StarlarkPackagePlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) } type apiContainerServiceClient struct { @@ -345,6 +351,24 @@ func (c *apiContainerServiceClient) GetStarlarkRun(ctx context.Context, in *empt return out, nil } +func (c *apiContainerServiceClient) GetStarlarkScriptPlanYaml(ctx context.Context, in *StarlarkScriptPlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) { + out := new(PlanYaml) + err := c.cc.Invoke(ctx, ApiContainerService_GetStarlarkScriptPlanYaml_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *apiContainerServiceClient) GetStarlarkPackagePlanYaml(ctx context.Context, in *StarlarkPackagePlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) { + out := new(PlanYaml) + err := c.cc.Invoke(ctx, ApiContainerService_GetStarlarkPackagePlanYaml_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ApiContainerServiceServer is the server API for ApiContainerService service. // All implementations should embed UnimplementedApiContainerServiceServer // for forward compatibility @@ -379,6 +403,10 @@ type ApiContainerServiceServer interface { ConnectServices(context.Context, *ConnectServicesArgs) (*ConnectServicesResponse, error) // Get last Starlark run GetStarlarkRun(context.Context, *emptypb.Empty) (*GetStarlarkRunResponse, error) + // Gets yaml representing the plan the script will execute in an enclave + GetStarlarkScriptPlanYaml(context.Context, *StarlarkScriptPlanYamlArgs) (*PlanYaml, error) + // Gets yaml representing the plan the package will execute in an enclave + GetStarlarkPackagePlanYaml(context.Context, *StarlarkPackagePlanYamlArgs) (*PlanYaml, error) } // UnimplementedApiContainerServiceServer should be embedded to have forward compatible implementations. @@ -433,6 +461,12 @@ func (UnimplementedApiContainerServiceServer) ConnectServices(context.Context, * func (UnimplementedApiContainerServiceServer) GetStarlarkRun(context.Context, *emptypb.Empty) (*GetStarlarkRunResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStarlarkRun not implemented") } +func (UnimplementedApiContainerServiceServer) GetStarlarkScriptPlanYaml(context.Context, *StarlarkScriptPlanYamlArgs) (*PlanYaml, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetStarlarkScriptPlanYaml not implemented") +} +func (UnimplementedApiContainerServiceServer) GetStarlarkPackagePlanYaml(context.Context, *StarlarkPackagePlanYamlArgs) (*PlanYaml, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetStarlarkPackagePlanYaml not implemented") +} // UnsafeApiContainerServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to ApiContainerServiceServer will @@ -758,6 +792,42 @@ func _ApiContainerService_GetStarlarkRun_Handler(srv interface{}, ctx context.Co return interceptor(ctx, in, info, handler) } +func _ApiContainerService_GetStarlarkScriptPlanYaml_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StarlarkScriptPlanYamlArgs) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ApiContainerServiceServer).GetStarlarkScriptPlanYaml(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ApiContainerService_GetStarlarkScriptPlanYaml_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ApiContainerServiceServer).GetStarlarkScriptPlanYaml(ctx, req.(*StarlarkScriptPlanYamlArgs)) + } + return interceptor(ctx, in, info, handler) +} + +func _ApiContainerService_GetStarlarkPackagePlanYaml_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StarlarkPackagePlanYamlArgs) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ApiContainerServiceServer).GetStarlarkPackagePlanYaml(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ApiContainerService_GetStarlarkPackagePlanYaml_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ApiContainerServiceServer).GetStarlarkPackagePlanYaml(ctx, req.(*StarlarkPackagePlanYamlArgs)) + } + return interceptor(ctx, in, info, handler) +} + // ApiContainerService_ServiceDesc is the grpc.ServiceDesc for ApiContainerService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -809,6 +879,14 @@ var ApiContainerService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetStarlarkRun", Handler: _ApiContainerService_GetStarlarkRun_Handler, }, + { + MethodName: "GetStarlarkScriptPlanYaml", + Handler: _ApiContainerService_GetStarlarkScriptPlanYaml_Handler, + }, + { + MethodName: "GetStarlarkPackagePlanYaml", + Handler: _ApiContainerService_GetStarlarkPackagePlanYaml_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/api/golang/core/kurtosis_core_rpc_api_bindings/kurtosis_core_rpc_api_bindingsconnect/api_container_service.connect.go b/api/golang/core/kurtosis_core_rpc_api_bindings/kurtosis_core_rpc_api_bindingsconnect/api_container_service.connect.go index f20776712f..81807b84e2 100644 --- a/api/golang/core/kurtosis_core_rpc_api_bindings/kurtosis_core_rpc_api_bindingsconnect/api_container_service.connect.go +++ b/api/golang/core/kurtosis_core_rpc_api_bindings/kurtosis_core_rpc_api_bindingsconnect/api_container_service.connect.go @@ -82,6 +82,12 @@ const ( // ApiContainerServiceGetStarlarkRunProcedure is the fully-qualified name of the // ApiContainerService's GetStarlarkRun RPC. ApiContainerServiceGetStarlarkRunProcedure = "/api_container_api.ApiContainerService/GetStarlarkRun" + // ApiContainerServiceGetStarlarkScriptPlanYamlProcedure is the fully-qualified name of the + // ApiContainerService's GetStarlarkScriptPlanYaml RPC. + ApiContainerServiceGetStarlarkScriptPlanYamlProcedure = "/api_container_api.ApiContainerService/GetStarlarkScriptPlanYaml" + // ApiContainerServiceGetStarlarkPackagePlanYamlProcedure is the fully-qualified name of the + // ApiContainerService's GetStarlarkPackagePlanYaml RPC. + ApiContainerServiceGetStarlarkPackagePlanYamlProcedure = "/api_container_api.ApiContainerService/GetStarlarkPackagePlanYaml" ) // ApiContainerServiceClient is a client for the api_container_api.ApiContainerService service. @@ -116,6 +122,10 @@ type ApiContainerServiceClient interface { ConnectServices(context.Context, *connect.Request[kurtosis_core_rpc_api_bindings.ConnectServicesArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.ConnectServicesResponse], error) // Get last Starlark run GetStarlarkRun(context.Context, *connect.Request[emptypb.Empty]) (*connect.Response[kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse], error) + // Gets yaml representing the plan the script will execute in an enclave + GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) + // Gets yaml representing the plan the package will execute in an enclave + GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) } // NewApiContainerServiceClient constructs a client for the api_container_api.ApiContainerService @@ -208,6 +218,16 @@ func NewApiContainerServiceClient(httpClient connect.HTTPClient, baseURL string, baseURL+ApiContainerServiceGetStarlarkRunProcedure, opts..., ), + getStarlarkScriptPlanYaml: connect.NewClient[kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs, kurtosis_core_rpc_api_bindings.PlanYaml]( + httpClient, + baseURL+ApiContainerServiceGetStarlarkScriptPlanYamlProcedure, + opts..., + ), + getStarlarkPackagePlanYaml: connect.NewClient[kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs, kurtosis_core_rpc_api_bindings.PlanYaml]( + httpClient, + baseURL+ApiContainerServiceGetStarlarkPackagePlanYamlProcedure, + opts..., + ), } } @@ -229,6 +249,8 @@ type apiContainerServiceClient struct { inspectFilesArtifactContents *connect.Client[kurtosis_core_rpc_api_bindings.InspectFilesArtifactContentsRequest, kurtosis_core_rpc_api_bindings.InspectFilesArtifactContentsResponse] connectServices *connect.Client[kurtosis_core_rpc_api_bindings.ConnectServicesArgs, kurtosis_core_rpc_api_bindings.ConnectServicesResponse] getStarlarkRun *connect.Client[emptypb.Empty, kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse] + getStarlarkScriptPlanYaml *connect.Client[kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs, kurtosis_core_rpc_api_bindings.PlanYaml] + getStarlarkPackagePlanYaml *connect.Client[kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs, kurtosis_core_rpc_api_bindings.PlanYaml] } // RunStarlarkScript calls api_container_api.ApiContainerService.RunStarlarkScript. @@ -317,6 +339,17 @@ func (c *apiContainerServiceClient) GetStarlarkRun(ctx context.Context, req *con return c.getStarlarkRun.CallUnary(ctx, req) } +// GetStarlarkScriptPlanYaml calls api_container_api.ApiContainerService.GetStarlarkScriptPlanYaml. +func (c *apiContainerServiceClient) GetStarlarkScriptPlanYaml(ctx context.Context, req *connect.Request[kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) { + return c.getStarlarkScriptPlanYaml.CallUnary(ctx, req) +} + +// GetStarlarkPackagePlanYaml calls +// api_container_api.ApiContainerService.GetStarlarkPackagePlanYaml. +func (c *apiContainerServiceClient) GetStarlarkPackagePlanYaml(ctx context.Context, req *connect.Request[kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) { + return c.getStarlarkPackagePlanYaml.CallUnary(ctx, req) +} + // ApiContainerServiceHandler is an implementation of the api_container_api.ApiContainerService // service. type ApiContainerServiceHandler interface { @@ -350,6 +383,10 @@ type ApiContainerServiceHandler interface { ConnectServices(context.Context, *connect.Request[kurtosis_core_rpc_api_bindings.ConnectServicesArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.ConnectServicesResponse], error) // Get last Starlark run GetStarlarkRun(context.Context, *connect.Request[emptypb.Empty]) (*connect.Response[kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse], error) + // Gets yaml representing the plan the script will execute in an enclave + GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) + // Gets yaml representing the plan the package will execute in an enclave + GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) } // NewApiContainerServiceHandler builds an HTTP handler from the service implementation. It returns @@ -438,6 +475,16 @@ func NewApiContainerServiceHandler(svc ApiContainerServiceHandler, opts ...conne svc.GetStarlarkRun, opts..., ) + apiContainerServiceGetStarlarkScriptPlanYamlHandler := connect.NewUnaryHandler( + ApiContainerServiceGetStarlarkScriptPlanYamlProcedure, + svc.GetStarlarkScriptPlanYaml, + opts..., + ) + apiContainerServiceGetStarlarkPackagePlanYamlHandler := connect.NewUnaryHandler( + ApiContainerServiceGetStarlarkPackagePlanYamlProcedure, + svc.GetStarlarkPackagePlanYaml, + opts..., + ) return "/api_container_api.ApiContainerService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case ApiContainerServiceRunStarlarkScriptProcedure: @@ -472,6 +519,10 @@ func NewApiContainerServiceHandler(svc ApiContainerServiceHandler, opts ...conne apiContainerServiceConnectServicesHandler.ServeHTTP(w, r) case ApiContainerServiceGetStarlarkRunProcedure: apiContainerServiceGetStarlarkRunHandler.ServeHTTP(w, r) + case ApiContainerServiceGetStarlarkScriptPlanYamlProcedure: + apiContainerServiceGetStarlarkScriptPlanYamlHandler.ServeHTTP(w, r) + case ApiContainerServiceGetStarlarkPackagePlanYamlProcedure: + apiContainerServiceGetStarlarkPackagePlanYamlHandler.ServeHTTP(w, r) default: http.NotFound(w, r) } @@ -544,3 +595,11 @@ func (UnimplementedApiContainerServiceHandler) ConnectServices(context.Context, func (UnimplementedApiContainerServiceHandler) GetStarlarkRun(context.Context, *connect.Request[emptypb.Empty]) (*connect.Response[kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("api_container_api.ApiContainerService.GetStarlarkRun is not implemented")) } + +func (UnimplementedApiContainerServiceHandler) GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("api_container_api.ApiContainerService.GetStarlarkScriptPlanYaml is not implemented")) +} + +func (UnimplementedApiContainerServiceHandler) GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("api_container_api.ApiContainerService.GetStarlarkPackagePlanYaml is not implemented")) +} diff --git a/api/protobuf/core/api_container_service.proto b/api/protobuf/core/api_container_service.proto index fde18b1af4..da013af583 100644 --- a/api/protobuf/core/api_container_service.proto +++ b/api/protobuf/core/api_container_service.proto @@ -57,9 +57,8 @@ service ApiContainerService { // Gets yaml representing the plan the script will execute in an enclave rpc GetStarlarkScriptPlanYaml(StarlarkScriptPlanYamlArgs) returns (PlanYaml) {}; - // Gets yaml representing the plan the package will execute in an enclave - rpc GetStarlarkPackaePlanYaml(StarlarkPackagePlanYamlArgs) returns (PlanYaml) {}; + rpc GetStarlarkPackagePlanYaml(StarlarkPackagePlanYamlArgs) returns (PlanYaml) {}; } // ============================================================================================== diff --git a/api/rust/src/api_container_api.rs b/api/rust/src/api_container_api.rs index 494dfa631d..a65f41f1c1 100644 --- a/api/rust/src/api_container_api.rs +++ b/api/rust/src/api_container_api.rs @@ -679,6 +679,41 @@ pub struct GetStarlarkRunResponse { #[prost(enumeration = "RestartPolicy", tag = "8")] pub restart_policy: i32, } +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PlanYaml { + #[prost(string, tag = "1")] + pub plan_yaml: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StarlarkScriptPlanYamlArgs { + #[prost(string, tag = "1")] + pub serialized_script: ::prost::alloc::string::String, + #[prost(string, optional, tag = "2")] + pub serialized_params: ::core::option::Option<::prost::alloc::string::String>, + /// The name of the main function, the default value is "run" + #[prost(string, optional, tag = "5")] + pub main_function_name: ::core::option::Option<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StarlarkPackagePlanYamlArgs { + #[prost(string, tag = "1")] + pub package_id: ::prost::alloc::string::String, + /// Serialized parameters data for the Starlark package main function + /// This should be a valid JSON string + #[prost(string, optional, tag = "2")] + pub serialized_params: ::core::option::Option<::prost::alloc::string::String>, + /// The relative main file filepath, the default value is the "main.star" file in the root of a package + #[prost(string, optional, tag = "3")] + pub relative_path_to_main_file: ::core::option::Option< + ::prost::alloc::string::String, + >, + /// The name of the main function, the default value is "run" + #[prost(string, optional, tag = "4")] + pub main_function_name: ::core::option::Option<::prost::alloc::string::String>, +} #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum ServiceStatus { @@ -1389,6 +1424,62 @@ pub mod api_container_service_client { ); self.inner.unary(req, path, codec).await } + /// Gets yaml representing the plan the script will execute in an enclave + pub async fn get_starlark_script_plan_yaml( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/api_container_api.ApiContainerService/GetStarlarkScriptPlanYaml", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "api_container_api.ApiContainerService", + "GetStarlarkScriptPlanYaml", + ), + ); + self.inner.unary(req, path, codec).await + } + /// Gets yaml representing the plan the package will execute in an enclave + pub async fn get_starlark_package_plan_yaml( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/api_container_api.ApiContainerService/GetStarlarkPackagePlanYaml", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "api_container_api.ApiContainerService", + "GetStarlarkPackagePlanYaml", + ), + ); + self.inner.unary(req, path, codec).await + } } } /// Generated server implementations. @@ -1533,6 +1624,16 @@ pub mod api_container_service_server { tonic::Response, tonic::Status, >; + /// Gets yaml representing the plan the script will execute in an enclave + async fn get_starlark_script_plan_yaml( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Gets yaml representing the plan the package will execute in an enclave + async fn get_starlark_package_plan_yaml( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; } #[derive(Debug)] pub struct ApiContainerServiceServer { @@ -2379,6 +2480,102 @@ pub mod api_container_service_server { }; Box::pin(fut) } + "/api_container_api.ApiContainerService/GetStarlarkScriptPlanYaml" => { + #[allow(non_camel_case_types)] + struct GetStarlarkScriptPlanYamlSvc( + pub Arc, + ); + impl< + T: ApiContainerService, + > tonic::server::UnaryService + for GetStarlarkScriptPlanYamlSvc { + type Response = super::PlanYaml; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).get_starlark_script_plan_yaml(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = GetStarlarkScriptPlanYamlSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/api_container_api.ApiContainerService/GetStarlarkPackagePlanYaml" => { + #[allow(non_camel_case_types)] + struct GetStarlarkPackagePlanYamlSvc( + pub Arc, + ); + impl< + T: ApiContainerService, + > tonic::server::UnaryService + for GetStarlarkPackagePlanYamlSvc { + type Response = super::PlanYaml; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).get_starlark_package_plan_yaml(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = GetStarlarkPackagePlanYamlSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } _ => { Box::pin(async move { Ok( diff --git a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_pb.d.ts b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_pb.d.ts index a574331973..81a95fd280 100644 --- a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_pb.d.ts +++ b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_pb.d.ts @@ -24,6 +24,8 @@ interface IApiContainerServiceService extends grpc.ServiceDefinition; connectServices: grpc.MethodDefinition; getStarlarkRun: grpc.MethodDefinition; + getStarlarkScriptPlanYaml: grpc.MethodDefinition; + getStarlarkPackagePlanYaml: grpc.MethodDefinition; } export const ApiContainerServiceService: IApiContainerServiceService; @@ -45,6 +47,8 @@ export interface IApiContainerServiceServer extends grpc.UntypedServiceImplement inspectFilesArtifactContents: grpc.handleUnaryCall; connectServices: grpc.handleUnaryCall; getStarlarkRun: grpc.handleUnaryCall; + getStarlarkScriptPlanYaml: grpc.handleUnaryCall; + getStarlarkPackagePlanYaml: grpc.handleUnaryCall; } export class ApiContainerServiceClient extends grpc.Client { @@ -94,4 +98,10 @@ export class ApiContainerServiceClient extends grpc.Client { getStarlarkRun(argument: google_protobuf_empty_pb.Empty, callback: grpc.requestCallback): grpc.ClientUnaryCall; getStarlarkRun(argument: google_protobuf_empty_pb.Empty, metadataOrOptions: grpc.Metadata | grpc.CallOptions | null, callback: grpc.requestCallback): grpc.ClientUnaryCall; getStarlarkRun(argument: google_protobuf_empty_pb.Empty, metadata: grpc.Metadata | null, options: grpc.CallOptions | null, callback: grpc.requestCallback): grpc.ClientUnaryCall; + getStarlarkScriptPlanYaml(argument: api_container_service_pb.StarlarkScriptPlanYamlArgs, callback: grpc.requestCallback): grpc.ClientUnaryCall; + getStarlarkScriptPlanYaml(argument: api_container_service_pb.StarlarkScriptPlanYamlArgs, metadataOrOptions: grpc.Metadata | grpc.CallOptions | null, callback: grpc.requestCallback): grpc.ClientUnaryCall; + getStarlarkScriptPlanYaml(argument: api_container_service_pb.StarlarkScriptPlanYamlArgs, metadata: grpc.Metadata | null, options: grpc.CallOptions | null, callback: grpc.requestCallback): grpc.ClientUnaryCall; + getStarlarkPackagePlanYaml(argument: api_container_service_pb.StarlarkPackagePlanYamlArgs, callback: grpc.requestCallback): grpc.ClientUnaryCall; + getStarlarkPackagePlanYaml(argument: api_container_service_pb.StarlarkPackagePlanYamlArgs, metadataOrOptions: grpc.Metadata | grpc.CallOptions | null, callback: grpc.requestCallback): grpc.ClientUnaryCall; + getStarlarkPackagePlanYaml(argument: api_container_service_pb.StarlarkPackagePlanYamlArgs, metadata: grpc.Metadata | null, options: grpc.CallOptions | null, callback: grpc.requestCallback): grpc.ClientUnaryCall; } diff --git a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_pb.js b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_pb.js index ac624f7ecf..d79e19ea23 100644 --- a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_pb.js +++ b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_pb.js @@ -137,6 +137,17 @@ function deserialize_api_container_api_ListFilesArtifactNamesAndUuidsResponse(bu return api_container_service_pb.ListFilesArtifactNamesAndUuidsResponse.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_api_container_api_PlanYaml(arg) { + if (!(arg instanceof api_container_service_pb.PlanYaml)) { + throw new Error('Expected argument of type api_container_api.PlanYaml'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_api_container_api_PlanYaml(buffer_arg) { + return api_container_service_pb.PlanYaml.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_api_container_api_RunStarlarkPackageArgs(arg) { if (!(arg instanceof api_container_service_pb.RunStarlarkPackageArgs)) { throw new Error('Expected argument of type api_container_api.RunStarlarkPackageArgs'); @@ -159,6 +170,17 @@ function deserialize_api_container_api_RunStarlarkScriptArgs(buffer_arg) { return api_container_service_pb.RunStarlarkScriptArgs.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_api_container_api_StarlarkPackagePlanYamlArgs(arg) { + if (!(arg instanceof api_container_service_pb.StarlarkPackagePlanYamlArgs)) { + throw new Error('Expected argument of type api_container_api.StarlarkPackagePlanYamlArgs'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_api_container_api_StarlarkPackagePlanYamlArgs(buffer_arg) { + return api_container_service_pb.StarlarkPackagePlanYamlArgs.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_api_container_api_StarlarkRunResponseLine(arg) { if (!(arg instanceof api_container_service_pb.StarlarkRunResponseLine)) { throw new Error('Expected argument of type api_container_api.StarlarkRunResponseLine'); @@ -170,6 +192,17 @@ function deserialize_api_container_api_StarlarkRunResponseLine(buffer_arg) { return api_container_service_pb.StarlarkRunResponseLine.deserializeBinary(new Uint8Array(buffer_arg)); } +function serialize_api_container_api_StarlarkScriptPlanYamlArgs(arg) { + if (!(arg instanceof api_container_service_pb.StarlarkScriptPlanYamlArgs)) { + throw new Error('Expected argument of type api_container_api.StarlarkScriptPlanYamlArgs'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_api_container_api_StarlarkScriptPlanYamlArgs(buffer_arg) { + return api_container_service_pb.StarlarkScriptPlanYamlArgs.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_api_container_api_StoreFilesArtifactFromServiceArgs(arg) { if (!(arg instanceof api_container_service_pb.StoreFilesArtifactFromServiceArgs)) { throw new Error('Expected argument of type api_container_api.StoreFilesArtifactFromServiceArgs'); @@ -461,6 +494,30 @@ getStarlarkRun: { responseSerialize: serialize_api_container_api_GetStarlarkRunResponse, responseDeserialize: deserialize_api_container_api_GetStarlarkRunResponse, }, + // Gets yaml representing the plan the script will execute in an enclave +getStarlarkScriptPlanYaml: { + path: '/api_container_api.ApiContainerService/GetStarlarkScriptPlanYaml', + requestStream: false, + responseStream: false, + requestType: api_container_service_pb.StarlarkScriptPlanYamlArgs, + responseType: api_container_service_pb.PlanYaml, + requestSerialize: serialize_api_container_api_StarlarkScriptPlanYamlArgs, + requestDeserialize: deserialize_api_container_api_StarlarkScriptPlanYamlArgs, + responseSerialize: serialize_api_container_api_PlanYaml, + responseDeserialize: deserialize_api_container_api_PlanYaml, + }, + // Gets yaml representing the plan the package will execute in an enclave +getStarlarkPackagePlanYaml: { + path: '/api_container_api.ApiContainerService/GetStarlarkPackagePlanYaml', + requestStream: false, + responseStream: false, + requestType: api_container_service_pb.StarlarkPackagePlanYamlArgs, + responseType: api_container_service_pb.PlanYaml, + requestSerialize: serialize_api_container_api_StarlarkPackagePlanYamlArgs, + requestDeserialize: deserialize_api_container_api_StarlarkPackagePlanYamlArgs, + responseSerialize: serialize_api_container_api_PlanYaml, + responseDeserialize: deserialize_api_container_api_PlanYaml, + }, }; exports.ApiContainerServiceClient = grpc.makeGenericClientConstructor(ApiContainerServiceService); diff --git a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_web_pb.d.ts b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_web_pb.d.ts index f5505b0e0e..4b1d68af33 100644 --- a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_web_pb.d.ts +++ b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_web_pb.d.ts @@ -101,6 +101,20 @@ export class ApiContainerServiceClient { response: api_container_service_pb.GetStarlarkRunResponse) => void ): grpcWeb.ClientReadableStream; + getStarlarkScriptPlanYaml( + request: api_container_service_pb.StarlarkScriptPlanYamlArgs, + metadata: grpcWeb.Metadata | undefined, + callback: (err: grpcWeb.RpcError, + response: api_container_service_pb.PlanYaml) => void + ): grpcWeb.ClientReadableStream; + + getStarlarkPackagePlanYaml( + request: api_container_service_pb.StarlarkPackagePlanYamlArgs, + metadata: grpcWeb.Metadata | undefined, + callback: (err: grpcWeb.RpcError, + response: api_container_service_pb.PlanYaml) => void + ): grpcWeb.ClientReadableStream; + } export class ApiContainerServicePromiseClient { @@ -178,5 +192,15 @@ export class ApiContainerServicePromiseClient { metadata?: grpcWeb.Metadata ): Promise; + getStarlarkScriptPlanYaml( + request: api_container_service_pb.StarlarkScriptPlanYamlArgs, + metadata?: grpcWeb.Metadata + ): Promise; + + getStarlarkPackagePlanYaml( + request: api_container_service_pb.StarlarkPackagePlanYamlArgs, + metadata?: grpcWeb.Metadata + ): Promise; + } diff --git a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_web_pb.js b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_web_pb.js index 07732d2fbc..d21fe965e4 100644 --- a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_web_pb.js +++ b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_grpc_web_pb.js @@ -915,5 +915,127 @@ proto.api_container_api.ApiContainerServicePromiseClient.prototype.getStarlarkRu }; +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.api_container_api.StarlarkScriptPlanYamlArgs, + * !proto.api_container_api.PlanYaml>} + */ +const methodDescriptor_ApiContainerService_GetStarlarkScriptPlanYaml = new grpc.web.MethodDescriptor( + '/api_container_api.ApiContainerService/GetStarlarkScriptPlanYaml', + grpc.web.MethodType.UNARY, + proto.api_container_api.StarlarkScriptPlanYamlArgs, + proto.api_container_api.PlanYaml, + /** + * @param {!proto.api_container_api.StarlarkScriptPlanYamlArgs} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + proto.api_container_api.PlanYaml.deserializeBinary +); + + +/** + * @param {!proto.api_container_api.StarlarkScriptPlanYamlArgs} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.RpcError, ?proto.api_container_api.PlanYaml)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.api_container_api.ApiContainerServiceClient.prototype.getStarlarkScriptPlanYaml = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/api_container_api.ApiContainerService/GetStarlarkScriptPlanYaml', + request, + metadata || {}, + methodDescriptor_ApiContainerService_GetStarlarkScriptPlanYaml, + callback); +}; + + +/** + * @param {!proto.api_container_api.StarlarkScriptPlanYamlArgs} request The + * request proto + * @param {?Object=} metadata User defined + * call metadata + * @return {!Promise} + * Promise that resolves to the response + */ +proto.api_container_api.ApiContainerServicePromiseClient.prototype.getStarlarkScriptPlanYaml = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/api_container_api.ApiContainerService/GetStarlarkScriptPlanYaml', + request, + metadata || {}, + methodDescriptor_ApiContainerService_GetStarlarkScriptPlanYaml); +}; + + +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.api_container_api.StarlarkPackagePlanYamlArgs, + * !proto.api_container_api.PlanYaml>} + */ +const methodDescriptor_ApiContainerService_GetStarlarkPackagePlanYaml = new grpc.web.MethodDescriptor( + '/api_container_api.ApiContainerService/GetStarlarkPackagePlanYaml', + grpc.web.MethodType.UNARY, + proto.api_container_api.StarlarkPackagePlanYamlArgs, + proto.api_container_api.PlanYaml, + /** + * @param {!proto.api_container_api.StarlarkPackagePlanYamlArgs} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + proto.api_container_api.PlanYaml.deserializeBinary +); + + +/** + * @param {!proto.api_container_api.StarlarkPackagePlanYamlArgs} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.RpcError, ?proto.api_container_api.PlanYaml)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.api_container_api.ApiContainerServiceClient.prototype.getStarlarkPackagePlanYaml = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/api_container_api.ApiContainerService/GetStarlarkPackagePlanYaml', + request, + metadata || {}, + methodDescriptor_ApiContainerService_GetStarlarkPackagePlanYaml, + callback); +}; + + +/** + * @param {!proto.api_container_api.StarlarkPackagePlanYamlArgs} request The + * request proto + * @param {?Object=} metadata User defined + * call metadata + * @return {!Promise} + * Promise that resolves to the response + */ +proto.api_container_api.ApiContainerServicePromiseClient.prototype.getStarlarkPackagePlanYaml = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/api_container_api.ApiContainerService/GetStarlarkPackagePlanYaml', + request, + metadata || {}, + methodDescriptor_ApiContainerService_GetStarlarkPackagePlanYaml); +}; + + module.exports = proto.api_container_api; diff --git a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_pb.d.ts b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_pb.d.ts index 13742313fe..7310abe338 100644 --- a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_pb.d.ts +++ b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_pb.d.ts @@ -1435,6 +1435,115 @@ export namespace GetStarlarkRunResponse { } } +export class PlanYaml extends jspb.Message { + getPlanYaml(): string; + setPlanYaml(value: string): PlanYaml; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): PlanYaml.AsObject; + static toObject(includeInstance: boolean, msg: PlanYaml): PlanYaml.AsObject; + static serializeBinaryToWriter(message: PlanYaml, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): PlanYaml; + static deserializeBinaryFromReader(message: PlanYaml, reader: jspb.BinaryReader): PlanYaml; +} + +export namespace PlanYaml { + export type AsObject = { + planYaml: string, + } +} + +export class StarlarkScriptPlanYamlArgs extends jspb.Message { + getSerializedScript(): string; + setSerializedScript(value: string): StarlarkScriptPlanYamlArgs; + + getSerializedParams(): string; + setSerializedParams(value: string): StarlarkScriptPlanYamlArgs; + hasSerializedParams(): boolean; + clearSerializedParams(): StarlarkScriptPlanYamlArgs; + + getMainFunctionName(): string; + setMainFunctionName(value: string): StarlarkScriptPlanYamlArgs; + hasMainFunctionName(): boolean; + clearMainFunctionName(): StarlarkScriptPlanYamlArgs; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): StarlarkScriptPlanYamlArgs.AsObject; + static toObject(includeInstance: boolean, msg: StarlarkScriptPlanYamlArgs): StarlarkScriptPlanYamlArgs.AsObject; + static serializeBinaryToWriter(message: StarlarkScriptPlanYamlArgs, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): StarlarkScriptPlanYamlArgs; + static deserializeBinaryFromReader(message: StarlarkScriptPlanYamlArgs, reader: jspb.BinaryReader): StarlarkScriptPlanYamlArgs; +} + +export namespace StarlarkScriptPlanYamlArgs { + export type AsObject = { + serializedScript: string, + serializedParams?: string, + mainFunctionName?: string, + } + + export enum SerializedParamsCase { + _SERIALIZED_PARAMS_NOT_SET = 0, + SERIALIZED_PARAMS = 2, + } + + export enum MainFunctionNameCase { + _MAIN_FUNCTION_NAME_NOT_SET = 0, + MAIN_FUNCTION_NAME = 5, + } +} + +export class StarlarkPackagePlanYamlArgs extends jspb.Message { + getPackageId(): string; + setPackageId(value: string): StarlarkPackagePlanYamlArgs; + + getSerializedParams(): string; + setSerializedParams(value: string): StarlarkPackagePlanYamlArgs; + hasSerializedParams(): boolean; + clearSerializedParams(): StarlarkPackagePlanYamlArgs; + + getRelativePathToMainFile(): string; + setRelativePathToMainFile(value: string): StarlarkPackagePlanYamlArgs; + hasRelativePathToMainFile(): boolean; + clearRelativePathToMainFile(): StarlarkPackagePlanYamlArgs; + + getMainFunctionName(): string; + setMainFunctionName(value: string): StarlarkPackagePlanYamlArgs; + hasMainFunctionName(): boolean; + clearMainFunctionName(): StarlarkPackagePlanYamlArgs; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): StarlarkPackagePlanYamlArgs.AsObject; + static toObject(includeInstance: boolean, msg: StarlarkPackagePlanYamlArgs): StarlarkPackagePlanYamlArgs.AsObject; + static serializeBinaryToWriter(message: StarlarkPackagePlanYamlArgs, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): StarlarkPackagePlanYamlArgs; + static deserializeBinaryFromReader(message: StarlarkPackagePlanYamlArgs, reader: jspb.BinaryReader): StarlarkPackagePlanYamlArgs; +} + +export namespace StarlarkPackagePlanYamlArgs { + export type AsObject = { + packageId: string, + serializedParams?: string, + relativePathToMainFile?: string, + mainFunctionName?: string, + } + + export enum SerializedParamsCase { + _SERIALIZED_PARAMS_NOT_SET = 0, + SERIALIZED_PARAMS = 2, + } + + export enum RelativePathToMainFileCase { + _RELATIVE_PATH_TO_MAIN_FILE_NOT_SET = 0, + RELATIVE_PATH_TO_MAIN_FILE = 3, + } + + export enum MainFunctionNameCase { + _MAIN_FUNCTION_NAME_NOT_SET = 0, + MAIN_FUNCTION_NAME = 4, + } +} + export enum ServiceStatus { STOPPED = 0, RUNNING = 1, diff --git a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_pb.js b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_pb.js index 49174b1033..316a1532ff 100644 --- a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_pb.js +++ b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/api_container_service_pb.js @@ -43,6 +43,7 @@ goog.exportSymbol('proto.api_container_api.InspectFilesArtifactContentsRequest', goog.exportSymbol('proto.api_container_api.InspectFilesArtifactContentsResponse', null, global); goog.exportSymbol('proto.api_container_api.KurtosisFeatureFlag', null, global); goog.exportSymbol('proto.api_container_api.ListFilesArtifactNamesAndUuidsResponse', null, global); +goog.exportSymbol('proto.api_container_api.PlanYaml', null, global); goog.exportSymbol('proto.api_container_api.Port', null, global); goog.exportSymbol('proto.api_container_api.Port.TransportProtocol', null, global); goog.exportSymbol('proto.api_container_api.RestartPolicy', null, global); @@ -61,10 +62,12 @@ goog.exportSymbol('proto.api_container_api.StarlarkInstructionArg', null, global goog.exportSymbol('proto.api_container_api.StarlarkInstructionPosition', null, global); goog.exportSymbol('proto.api_container_api.StarlarkInstructionResult', null, global); goog.exportSymbol('proto.api_container_api.StarlarkInterpretationError', null, global); +goog.exportSymbol('proto.api_container_api.StarlarkPackagePlanYamlArgs', null, global); goog.exportSymbol('proto.api_container_api.StarlarkRunFinishedEvent', null, global); goog.exportSymbol('proto.api_container_api.StarlarkRunProgress', null, global); goog.exportSymbol('proto.api_container_api.StarlarkRunResponseLine', null, global); goog.exportSymbol('proto.api_container_api.StarlarkRunResponseLine.RunResponseLineCase', null, global); +goog.exportSymbol('proto.api_container_api.StarlarkScriptPlanYamlArgs', null, global); goog.exportSymbol('proto.api_container_api.StarlarkValidationError', null, global); goog.exportSymbol('proto.api_container_api.StarlarkWarning', null, global); goog.exportSymbol('proto.api_container_api.StoreFilesArtifactFromServiceArgs', null, global); @@ -957,6 +960,69 @@ if (goog.DEBUG && !COMPILED) { */ proto.api_container_api.GetStarlarkRunResponse.displayName = 'proto.api_container_api.GetStarlarkRunResponse'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.api_container_api.PlanYaml = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.api_container_api.PlanYaml, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.api_container_api.PlanYaml.displayName = 'proto.api_container_api.PlanYaml'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.api_container_api.StarlarkScriptPlanYamlArgs, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.api_container_api.StarlarkScriptPlanYamlArgs.displayName = 'proto.api_container_api.StarlarkScriptPlanYamlArgs'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.api_container_api.StarlarkPackagePlanYamlArgs, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.api_container_api.StarlarkPackagePlanYamlArgs.displayName = 'proto.api_container_api.StarlarkPackagePlanYamlArgs'; +} @@ -10460,6 +10526,636 @@ proto.api_container_api.GetStarlarkRunResponse.prototype.setRestartPolicy = func }; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.api_container_api.PlanYaml.prototype.toObject = function(opt_includeInstance) { + return proto.api_container_api.PlanYaml.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.api_container_api.PlanYaml} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.api_container_api.PlanYaml.toObject = function(includeInstance, msg) { + var f, obj = { + planYaml: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.api_container_api.PlanYaml} + */ +proto.api_container_api.PlanYaml.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.api_container_api.PlanYaml; + return proto.api_container_api.PlanYaml.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.api_container_api.PlanYaml} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.api_container_api.PlanYaml} + */ +proto.api_container_api.PlanYaml.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setPlanYaml(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.api_container_api.PlanYaml.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.api_container_api.PlanYaml.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.api_container_api.PlanYaml} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.api_container_api.PlanYaml.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getPlanYaml(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string plan_yaml = 1; + * @return {string} + */ +proto.api_container_api.PlanYaml.prototype.getPlanYaml = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.api_container_api.PlanYaml} returns this + */ +proto.api_container_api.PlanYaml.prototype.setPlanYaml = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.toObject = function(opt_includeInstance) { + return proto.api_container_api.StarlarkScriptPlanYamlArgs.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.api_container_api.StarlarkScriptPlanYamlArgs} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.toObject = function(includeInstance, msg) { + var f, obj = { + serializedScript: jspb.Message.getFieldWithDefault(msg, 1, ""), + serializedParams: jspb.Message.getFieldWithDefault(msg, 2, ""), + mainFunctionName: jspb.Message.getFieldWithDefault(msg, 5, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.api_container_api.StarlarkScriptPlanYamlArgs} + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.api_container_api.StarlarkScriptPlanYamlArgs; + return proto.api_container_api.StarlarkScriptPlanYamlArgs.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.api_container_api.StarlarkScriptPlanYamlArgs} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.api_container_api.StarlarkScriptPlanYamlArgs} + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setSerializedScript(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setSerializedParams(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.setMainFunctionName(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.api_container_api.StarlarkScriptPlanYamlArgs.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.api_container_api.StarlarkScriptPlanYamlArgs} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSerializedScript(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeString( + 5, + f + ); + } +}; + + +/** + * optional string serialized_script = 1; + * @return {string} + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.getSerializedScript = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.api_container_api.StarlarkScriptPlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.setSerializedScript = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string serialized_params = 2; + * @return {string} + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.getSerializedParams = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.api_container_api.StarlarkScriptPlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.setSerializedParams = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.api_container_api.StarlarkScriptPlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.clearSerializedParams = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.hasSerializedParams = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional string main_function_name = 5; + * @return {string} + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.getMainFunctionName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); +}; + + +/** + * @param {string} value + * @return {!proto.api_container_api.StarlarkScriptPlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.setMainFunctionName = function(value) { + return jspb.Message.setField(this, 5, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.api_container_api.StarlarkScriptPlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.clearMainFunctionName = function() { + return jspb.Message.setField(this, 5, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.api_container_api.StarlarkScriptPlanYamlArgs.prototype.hasMainFunctionName = function() { + return jspb.Message.getField(this, 5) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.toObject = function(opt_includeInstance) { + return proto.api_container_api.StarlarkPackagePlanYamlArgs.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.api_container_api.StarlarkPackagePlanYamlArgs} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.toObject = function(includeInstance, msg) { + var f, obj = { + packageId: jspb.Message.getFieldWithDefault(msg, 1, ""), + serializedParams: jspb.Message.getFieldWithDefault(msg, 2, ""), + relativePathToMainFile: jspb.Message.getFieldWithDefault(msg, 3, ""), + mainFunctionName: jspb.Message.getFieldWithDefault(msg, 4, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.api_container_api.StarlarkPackagePlanYamlArgs; + return proto.api_container_api.StarlarkPackagePlanYamlArgs.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.api_container_api.StarlarkPackagePlanYamlArgs} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setPackageId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setSerializedParams(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setRelativePathToMainFile(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setMainFunctionName(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.api_container_api.StarlarkPackagePlanYamlArgs.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.api_container_api.StarlarkPackagePlanYamlArgs} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getPackageId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeString( + 4, + f + ); + } +}; + + +/** + * optional string package_id = 1; + * @return {string} + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.getPackageId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setPackageId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string serialized_params = 2; + * @return {string} + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.getSerializedParams = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setSerializedParams = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.clearSerializedParams = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.hasSerializedParams = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional string relative_path_to_main_file = 3; + * @return {string} + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.getRelativePathToMainFile = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setRelativePathToMainFile = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.clearRelativePathToMainFile = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.hasRelativePathToMainFile = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional string main_function_name = 4; + * @return {string} + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.getMainFunctionName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setMainFunctionName = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.clearMainFunctionName = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.hasMainFunctionName = function() { + return jspb.Message.getField(this, 4) != null; +}; + + /** * @enum {number} */ diff --git a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_connect.d.ts b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_connect.d.ts index 201f76f184..a8be359ca1 100644 --- a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_connect.d.ts +++ b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_connect.d.ts @@ -3,7 +3,7 @@ /* eslint-disable */ // @ts-nocheck -import { ConnectServicesArgs, ConnectServicesResponse, DownloadFilesArtifactArgs, ExecCommandArgs, ExecCommandResponse, GetExistingAndHistoricalServiceIdentifiersResponse, GetServicesArgs, GetServicesResponse, GetStarlarkRunResponse, InspectFilesArtifactContentsRequest, InspectFilesArtifactContentsResponse, ListFilesArtifactNamesAndUuidsResponse, RunStarlarkPackageArgs, RunStarlarkScriptArgs, StarlarkRunResponseLine, StoreFilesArtifactFromServiceArgs, StoreFilesArtifactFromServiceResponse, StoreWebFilesArtifactArgs, StoreWebFilesArtifactResponse, StreamedDataChunk, UploadFilesArtifactResponse, WaitForHttpGetEndpointAvailabilityArgs, WaitForHttpPostEndpointAvailabilityArgs } from "./api_container_service_pb.js"; +import { ConnectServicesArgs, ConnectServicesResponse, DownloadFilesArtifactArgs, ExecCommandArgs, ExecCommandResponse, GetExistingAndHistoricalServiceIdentifiersResponse, GetServicesArgs, GetServicesResponse, GetStarlarkRunResponse, InspectFilesArtifactContentsRequest, InspectFilesArtifactContentsResponse, ListFilesArtifactNamesAndUuidsResponse, PlanYaml, RunStarlarkPackageArgs, RunStarlarkScriptArgs, StarlarkPackagePlanYamlArgs, StarlarkRunResponseLine, StarlarkScriptPlanYamlArgs, StoreFilesArtifactFromServiceArgs, StoreFilesArtifactFromServiceResponse, StoreWebFilesArtifactArgs, StoreWebFilesArtifactResponse, StreamedDataChunk, UploadFilesArtifactResponse, WaitForHttpGetEndpointAvailabilityArgs, WaitForHttpPostEndpointAvailabilityArgs } from "./api_container_service_pb.js"; import { Empty, MethodKind } from "@bufbuild/protobuf"; /** @@ -184,6 +184,28 @@ export declare const ApiContainerService: { readonly O: typeof GetStarlarkRunResponse, readonly kind: MethodKind.Unary, }, + /** + * Gets yaml representing the plan the script will execute in an enclave + * + * @generated from rpc api_container_api.ApiContainerService.GetStarlarkScriptPlanYaml + */ + readonly getStarlarkScriptPlanYaml: { + readonly name: "GetStarlarkScriptPlanYaml", + readonly I: typeof StarlarkScriptPlanYamlArgs, + readonly O: typeof PlanYaml, + readonly kind: MethodKind.Unary, + }, + /** + * Gets yaml representing the plan the package will execute in an enclave + * + * @generated from rpc api_container_api.ApiContainerService.GetStarlarkPackagePlanYaml + */ + readonly getStarlarkPackagePlanYaml: { + readonly name: "GetStarlarkPackagePlanYaml", + readonly I: typeof StarlarkPackagePlanYamlArgs, + readonly O: typeof PlanYaml, + readonly kind: MethodKind.Unary, + }, } }; diff --git a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_connect.js b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_connect.js index 627620d9d8..a3c7ddc8e0 100644 --- a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_connect.js +++ b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_connect.js @@ -3,7 +3,7 @@ /* eslint-disable */ // @ts-nocheck -import { ConnectServicesArgs, ConnectServicesResponse, DownloadFilesArtifactArgs, ExecCommandArgs, ExecCommandResponse, GetExistingAndHistoricalServiceIdentifiersResponse, GetServicesArgs, GetServicesResponse, GetStarlarkRunResponse, InspectFilesArtifactContentsRequest, InspectFilesArtifactContentsResponse, ListFilesArtifactNamesAndUuidsResponse, RunStarlarkPackageArgs, RunStarlarkScriptArgs, StarlarkRunResponseLine, StoreFilesArtifactFromServiceArgs, StoreFilesArtifactFromServiceResponse, StoreWebFilesArtifactArgs, StoreWebFilesArtifactResponse, StreamedDataChunk, UploadFilesArtifactResponse, WaitForHttpGetEndpointAvailabilityArgs, WaitForHttpPostEndpointAvailabilityArgs } from "./api_container_service_pb.js"; +import { ConnectServicesArgs, ConnectServicesResponse, DownloadFilesArtifactArgs, ExecCommandArgs, ExecCommandResponse, GetExistingAndHistoricalServiceIdentifiersResponse, GetServicesArgs, GetServicesResponse, GetStarlarkRunResponse, InspectFilesArtifactContentsRequest, InspectFilesArtifactContentsResponse, ListFilesArtifactNamesAndUuidsResponse, PlanYaml, RunStarlarkPackageArgs, RunStarlarkScriptArgs, StarlarkPackagePlanYamlArgs, StarlarkRunResponseLine, StarlarkScriptPlanYamlArgs, StoreFilesArtifactFromServiceArgs, StoreFilesArtifactFromServiceResponse, StoreWebFilesArtifactArgs, StoreWebFilesArtifactResponse, StreamedDataChunk, UploadFilesArtifactResponse, WaitForHttpGetEndpointAvailabilityArgs, WaitForHttpPostEndpointAvailabilityArgs } from "./api_container_service_pb.js"; import { Empty, MethodKind } from "@bufbuild/protobuf"; /** @@ -184,6 +184,28 @@ export const ApiContainerService = { O: GetStarlarkRunResponse, kind: MethodKind.Unary, }, + /** + * Gets yaml representing the plan the script will execute in an enclave + * + * @generated from rpc api_container_api.ApiContainerService.GetStarlarkScriptPlanYaml + */ + getStarlarkScriptPlanYaml: { + name: "GetStarlarkScriptPlanYaml", + I: StarlarkScriptPlanYamlArgs, + O: PlanYaml, + kind: MethodKind.Unary, + }, + /** + * Gets yaml representing the plan the package will execute in an enclave + * + * @generated from rpc api_container_api.ApiContainerService.GetStarlarkPackagePlanYaml + */ + getStarlarkPackagePlanYaml: { + name: "GetStarlarkPackagePlanYaml", + I: StarlarkPackagePlanYamlArgs, + O: PlanYaml, + kind: MethodKind.Unary, + }, } }; diff --git a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_pb.d.ts b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_pb.d.ts index b45831ded6..3fbfbeb5f8 100644 --- a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_pb.d.ts +++ b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_pb.d.ts @@ -1809,3 +1809,109 @@ export declare class GetStarlarkRunResponse extends Message | undefined, b: GetStarlarkRunResponse | PlainMessage | undefined): boolean; } +/** + * @generated from message api_container_api.PlanYaml + */ +export declare class PlanYaml extends Message { + /** + * @generated from field: string plan_yaml = 1; + */ + planYaml: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "api_container_api.PlanYaml"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): PlanYaml; + + static fromJson(jsonValue: JsonValue, options?: Partial): PlanYaml; + + static fromJsonString(jsonString: string, options?: Partial): PlanYaml; + + static equals(a: PlanYaml | PlainMessage | undefined, b: PlanYaml | PlainMessage | undefined): boolean; +} + +/** + * @generated from message api_container_api.StarlarkScriptPlanYamlArgs + */ +export declare class StarlarkScriptPlanYamlArgs extends Message { + /** + * @generated from field: string serialized_script = 1; + */ + serializedScript: string; + + /** + * @generated from field: optional string serialized_params = 2; + */ + serializedParams?: string; + + /** + * The name of the main function, the default value is "run" + * + * @generated from field: optional string main_function_name = 5; + */ + mainFunctionName?: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "api_container_api.StarlarkScriptPlanYamlArgs"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): StarlarkScriptPlanYamlArgs; + + static fromJson(jsonValue: JsonValue, options?: Partial): StarlarkScriptPlanYamlArgs; + + static fromJsonString(jsonString: string, options?: Partial): StarlarkScriptPlanYamlArgs; + + static equals(a: StarlarkScriptPlanYamlArgs | PlainMessage | undefined, b: StarlarkScriptPlanYamlArgs | PlainMessage | undefined): boolean; +} + +/** + * @generated from message api_container_api.StarlarkPackagePlanYamlArgs + */ +export declare class StarlarkPackagePlanYamlArgs extends Message { + /** + * @generated from field: string package_id = 1; + */ + packageId: string; + + /** + * Serialized parameters data for the Starlark package main function + * This should be a valid JSON string + * + * @generated from field: optional string serialized_params = 2; + */ + serializedParams?: string; + + /** + * The relative main file filepath, the default value is the "main.star" file in the root of a package + * + * @generated from field: optional string relative_path_to_main_file = 3; + */ + relativePathToMainFile?: string; + + /** + * The name of the main function, the default value is "run" + * + * @generated from field: optional string main_function_name = 4; + */ + mainFunctionName?: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "api_container_api.StarlarkPackagePlanYamlArgs"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): StarlarkPackagePlanYamlArgs; + + static fromJson(jsonValue: JsonValue, options?: Partial): StarlarkPackagePlanYamlArgs; + + static fromJsonString(jsonString: string, options?: Partial): StarlarkPackagePlanYamlArgs; + + static equals(a: StarlarkPackagePlanYamlArgs | PlainMessage | undefined, b: StarlarkPackagePlanYamlArgs | PlainMessage | undefined): boolean; +} + diff --git a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_pb.js b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_pb.js index dd244aa275..85aa14826f 100644 --- a/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_pb.js +++ b/api/typescript/src/core/kurtosis_core_rpc_api_bindings/connect/api_container_service_pb.js @@ -636,3 +636,38 @@ export const GetStarlarkRunResponse = proto3.makeMessageType( ], ); +/** + * @generated from message api_container_api.PlanYaml + */ +export const PlanYaml = proto3.makeMessageType( + "api_container_api.PlanYaml", + () => [ + { no: 1, name: "plan_yaml", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message api_container_api.StarlarkScriptPlanYamlArgs + */ +export const StarlarkScriptPlanYamlArgs = proto3.makeMessageType( + "api_container_api.StarlarkScriptPlanYamlArgs", + () => [ + { no: 1, name: "serialized_script", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "serialized_params", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, + { no: 5, name: "main_function_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, + ], +); + +/** + * @generated from message api_container_api.StarlarkPackagePlanYamlArgs + */ +export const StarlarkPackagePlanYamlArgs = proto3.makeMessageType( + "api_container_api.StarlarkPackagePlanYamlArgs", + () => [ + { no: 1, name: "package_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "serialized_params", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, + { no: 3, name: "relative_path_to_main_file", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, + { no: 4, name: "main_function_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, + ], +); + diff --git a/core/server/api_container/server/api_container_service.go b/core/server/api_container/server/api_container_service.go index 49592a4b83..e409a9349b 100644 --- a/core/server/api_container/server/api_container_service.go +++ b/core/server/api_container/server/api_container_service.go @@ -594,6 +594,10 @@ func (apicService *ApiContainerService) GetStarlarkRun(_ context.Context, _ *emp return apicService.starlarkRun, nil } +func (apicService *ApiContainerService) GetStarlark + + + // ==================================================================================================== // // Private helper methods diff --git a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api.pb.go b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api.pb.go index 0fb7382651..588ceeef6d 100644 --- a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api.pb.go +++ b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc-gen-go v1.32.0 +// protoc v4.25.2 // source: kurtosis_enclave_manager_api.proto package kurtosis_enclave_manager_api_bindings @@ -586,6 +586,179 @@ func (x *GetStarlarkRunRequest) GetApicPort() int32 { return 0 } +type PlanYaml struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PlanYaml string `protobuf:"bytes,1,opt,name=plan_yaml,json=planYaml,proto3" json:"plan_yaml,omitempty"` +} + +func (x *PlanYaml) Reset() { + *x = PlanYaml{} + if protoimpl.UnsafeEnabled { + mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PlanYaml) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PlanYaml) ProtoMessage() {} + +func (x *PlanYaml) ProtoReflect() protoreflect.Message { + mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PlanYaml.ProtoReflect.Descriptor instead. +func (*PlanYaml) Descriptor() ([]byte, []int) { + return file_kurtosis_enclave_manager_api_proto_rawDescGZIP(), []int{9} +} + +func (x *PlanYaml) GetPlanYaml() string { + if x != nil { + return x.PlanYaml + } + return "" +} + +type StarlarkScriptPlanYamlArgs struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ApicIpAddress string `protobuf:"bytes,1,opt,name=apic_ip_address,json=apicIpAddress,proto3" json:"apic_ip_address,omitempty"` + ApicPort int32 `protobuf:"varint,2,opt,name=apic_port,json=apicPort,proto3" json:"apic_port,omitempty"` + StarlarkPackagePlanYamlArgs *kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs `protobuf:"bytes,3,opt,name=starlark_package_plan_yaml_args,json=starlarkPackagePlanYamlArgs,proto3" json:"starlark_package_plan_yaml_args,omitempty"` +} + +func (x *StarlarkScriptPlanYamlArgs) Reset() { + *x = StarlarkScriptPlanYamlArgs{} + if protoimpl.UnsafeEnabled { + mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StarlarkScriptPlanYamlArgs) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StarlarkScriptPlanYamlArgs) ProtoMessage() {} + +func (x *StarlarkScriptPlanYamlArgs) ProtoReflect() protoreflect.Message { + mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StarlarkScriptPlanYamlArgs.ProtoReflect.Descriptor instead. +func (*StarlarkScriptPlanYamlArgs) Descriptor() ([]byte, []int) { + return file_kurtosis_enclave_manager_api_proto_rawDescGZIP(), []int{10} +} + +func (x *StarlarkScriptPlanYamlArgs) GetApicIpAddress() string { + if x != nil { + return x.ApicIpAddress + } + return "" +} + +func (x *StarlarkScriptPlanYamlArgs) GetApicPort() int32 { + if x != nil { + return x.ApicPort + } + return 0 +} + +func (x *StarlarkScriptPlanYamlArgs) GetStarlarkPackagePlanYamlArgs() *kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs { + if x != nil { + return x.StarlarkPackagePlanYamlArgs + } + return nil +} + +type StarlarkPackagePlanYamlArgs struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ApicIpAddress string `protobuf:"bytes,1,opt,name=apic_ip_address,json=apicIpAddress,proto3" json:"apic_ip_address,omitempty"` + ApicPort int32 `protobuf:"varint,2,opt,name=apic_port,json=apicPort,proto3" json:"apic_port,omitempty"` + StarlarkScriptPlanYamlArgs *kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs `protobuf:"bytes,3,opt,name=starlark_script_plan_yaml_args,json=starlarkScriptPlanYamlArgs,proto3" json:"starlark_script_plan_yaml_args,omitempty"` +} + +func (x *StarlarkPackagePlanYamlArgs) Reset() { + *x = StarlarkPackagePlanYamlArgs{} + if protoimpl.UnsafeEnabled { + mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StarlarkPackagePlanYamlArgs) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StarlarkPackagePlanYamlArgs) ProtoMessage() {} + +func (x *StarlarkPackagePlanYamlArgs) ProtoReflect() protoreflect.Message { + mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StarlarkPackagePlanYamlArgs.ProtoReflect.Descriptor instead. +func (*StarlarkPackagePlanYamlArgs) Descriptor() ([]byte, []int) { + return file_kurtosis_enclave_manager_api_proto_rawDescGZIP(), []int{11} +} + +func (x *StarlarkPackagePlanYamlArgs) GetApicIpAddress() string { + if x != nil { + return x.ApicIpAddress + } + return "" +} + +func (x *StarlarkPackagePlanYamlArgs) GetApicPort() int32 { + if x != nil { + return x.ApicPort + } + return 0 +} + +func (x *StarlarkPackagePlanYamlArgs) GetStarlarkScriptPlanYamlArgs() *kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs { + if x != nil { + return x.StarlarkScriptPlanYamlArgs + } + return nil +} + var File_kurtosis_enclave_manager_api_proto protoreflect.FileDescriptor var file_kurtosis_enclave_manager_api_proto_rawDesc = []byte{ @@ -681,99 +854,144 @@ var file_kurtosis_enclave_manager_api_proto_rawDesc = []byte{ 0x63, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x70, 0x69, 0x63, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x70, 0x69, 0x63, 0x50, 0x6f, 0x72, 0x74, 0x32, 0xce, - 0x0a, 0x0a, 0x1c, 0x4b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x45, 0x6e, 0x63, 0x6c, 0x61, - 0x76, 0x65, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, - 0x64, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x2c, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, - 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, - 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x45, 0x6e, 0x63, 0x6c, - 0x61, 0x76, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1f, 0x2e, 0x65, - 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x6e, 0x63, - 0x6c, 0x61, 0x76, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x65, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x2c, - 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, - 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x61, - 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, - 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, - 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x4c, 0x6f, 0x67, 0x73, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x22, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, - 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, - 0x12, 0xa1, 0x01, 0x0a, 0x1e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, - 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x55, 0x75, - 0x69, 0x64, 0x73, 0x12, 0x42, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, - 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x47, - 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, - 0x61, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x55, 0x75, 0x69, 0x64, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, - 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x4e, 0x61, 0x6d, - 0x65, 0x73, 0x41, 0x6e, 0x64, 0x55, 0x75, 0x69, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x79, 0x0a, 0x12, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, - 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x33, 0x2e, 0x6b, 0x75, 0x72, - 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, - 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, - 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, - 0x77, 0x0a, 0x11, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x12, 0x32, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, - 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, - 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, - 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x4c, 0x69, 0x6e, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x53, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x12, 0x1d, 0x2e, 0x65, 0x6e, 0x67, 0x69, - 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x63, - 0x6c, 0x61, 0x76, 0x65, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x21, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, - 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x63, 0x6c, - 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x98, 0x01, - 0x0a, 0x1c, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, - 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3d, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x70, 0x69, 0x63, 0x50, 0x6f, 0x72, 0x74, 0x22, 0x27, + 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x6c, + 0x61, 0x6e, 0x5f, 0x79, 0x61, 0x6d, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, + 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x22, 0xd6, 0x01, 0x0a, 0x1a, 0x53, 0x74, 0x61, 0x72, + 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, + 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x69, + 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0d, 0x61, 0x70, 0x69, 0x63, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, + 0x0a, 0x09, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x08, 0x61, 0x70, 0x69, 0x63, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x73, 0x0a, 0x1f, 0x73, + 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5f, + 0x70, 0x6c, 0x61, 0x6e, 0x5f, 0x79, 0x61, 0x6d, 0x6c, 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, + 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, + 0x72, 0x67, 0x73, 0x52, 0x1b, 0x73, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, + 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, + 0x22, 0xd6, 0x01, 0x0a, 0x1b, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, + 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, + 0x12, 0x26, 0x0a, 0x0f, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x70, 0x69, 0x63, 0x49, + 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x70, 0x69, 0x63, + 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x70, 0x69, + 0x63, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x72, 0x0a, 0x1e, 0x73, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, + 0x6b, 0x5f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x5f, 0x70, 0x6c, 0x61, 0x6e, 0x5f, 0x79, 0x61, + 0x6d, 0x6c, 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, + 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, + 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, + 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x52, 0x1a, 0x73, + 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, + 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x32, 0xc2, 0x0c, 0x0a, 0x1c, 0x4b, 0x75, + 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x4d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x64, 0x0a, 0x05, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x12, 0x2c, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, + 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x48, + 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x2d, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, + 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x61, + 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x48, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x73, 0x12, + 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, + 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x0b, 0x47, 0x65, + 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x2c, 0x2e, 0x6b, 0x75, 0x72, 0x74, + 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x58, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, + 0x6f, 0x67, 0x73, 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, + 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x41, + 0x72, 0x67, 0x73, 0x1a, 0x22, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, + 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0xa1, 0x01, 0x0a, 0x1e, + 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, + 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x55, 0x75, 0x69, 0x64, 0x73, 0x12, 0x42, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, - 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, - 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, + 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, + 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x4e, 0x61, + 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x55, 0x75, 0x69, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, + 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, + 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, + 0x55, 0x75, 0x69, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x79, 0x0a, 0x12, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x33, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, + 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, + 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, + 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x77, 0x0a, 0x11, 0x52, 0x75, + 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, + 0x32, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, + 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x52, 0x75, 0x6e, 0x53, 0x74, + 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, + 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, + 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x22, + 0x00, 0x30, 0x01, 0x12, 0x53, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x63, + 0x6c, 0x61, 0x76, 0x65, 0x12, 0x1d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, + 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x41, + 0x72, 0x67, 0x73, 0x1a, 0x21, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x98, 0x01, 0x0a, 0x1c, 0x49, 0x6e, 0x73, + 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, + 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3d, 0x2e, 0x6b, 0x75, 0x72, 0x74, + 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, + 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, + 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x73, + 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, + 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x79, 0x0a, 0x15, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, + 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x36, 0x2e, 0x6b, + 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, + 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, + 0x64, 0x44, 0x61, 0x74, 0x61, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x22, 0x00, 0x30, 0x01, 0x12, 0x4a, + 0x0a, 0x0e, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, + 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x65, + 0x73, 0x74, 0x72, 0x6f, 0x79, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x41, 0x72, 0x67, 0x73, + 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x6e, 0x0a, 0x0e, 0x47, 0x65, + 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x12, 0x2f, 0x2e, 0x6b, + 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, + 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, - 0x69, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, - 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x79, 0x0a, 0x15, 0x44, 0x6f, 0x77, 0x6e, - 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, - 0x74, 0x12, 0x36, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, - 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x77, - 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, - 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x5f, - 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x22, - 0x00, 0x30, 0x01, 0x12, 0x4a, 0x0a, 0x0e, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, 0x45, 0x6e, - 0x63, 0x6c, 0x61, 0x76, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, - 0x70, 0x69, 0x2e, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, - 0x65, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, - 0x6e, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, - 0x6e, 0x12, 0x2f, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, - 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, - 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, - 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, - 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, - 0x64, 0x5a, 0x62, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, - 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x2d, 0x74, 0x65, 0x63, 0x68, 0x2f, 0x6b, 0x75, 0x72, 0x74, - 0x6f, 0x73, 0x69, 0x73, 0x2f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x2d, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, + 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x77, 0x0a, 0x19, 0x47, 0x65, + 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, + 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x34, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, + 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x22, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, - 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x5f, 0x62, 0x69, 0x6e, - 0x64, 0x69, 0x6e, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, + 0x6c, 0x22, 0x00, 0x12, 0x79, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, + 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, + 0x6c, 0x12, 0x35, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, + 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, + 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, + 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x22, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, + 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x22, 0x00, 0x42, 0x64, + 0x5a, 0x62, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x72, + 0x74, 0x6f, 0x73, 0x69, 0x73, 0x2d, 0x74, 0x65, 0x63, 0x68, 0x2f, 0x6b, 0x75, 0x72, 0x74, 0x6f, + 0x73, 0x69, 0x73, 0x2f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x2d, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x6b, + 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x5f, 0x62, 0x69, 0x6e, 0x64, + 0x69, 0x6e, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -789,7 +1007,7 @@ func file_kurtosis_enclave_manager_api_proto_rawDescGZIP() []byte { } var file_kurtosis_enclave_manager_api_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_kurtosis_enclave_manager_api_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_kurtosis_enclave_manager_api_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_kurtosis_enclave_manager_api_proto_goTypes = []interface{}{ (HealthCheckResponse_ServingStatus)(0), // 0: kurtosis_enclave_manager.HealthCheckResponse.ServingStatus (*HealthCheckRequest)(nil), // 1: kurtosis_enclave_manager.HealthCheckRequest @@ -801,59 +1019,70 @@ var file_kurtosis_enclave_manager_api_proto_goTypes = []interface{}{ (*InspectFilesArtifactContentsRequest)(nil), // 7: kurtosis_enclave_manager.InspectFilesArtifactContentsRequest (*DownloadFilesArtifactRequest)(nil), // 8: kurtosis_enclave_manager.DownloadFilesArtifactRequest (*GetStarlarkRunRequest)(nil), // 9: kurtosis_enclave_manager.GetStarlarkRunRequest - (*kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs)(nil), // 10: api_container_api.RunStarlarkPackageArgs - (*kurtosis_core_rpc_api_bindings.RunStarlarkScriptArgs)(nil), // 11: api_container_api.RunStarlarkScriptArgs - (*kurtosis_core_rpc_api_bindings.FilesArtifactNameAndUuid)(nil), // 12: api_container_api.FilesArtifactNameAndUuid - (*kurtosis_core_rpc_api_bindings.DownloadFilesArtifactArgs)(nil), // 13: api_container_api.DownloadFilesArtifactArgs - (*emptypb.Empty)(nil), // 14: google.protobuf.Empty - (*kurtosis_engine_rpc_api_bindings.GetServiceLogsArgs)(nil), // 15: engine_api.GetServiceLogsArgs - (*kurtosis_engine_rpc_api_bindings.CreateEnclaveArgs)(nil), // 16: engine_api.CreateEnclaveArgs - (*kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs)(nil), // 17: engine_api.DestroyEnclaveArgs - (*kurtosis_engine_rpc_api_bindings.GetEnclavesResponse)(nil), // 18: engine_api.GetEnclavesResponse - (*kurtosis_core_rpc_api_bindings.GetServicesResponse)(nil), // 19: api_container_api.GetServicesResponse - (*kurtosis_engine_rpc_api_bindings.GetServiceLogsResponse)(nil), // 20: engine_api.GetServiceLogsResponse - (*kurtosis_core_rpc_api_bindings.ListFilesArtifactNamesAndUuidsResponse)(nil), // 21: api_container_api.ListFilesArtifactNamesAndUuidsResponse - (*kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine)(nil), // 22: api_container_api.StarlarkRunResponseLine - (*kurtosis_engine_rpc_api_bindings.CreateEnclaveResponse)(nil), // 23: engine_api.CreateEnclaveResponse - (*kurtosis_core_rpc_api_bindings.InspectFilesArtifactContentsResponse)(nil), // 24: api_container_api.InspectFilesArtifactContentsResponse - (*kurtosis_core_rpc_api_bindings.StreamedDataChunk)(nil), // 25: api_container_api.StreamedDataChunk - (*kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse)(nil), // 26: api_container_api.GetStarlarkRunResponse + (*PlanYaml)(nil), // 10: kurtosis_enclave_manager.PlanYaml + (*StarlarkScriptPlanYamlArgs)(nil), // 11: kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs + (*StarlarkPackagePlanYamlArgs)(nil), // 12: kurtosis_enclave_manager.StarlarkPackagePlanYamlArgs + (*kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs)(nil), // 13: api_container_api.RunStarlarkPackageArgs + (*kurtosis_core_rpc_api_bindings.RunStarlarkScriptArgs)(nil), // 14: api_container_api.RunStarlarkScriptArgs + (*kurtosis_core_rpc_api_bindings.FilesArtifactNameAndUuid)(nil), // 15: api_container_api.FilesArtifactNameAndUuid + (*kurtosis_core_rpc_api_bindings.DownloadFilesArtifactArgs)(nil), // 16: api_container_api.DownloadFilesArtifactArgs + (*kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs)(nil), // 17: api_container_api.StarlarkScriptPlanYamlArgs + (*kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs)(nil), // 18: api_container_api.StarlarkPackagePlanYamlArgs + (*emptypb.Empty)(nil), // 19: google.protobuf.Empty + (*kurtosis_engine_rpc_api_bindings.GetServiceLogsArgs)(nil), // 20: engine_api.GetServiceLogsArgs + (*kurtosis_engine_rpc_api_bindings.CreateEnclaveArgs)(nil), // 21: engine_api.CreateEnclaveArgs + (*kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs)(nil), // 22: engine_api.DestroyEnclaveArgs + (*kurtosis_engine_rpc_api_bindings.GetEnclavesResponse)(nil), // 23: engine_api.GetEnclavesResponse + (*kurtosis_core_rpc_api_bindings.GetServicesResponse)(nil), // 24: api_container_api.GetServicesResponse + (*kurtosis_engine_rpc_api_bindings.GetServiceLogsResponse)(nil), // 25: engine_api.GetServiceLogsResponse + (*kurtosis_core_rpc_api_bindings.ListFilesArtifactNamesAndUuidsResponse)(nil), // 26: api_container_api.ListFilesArtifactNamesAndUuidsResponse + (*kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine)(nil), // 27: api_container_api.StarlarkRunResponseLine + (*kurtosis_engine_rpc_api_bindings.CreateEnclaveResponse)(nil), // 28: engine_api.CreateEnclaveResponse + (*kurtosis_core_rpc_api_bindings.InspectFilesArtifactContentsResponse)(nil), // 29: api_container_api.InspectFilesArtifactContentsResponse + (*kurtosis_core_rpc_api_bindings.StreamedDataChunk)(nil), // 30: api_container_api.StreamedDataChunk + (*kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse)(nil), // 31: api_container_api.GetStarlarkRunResponse } var file_kurtosis_enclave_manager_api_proto_depIdxs = []int32{ 0, // 0: kurtosis_enclave_manager.HealthCheckResponse.status:type_name -> kurtosis_enclave_manager.HealthCheckResponse.ServingStatus - 10, // 1: kurtosis_enclave_manager.RunStarlarkPackageRequest.RunStarlarkPackageArgs:type_name -> api_container_api.RunStarlarkPackageArgs - 11, // 2: kurtosis_enclave_manager.RunStarlarkScriptRequest.RunStarlarkScriptArgs:type_name -> api_container_api.RunStarlarkScriptArgs - 12, // 3: kurtosis_enclave_manager.InspectFilesArtifactContentsRequest.file_names_and_uuid:type_name -> api_container_api.FilesArtifactNameAndUuid - 13, // 4: kurtosis_enclave_manager.DownloadFilesArtifactRequest.download_files_artifacts_args:type_name -> api_container_api.DownloadFilesArtifactArgs - 1, // 5: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.Check:input_type -> kurtosis_enclave_manager.HealthCheckRequest - 14, // 6: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetEnclaves:input_type -> google.protobuf.Empty - 3, // 7: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServices:input_type -> kurtosis_enclave_manager.GetServicesRequest - 15, // 8: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServiceLogs:input_type -> engine_api.GetServiceLogsArgs - 4, // 9: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.ListFilesArtifactNamesAndUuids:input_type -> kurtosis_enclave_manager.GetListFilesArtifactNamesAndUuidsRequest - 5, // 10: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkPackage:input_type -> kurtosis_enclave_manager.RunStarlarkPackageRequest - 6, // 11: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkScript:input_type -> kurtosis_enclave_manager.RunStarlarkScriptRequest - 16, // 12: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.CreateEnclave:input_type -> engine_api.CreateEnclaveArgs - 7, // 13: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.InspectFilesArtifactContents:input_type -> kurtosis_enclave_manager.InspectFilesArtifactContentsRequest - 8, // 14: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DownloadFilesArtifact:input_type -> kurtosis_enclave_manager.DownloadFilesArtifactRequest - 17, // 15: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DestroyEnclave:input_type -> engine_api.DestroyEnclaveArgs - 9, // 16: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkRun:input_type -> kurtosis_enclave_manager.GetStarlarkRunRequest - 2, // 17: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.Check:output_type -> kurtosis_enclave_manager.HealthCheckResponse - 18, // 18: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetEnclaves:output_type -> engine_api.GetEnclavesResponse - 19, // 19: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServices:output_type -> api_container_api.GetServicesResponse - 20, // 20: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServiceLogs:output_type -> engine_api.GetServiceLogsResponse - 21, // 21: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.ListFilesArtifactNamesAndUuids:output_type -> api_container_api.ListFilesArtifactNamesAndUuidsResponse - 22, // 22: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkPackage:output_type -> api_container_api.StarlarkRunResponseLine - 22, // 23: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkScript:output_type -> api_container_api.StarlarkRunResponseLine - 23, // 24: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.CreateEnclave:output_type -> engine_api.CreateEnclaveResponse - 24, // 25: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.InspectFilesArtifactContents:output_type -> api_container_api.InspectFilesArtifactContentsResponse - 25, // 26: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DownloadFilesArtifact:output_type -> api_container_api.StreamedDataChunk - 14, // 27: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DestroyEnclave:output_type -> google.protobuf.Empty - 26, // 28: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkRun:output_type -> api_container_api.GetStarlarkRunResponse - 17, // [17:29] is the sub-list for method output_type - 5, // [5:17] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 13, // 1: kurtosis_enclave_manager.RunStarlarkPackageRequest.RunStarlarkPackageArgs:type_name -> api_container_api.RunStarlarkPackageArgs + 14, // 2: kurtosis_enclave_manager.RunStarlarkScriptRequest.RunStarlarkScriptArgs:type_name -> api_container_api.RunStarlarkScriptArgs + 15, // 3: kurtosis_enclave_manager.InspectFilesArtifactContentsRequest.file_names_and_uuid:type_name -> api_container_api.FilesArtifactNameAndUuid + 16, // 4: kurtosis_enclave_manager.DownloadFilesArtifactRequest.download_files_artifacts_args:type_name -> api_container_api.DownloadFilesArtifactArgs + 17, // 5: kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs.starlark_package_plan_yaml_args:type_name -> api_container_api.StarlarkScriptPlanYamlArgs + 18, // 6: kurtosis_enclave_manager.StarlarkPackagePlanYamlArgs.starlark_script_plan_yaml_args:type_name -> api_container_api.StarlarkPackagePlanYamlArgs + 1, // 7: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.Check:input_type -> kurtosis_enclave_manager.HealthCheckRequest + 19, // 8: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetEnclaves:input_type -> google.protobuf.Empty + 3, // 9: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServices:input_type -> kurtosis_enclave_manager.GetServicesRequest + 20, // 10: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServiceLogs:input_type -> engine_api.GetServiceLogsArgs + 4, // 11: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.ListFilesArtifactNamesAndUuids:input_type -> kurtosis_enclave_manager.GetListFilesArtifactNamesAndUuidsRequest + 5, // 12: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkPackage:input_type -> kurtosis_enclave_manager.RunStarlarkPackageRequest + 6, // 13: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkScript:input_type -> kurtosis_enclave_manager.RunStarlarkScriptRequest + 21, // 14: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.CreateEnclave:input_type -> engine_api.CreateEnclaveArgs + 7, // 15: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.InspectFilesArtifactContents:input_type -> kurtosis_enclave_manager.InspectFilesArtifactContentsRequest + 8, // 16: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DownloadFilesArtifact:input_type -> kurtosis_enclave_manager.DownloadFilesArtifactRequest + 22, // 17: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DestroyEnclave:input_type -> engine_api.DestroyEnclaveArgs + 9, // 18: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkRun:input_type -> kurtosis_enclave_manager.GetStarlarkRunRequest + 11, // 19: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkScriptPlanYaml:input_type -> kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs + 12, // 20: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkPackagePlanYaml:input_type -> kurtosis_enclave_manager.StarlarkPackagePlanYamlArgs + 2, // 21: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.Check:output_type -> kurtosis_enclave_manager.HealthCheckResponse + 23, // 22: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetEnclaves:output_type -> engine_api.GetEnclavesResponse + 24, // 23: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServices:output_type -> api_container_api.GetServicesResponse + 25, // 24: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServiceLogs:output_type -> engine_api.GetServiceLogsResponse + 26, // 25: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.ListFilesArtifactNamesAndUuids:output_type -> api_container_api.ListFilesArtifactNamesAndUuidsResponse + 27, // 26: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkPackage:output_type -> api_container_api.StarlarkRunResponseLine + 27, // 27: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkScript:output_type -> api_container_api.StarlarkRunResponseLine + 28, // 28: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.CreateEnclave:output_type -> engine_api.CreateEnclaveResponse + 29, // 29: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.InspectFilesArtifactContents:output_type -> api_container_api.InspectFilesArtifactContentsResponse + 30, // 30: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DownloadFilesArtifact:output_type -> api_container_api.StreamedDataChunk + 19, // 31: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DestroyEnclave:output_type -> google.protobuf.Empty + 31, // 32: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkRun:output_type -> api_container_api.GetStarlarkRunResponse + 10, // 33: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkScriptPlanYaml:output_type -> kurtosis_enclave_manager.PlanYaml + 10, // 34: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkPackagePlanYaml:output_type -> kurtosis_enclave_manager.PlanYaml + 21, // [21:35] is the sub-list for method output_type + 7, // [7:21] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_kurtosis_enclave_manager_api_proto_init() } @@ -970,6 +1199,42 @@ func file_kurtosis_enclave_manager_api_proto_init() { return nil } } + file_kurtosis_enclave_manager_api_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PlanYaml); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kurtosis_enclave_manager_api_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StarlarkScriptPlanYamlArgs); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kurtosis_enclave_manager_api_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StarlarkPackagePlanYamlArgs); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -977,7 +1242,7 @@ func file_kurtosis_enclave_manager_api_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_kurtosis_enclave_manager_api_proto_rawDesc, NumEnums: 1, - NumMessages: 9, + NumMessages: 12, NumExtensions: 0, NumServices: 1, }, diff --git a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_bindingsconnect/kurtosis_enclave_manager_api.connect.go b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_bindingsconnect/kurtosis_enclave_manager_api.connect.go index e51bade598..95009ac32c 100644 --- a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_bindingsconnect/kurtosis_enclave_manager_api.connect.go +++ b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_bindingsconnect/kurtosis_enclave_manager_api.connect.go @@ -73,6 +73,12 @@ const ( // KurtosisEnclaveManagerServerGetStarlarkRunProcedure is the fully-qualified name of the // KurtosisEnclaveManagerServer's GetStarlarkRun RPC. KurtosisEnclaveManagerServerGetStarlarkRunProcedure = "/kurtosis_enclave_manager.KurtosisEnclaveManagerServer/GetStarlarkRun" + // KurtosisEnclaveManagerServerGetStarlarkScriptPlanYamlProcedure is the fully-qualified name of the + // KurtosisEnclaveManagerServer's GetStarlarkScriptPlanYaml RPC. + KurtosisEnclaveManagerServerGetStarlarkScriptPlanYamlProcedure = "/kurtosis_enclave_manager.KurtosisEnclaveManagerServer/GetStarlarkScriptPlanYaml" + // KurtosisEnclaveManagerServerGetStarlarkPackagePlanYamlProcedure is the fully-qualified name of + // the KurtosisEnclaveManagerServer's GetStarlarkPackagePlanYaml RPC. + KurtosisEnclaveManagerServerGetStarlarkPackagePlanYamlProcedure = "/kurtosis_enclave_manager.KurtosisEnclaveManagerServer/GetStarlarkPackagePlanYaml" ) // KurtosisEnclaveManagerServerClient is a client for the @@ -90,6 +96,8 @@ type KurtosisEnclaveManagerServerClient interface { DownloadFilesArtifact(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.DownloadFilesArtifactRequest]) (*connect.ServerStreamForClient[kurtosis_core_rpc_api_bindings.StreamedDataChunk], error) DestroyEnclave(context.Context, *connect.Request[kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs]) (*connect.Response[emptypb.Empty], error) GetStarlarkRun(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.GetStarlarkRunRequest]) (*connect.Response[kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse], error) + GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) + GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) } // NewKurtosisEnclaveManagerServerClient constructs a client for the @@ -163,6 +171,16 @@ func NewKurtosisEnclaveManagerServerClient(httpClient connect.HTTPClient, baseUR baseURL+KurtosisEnclaveManagerServerGetStarlarkRunProcedure, opts..., ), + getStarlarkScriptPlanYaml: connect.NewClient[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs, kurtosis_enclave_manager_api_bindings.PlanYaml]( + httpClient, + baseURL+KurtosisEnclaveManagerServerGetStarlarkScriptPlanYamlProcedure, + opts..., + ), + getStarlarkPackagePlanYaml: connect.NewClient[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs, kurtosis_enclave_manager_api_bindings.PlanYaml]( + httpClient, + baseURL+KurtosisEnclaveManagerServerGetStarlarkPackagePlanYamlProcedure, + opts..., + ), } } @@ -180,6 +198,8 @@ type kurtosisEnclaveManagerServerClient struct { downloadFilesArtifact *connect.Client[kurtosis_enclave_manager_api_bindings.DownloadFilesArtifactRequest, kurtosis_core_rpc_api_bindings.StreamedDataChunk] destroyEnclave *connect.Client[kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs, emptypb.Empty] getStarlarkRun *connect.Client[kurtosis_enclave_manager_api_bindings.GetStarlarkRunRequest, kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse] + getStarlarkScriptPlanYaml *connect.Client[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs, kurtosis_enclave_manager_api_bindings.PlanYaml] + getStarlarkPackagePlanYaml *connect.Client[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs, kurtosis_enclave_manager_api_bindings.PlanYaml] } // Check calls kurtosis_enclave_manager.KurtosisEnclaveManagerServer.Check. @@ -246,6 +266,18 @@ func (c *kurtosisEnclaveManagerServerClient) GetStarlarkRun(ctx context.Context, return c.getStarlarkRun.CallUnary(ctx, req) } +// GetStarlarkScriptPlanYaml calls +// kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkScriptPlanYaml. +func (c *kurtosisEnclaveManagerServerClient) GetStarlarkScriptPlanYaml(ctx context.Context, req *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) { + return c.getStarlarkScriptPlanYaml.CallUnary(ctx, req) +} + +// GetStarlarkPackagePlanYaml calls +// kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkPackagePlanYaml. +func (c *kurtosisEnclaveManagerServerClient) GetStarlarkPackagePlanYaml(ctx context.Context, req *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) { + return c.getStarlarkPackagePlanYaml.CallUnary(ctx, req) +} + // KurtosisEnclaveManagerServerHandler is an implementation of the // kurtosis_enclave_manager.KurtosisEnclaveManagerServer service. type KurtosisEnclaveManagerServerHandler interface { @@ -261,6 +293,8 @@ type KurtosisEnclaveManagerServerHandler interface { DownloadFilesArtifact(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.DownloadFilesArtifactRequest], *connect.ServerStream[kurtosis_core_rpc_api_bindings.StreamedDataChunk]) error DestroyEnclave(context.Context, *connect.Request[kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs]) (*connect.Response[emptypb.Empty], error) GetStarlarkRun(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.GetStarlarkRunRequest]) (*connect.Response[kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse], error) + GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) + GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) } // NewKurtosisEnclaveManagerServerHandler builds an HTTP handler from the service implementation. It @@ -329,6 +363,16 @@ func NewKurtosisEnclaveManagerServerHandler(svc KurtosisEnclaveManagerServerHand svc.GetStarlarkRun, opts..., ) + kurtosisEnclaveManagerServerGetStarlarkScriptPlanYamlHandler := connect.NewUnaryHandler( + KurtosisEnclaveManagerServerGetStarlarkScriptPlanYamlProcedure, + svc.GetStarlarkScriptPlanYaml, + opts..., + ) + kurtosisEnclaveManagerServerGetStarlarkPackagePlanYamlHandler := connect.NewUnaryHandler( + KurtosisEnclaveManagerServerGetStarlarkPackagePlanYamlProcedure, + svc.GetStarlarkPackagePlanYaml, + opts..., + ) return "/kurtosis_enclave_manager.KurtosisEnclaveManagerServer/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case KurtosisEnclaveManagerServerCheckProcedure: @@ -355,6 +399,10 @@ func NewKurtosisEnclaveManagerServerHandler(svc KurtosisEnclaveManagerServerHand kurtosisEnclaveManagerServerDestroyEnclaveHandler.ServeHTTP(w, r) case KurtosisEnclaveManagerServerGetStarlarkRunProcedure: kurtosisEnclaveManagerServerGetStarlarkRunHandler.ServeHTTP(w, r) + case KurtosisEnclaveManagerServerGetStarlarkScriptPlanYamlProcedure: + kurtosisEnclaveManagerServerGetStarlarkScriptPlanYamlHandler.ServeHTTP(w, r) + case KurtosisEnclaveManagerServerGetStarlarkPackagePlanYamlProcedure: + kurtosisEnclaveManagerServerGetStarlarkPackagePlanYamlHandler.ServeHTTP(w, r) default: http.NotFound(w, r) } @@ -411,3 +459,11 @@ func (UnimplementedKurtosisEnclaveManagerServerHandler) DestroyEnclave(context.C func (UnimplementedKurtosisEnclaveManagerServerHandler) GetStarlarkRun(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.GetStarlarkRunRequest]) (*connect.Response[kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkRun is not implemented")) } + +func (UnimplementedKurtosisEnclaveManagerServerHandler) GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkScriptPlanYaml is not implemented")) +} + +func (UnimplementedKurtosisEnclaveManagerServerHandler) GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkPackagePlanYaml is not implemented")) +} diff --git a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_grpc.pb.go b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_grpc.pb.go index 8495d11622..cca6659d42 100644 --- a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_grpc.pb.go +++ b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.24.4 +// - protoc v4.25.2 // source: kurtosis_enclave_manager_api.proto package kurtosis_enclave_manager_api_bindings @@ -34,6 +34,8 @@ const ( KurtosisEnclaveManagerServer_DownloadFilesArtifact_FullMethodName = "/kurtosis_enclave_manager.KurtosisEnclaveManagerServer/DownloadFilesArtifact" KurtosisEnclaveManagerServer_DestroyEnclave_FullMethodName = "/kurtosis_enclave_manager.KurtosisEnclaveManagerServer/DestroyEnclave" KurtosisEnclaveManagerServer_GetStarlarkRun_FullMethodName = "/kurtosis_enclave_manager.KurtosisEnclaveManagerServer/GetStarlarkRun" + KurtosisEnclaveManagerServer_GetStarlarkScriptPlanYaml_FullMethodName = "/kurtosis_enclave_manager.KurtosisEnclaveManagerServer/GetStarlarkScriptPlanYaml" + KurtosisEnclaveManagerServer_GetStarlarkPackagePlanYaml_FullMethodName = "/kurtosis_enclave_manager.KurtosisEnclaveManagerServer/GetStarlarkPackagePlanYaml" ) // KurtosisEnclaveManagerServerClient is the client API for KurtosisEnclaveManagerServer service. @@ -52,6 +54,8 @@ type KurtosisEnclaveManagerServerClient interface { DownloadFilesArtifact(ctx context.Context, in *DownloadFilesArtifactRequest, opts ...grpc.CallOption) (KurtosisEnclaveManagerServer_DownloadFilesArtifactClient, error) DestroyEnclave(ctx context.Context, in *kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs, opts ...grpc.CallOption) (*emptypb.Empty, error) GetStarlarkRun(ctx context.Context, in *GetStarlarkRunRequest, opts ...grpc.CallOption) (*kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse, error) + GetStarlarkScriptPlanYaml(ctx context.Context, in *StarlarkScriptPlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) + GetStarlarkPackagePlanYaml(ctx context.Context, in *StarlarkPackagePlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) } type kurtosisEnclaveManagerServerClient struct { @@ -262,6 +266,24 @@ func (c *kurtosisEnclaveManagerServerClient) GetStarlarkRun(ctx context.Context, return out, nil } +func (c *kurtosisEnclaveManagerServerClient) GetStarlarkScriptPlanYaml(ctx context.Context, in *StarlarkScriptPlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) { + out := new(PlanYaml) + err := c.cc.Invoke(ctx, KurtosisEnclaveManagerServer_GetStarlarkScriptPlanYaml_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kurtosisEnclaveManagerServerClient) GetStarlarkPackagePlanYaml(ctx context.Context, in *StarlarkPackagePlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) { + out := new(PlanYaml) + err := c.cc.Invoke(ctx, KurtosisEnclaveManagerServer_GetStarlarkPackagePlanYaml_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // KurtosisEnclaveManagerServerServer is the server API for KurtosisEnclaveManagerServer service. // All implementations should embed UnimplementedKurtosisEnclaveManagerServerServer // for forward compatibility @@ -278,6 +300,8 @@ type KurtosisEnclaveManagerServerServer interface { DownloadFilesArtifact(*DownloadFilesArtifactRequest, KurtosisEnclaveManagerServer_DownloadFilesArtifactServer) error DestroyEnclave(context.Context, *kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs) (*emptypb.Empty, error) GetStarlarkRun(context.Context, *GetStarlarkRunRequest) (*kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse, error) + GetStarlarkScriptPlanYaml(context.Context, *StarlarkScriptPlanYamlArgs) (*PlanYaml, error) + GetStarlarkPackagePlanYaml(context.Context, *StarlarkPackagePlanYamlArgs) (*PlanYaml, error) } // UnimplementedKurtosisEnclaveManagerServerServer should be embedded to have forward compatible implementations. @@ -320,6 +344,12 @@ func (UnimplementedKurtosisEnclaveManagerServerServer) DestroyEnclave(context.Co func (UnimplementedKurtosisEnclaveManagerServerServer) GetStarlarkRun(context.Context, *GetStarlarkRunRequest) (*kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStarlarkRun not implemented") } +func (UnimplementedKurtosisEnclaveManagerServerServer) GetStarlarkScriptPlanYaml(context.Context, *StarlarkScriptPlanYamlArgs) (*PlanYaml, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetStarlarkScriptPlanYaml not implemented") +} +func (UnimplementedKurtosisEnclaveManagerServerServer) GetStarlarkPackagePlanYaml(context.Context, *StarlarkPackagePlanYamlArgs) (*PlanYaml, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetStarlarkPackagePlanYaml not implemented") +} // UnsafeKurtosisEnclaveManagerServerServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to KurtosisEnclaveManagerServerServer will @@ -560,6 +590,42 @@ func _KurtosisEnclaveManagerServer_GetStarlarkRun_Handler(srv interface{}, ctx c return interceptor(ctx, in, info, handler) } +func _KurtosisEnclaveManagerServer_GetStarlarkScriptPlanYaml_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StarlarkScriptPlanYamlArgs) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KurtosisEnclaveManagerServerServer).GetStarlarkScriptPlanYaml(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KurtosisEnclaveManagerServer_GetStarlarkScriptPlanYaml_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KurtosisEnclaveManagerServerServer).GetStarlarkScriptPlanYaml(ctx, req.(*StarlarkScriptPlanYamlArgs)) + } + return interceptor(ctx, in, info, handler) +} + +func _KurtosisEnclaveManagerServer_GetStarlarkPackagePlanYaml_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StarlarkPackagePlanYamlArgs) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KurtosisEnclaveManagerServerServer).GetStarlarkPackagePlanYaml(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KurtosisEnclaveManagerServer_GetStarlarkPackagePlanYaml_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KurtosisEnclaveManagerServerServer).GetStarlarkPackagePlanYaml(ctx, req.(*StarlarkPackagePlanYamlArgs)) + } + return interceptor(ctx, in, info, handler) +} + // KurtosisEnclaveManagerServer_ServiceDesc is the grpc.ServiceDesc for KurtosisEnclaveManagerServer service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -599,6 +665,14 @@ var KurtosisEnclaveManagerServer_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetStarlarkRun", Handler: _KurtosisEnclaveManagerServer_GetStarlarkRun_Handler, }, + { + MethodName: "GetStarlarkScriptPlanYaml", + Handler: _KurtosisEnclaveManagerServer_GetStarlarkScriptPlanYaml_Handler, + }, + { + MethodName: "GetStarlarkPackagePlanYaml", + Handler: _KurtosisEnclaveManagerServer_GetStarlarkPackagePlanYaml_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto b/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto index b7fe22a5da..1fef3dcc5a 100644 --- a/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto +++ b/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto @@ -22,7 +22,7 @@ service KurtosisEnclaveManagerServer { rpc DestroyEnclave(engine_api.DestroyEnclaveArgs) returns (google.protobuf.Empty) {}; rpc GetStarlarkRun(GetStarlarkRunRequest) returns (api_container_api.GetStarlarkRunResponse) {}; rpc GetStarlarkScriptPlanYaml(StarlarkScriptPlanYamlArgs) returns (PlanYaml) {}; - rpc GetStarlarkPackaePlanYaml(StarlarkPackagePlanYamlArgs) returns (PlanYaml) {}; + rpc GetStarlarkPackagePlanYaml(StarlarkPackagePlanYamlArgs) returns (PlanYaml) {}; } message HealthCheckRequest { @@ -91,11 +91,11 @@ message StarlarkScriptPlanYamlArgs { string apic_ip_address = 1; int32 apic_port = 2; - api_container_api.GetStarlarkPackagePlanYamlRequest starlark_package_plan_yaml_args = 3; + api_container_api.StarlarkScriptPlanYamlArgs starlark_package_plan_yaml_args = 3; } message StarlarkPackagePlanYamlArgs { string apic_ip_address = 1; int32 apic_port = 2; - api_container_api.GetStarlarkScriptPlanYamlRequest starlark_script_plan_yaml_args = 3; + api_container_api.StarlarkPackagePlanYamlArgs starlark_script_plan_yaml_args = 3; } \ No newline at end of file diff --git a/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_connect.ts b/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_connect.ts index 9f53d33c27..07632f23da 100644 --- a/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_connect.ts +++ b/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_connect.ts @@ -1,9 +1,9 @@ -// @generated by protoc-gen-connect-es v0.13.2 with parameter "target=ts" +// @generated by protoc-gen-connect-es v1.3.0 with parameter "target=ts" // @generated from file kurtosis_enclave_manager_api.proto (package kurtosis_enclave_manager, syntax proto3) /* eslint-disable */ // @ts-nocheck -import { DownloadFilesArtifactRequest, GetListFilesArtifactNamesAndUuidsRequest, GetServicesRequest, GetStarlarkRunRequest, HealthCheckRequest, HealthCheckResponse, InspectFilesArtifactContentsRequest, RunStarlarkPackageRequest, RunStarlarkScriptRequest } from "./kurtosis_enclave_manager_api_pb.js"; +import { DownloadFilesArtifactRequest, GetListFilesArtifactNamesAndUuidsRequest, GetServicesRequest, GetStarlarkRunRequest, HealthCheckRequest, HealthCheckResponse, InspectFilesArtifactContentsRequest, PlanYaml, RunStarlarkPackageRequest, RunStarlarkScriptRequest, StarlarkPackagePlanYamlArgs, StarlarkScriptPlanYamlArgs } from "./kurtosis_enclave_manager_api_pb.js"; import { Empty, MethodKind } from "@bufbuild/protobuf"; import { CreateEnclaveArgs, CreateEnclaveResponse, DestroyEnclaveArgs, GetEnclavesResponse, GetServiceLogsArgs, GetServiceLogsResponse } from "./engine_service_pb.js"; import { GetServicesResponse, GetStarlarkRunResponse, InspectFilesArtifactContentsResponse, ListFilesArtifactNamesAndUuidsResponse, StarlarkRunResponseLine, StreamedDataChunk } from "./api_container_service_pb.js"; @@ -122,6 +122,24 @@ export const KurtosisEnclaveManagerServer = { O: GetStarlarkRunResponse, kind: MethodKind.Unary, }, + /** + * @generated from rpc kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkScriptPlanYaml + */ + getStarlarkScriptPlanYaml: { + name: "GetStarlarkScriptPlanYaml", + I: StarlarkScriptPlanYamlArgs, + O: PlanYaml, + kind: MethodKind.Unary, + }, + /** + * @generated from rpc kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkPackagePlanYaml + */ + getStarlarkPackagePlanYaml: { + name: "GetStarlarkPackagePlanYaml", + I: StarlarkPackagePlanYamlArgs, + O: PlanYaml, + kind: MethodKind.Unary, + }, } } as const; diff --git a/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_pb.ts b/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_pb.ts index 48ade988d6..6a0269277b 100644 --- a/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_pb.ts +++ b/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_pb.ts @@ -1,11 +1,11 @@ -// @generated by protoc-gen-es v1.5.1 with parameter "target=ts" +// @generated by protoc-gen-es v1.3.1 with parameter "target=ts" // @generated from file kurtosis_enclave_manager_api.proto (package kurtosis_enclave_manager, syntax proto3) /* eslint-disable */ // @ts-nocheck import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; -import { DownloadFilesArtifactArgs, FilesArtifactNameAndUuid, RunStarlarkPackageArgs, RunStarlarkScriptArgs } from "./api_container_service_pb.js"; +import { DownloadFilesArtifactArgs, FilesArtifactNameAndUuid, RunStarlarkPackageArgs, RunStarlarkScriptArgs, StarlarkPackagePlanYamlArgs as StarlarkPackagePlanYamlArgs$1, StarlarkScriptPlanYamlArgs as StarlarkScriptPlanYamlArgs$1 } from "./api_container_service_pb.js"; /** * @generated from message kurtosis_enclave_manager.HealthCheckRequest @@ -440,3 +440,138 @@ export class GetStarlarkRunRequest extends Message { } } +/** + * @generated from message kurtosis_enclave_manager.PlanYaml + */ +export class PlanYaml extends Message { + /** + * @generated from field: string plan_yaml = 1; + */ + planYaml = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "kurtosis_enclave_manager.PlanYaml"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "plan_yaml", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): PlanYaml { + return new PlanYaml().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): PlanYaml { + return new PlanYaml().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): PlanYaml { + return new PlanYaml().fromJsonString(jsonString, options); + } + + static equals(a: PlanYaml | PlainMessage | undefined, b: PlanYaml | PlainMessage | undefined): boolean { + return proto3.util.equals(PlanYaml, a, b); + } +} + +/** + * @generated from message kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs + */ +export class StarlarkScriptPlanYamlArgs extends Message { + /** + * @generated from field: string apic_ip_address = 1; + */ + apicIpAddress = ""; + + /** + * @generated from field: int32 apic_port = 2; + */ + apicPort = 0; + + /** + * @generated from field: api_container_api.StarlarkScriptPlanYamlArgs starlark_package_plan_yaml_args = 3; + */ + starlarkPackagePlanYamlArgs?: StarlarkScriptPlanYamlArgs$1; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "apic_ip_address", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "apic_port", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 3, name: "starlark_package_plan_yaml_args", kind: "message", T: StarlarkScriptPlanYamlArgs$1 }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): StarlarkScriptPlanYamlArgs { + return new StarlarkScriptPlanYamlArgs().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): StarlarkScriptPlanYamlArgs { + return new StarlarkScriptPlanYamlArgs().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): StarlarkScriptPlanYamlArgs { + return new StarlarkScriptPlanYamlArgs().fromJsonString(jsonString, options); + } + + static equals(a: StarlarkScriptPlanYamlArgs | PlainMessage | undefined, b: StarlarkScriptPlanYamlArgs | PlainMessage | undefined): boolean { + return proto3.util.equals(StarlarkScriptPlanYamlArgs, a, b); + } +} + +/** + * @generated from message kurtosis_enclave_manager.StarlarkPackagePlanYamlArgs + */ +export class StarlarkPackagePlanYamlArgs extends Message { + /** + * @generated from field: string apic_ip_address = 1; + */ + apicIpAddress = ""; + + /** + * @generated from field: int32 apic_port = 2; + */ + apicPort = 0; + + /** + * @generated from field: api_container_api.StarlarkPackagePlanYamlArgs starlark_script_plan_yaml_args = 3; + */ + starlarkScriptPlanYamlArgs?: StarlarkPackagePlanYamlArgs$1; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "kurtosis_enclave_manager.StarlarkPackagePlanYamlArgs"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "apic_ip_address", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "apic_port", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 3, name: "starlark_script_plan_yaml_args", kind: "message", T: StarlarkPackagePlanYamlArgs$1 }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): StarlarkPackagePlanYamlArgs { + return new StarlarkPackagePlanYamlArgs().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): StarlarkPackagePlanYamlArgs { + return new StarlarkPackagePlanYamlArgs().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): StarlarkPackagePlanYamlArgs { + return new StarlarkPackagePlanYamlArgs().fromJsonString(jsonString, options); + } + + static equals(a: StarlarkPackagePlanYamlArgs | PlainMessage | undefined, b: StarlarkPackagePlanYamlArgs | PlainMessage | undefined): boolean { + return proto3.util.equals(StarlarkPackagePlanYamlArgs, a, b); + } +} + From 27acec64aae4b03b85e73825da779a6121f1311a Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 22 Feb 2024 11:59:26 -0500 Subject: [PATCH 22/75] implement plan yaml retrieval --- core/server/api_container/main.go | 4 +- .../server/api_container_service.go | 102 ++++++++++++++++-- 2 files changed, 97 insertions(+), 9 deletions(-) diff --git a/core/server/api_container/main.go b/core/server/api_container/main.go index 578470031e..ce018b17e6 100644 --- a/core/server/api_container/main.go +++ b/core/server/api_container/main.go @@ -210,8 +210,9 @@ func runMain() error { } // TODO: Consolidate Interpreter, Validator and Executor into a single interface + startosisInterpreter := startosis_engine.NewStartosisInterpreter(serviceNetwork, gitPackageContentProvider, runtimeValueStore, starlarkValueSerde, serverArgs.EnclaveEnvVars) startosisRunner := startosis_engine.NewStartosisRunner( - startosis_engine.NewStartosisInterpreter(serviceNetwork, gitPackageContentProvider, runtimeValueStore, starlarkValueSerde, serverArgs.EnclaveEnvVars), + startosisInterpreter, startosis_engine.NewStartosisValidator(&kurtosisBackend, serviceNetwork, filesArtifactStore), startosis_engine.NewStartosisExecutor(starlarkValueSerde, runtimeValueStore, enclavePlan, enclaveDb)) @@ -224,6 +225,7 @@ func runMain() error { filesArtifactStore, serviceNetwork, startosisRunner, + startosisInterpreter, gitPackageContentProvider, restartPolicy, metricsClient, diff --git a/core/server/api_container/server/api_container_service.go b/core/server/api_container/server/api_container_service.go index e409a9349b..4d61e9ffeb 100644 --- a/core/server/api_container/server/api_container_service.go +++ b/core/server/api_container/server/api_container_service.go @@ -13,6 +13,9 @@ import ( "context" "fmt" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/docker_compose_transpiler" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_structure" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan/resolver" "io" "math" "net/http" @@ -34,7 +37,6 @@ import ( "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/port_spec" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" @@ -96,6 +98,8 @@ type ApiContainerService struct { startosisRunner *startosis_engine.StartosisRunner + startosisInterpreter *startosis_engine.StartosisInterpreter + packageContentProvider startosis_packages.PackageContentProvider restartPolicy kurtosis_core_rpc_api_bindings.RestartPolicy @@ -109,6 +113,7 @@ func NewApiContainerService( filesArtifactStore *enclave_data_directory.FilesArtifactStore, serviceNetwork service_network.ServiceNetwork, startosisRunner *startosis_engine.StartosisRunner, + startosisInterpreter *startosis_engine.StartosisInterpreter, startosisModuleContentProvider startosis_packages.PackageContentProvider, restartPolicy kurtosis_core_rpc_api_bindings.RestartPolicy, metricsClient metrics_client.MetricsClient, @@ -117,6 +122,7 @@ func NewApiContainerService( filesArtifactStore: filesArtifactStore, serviceNetwork: serviceNetwork, startosisRunner: startosisRunner, + startosisInterpreter: startosisInterpreter, packageContentProvider: startosisModuleContentProvider, restartPolicy: restartPolicy, starlarkRun: &kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse{ @@ -249,6 +255,12 @@ func (apicService *ApiContainerService) InspectFilesArtifactContents(_ context.C } func (apicService *ApiContainerService) RunStarlarkPackage(args *kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs, stream kurtosis_core_rpc_api_bindings.ApiContainerService_RunStarlarkPackageServer) error { + + var scriptWithRunFunction string + var interpretationError *startosis_errors.InterpretationError + var isRemote bool + var detectedPackageId string + var detectedPackageReplaceOptions map[string]string packageIdFromArgs := args.GetPackageId() parallelism := int(args.GetParallelism()) if parallelism == 0 { @@ -261,12 +273,6 @@ func (apicService *ApiContainerService) RunStarlarkPackage(args *kurtosis_core_r ApiDownloadMode := shared_utils.GetOrDefault(args.ImageDownloadMode, defaultImageDownloadMode) downloadMode := convertFromImageDownloadModeAPI(ApiDownloadMode) nonBlockingMode := args.GetNonBlockingMode() - - var scriptWithRunFunction string - var interpretationError *startosis_errors.InterpretationError - var isRemote bool - var detectedPackageId string - var detectedPackageReplaceOptions map[string]string var actualRelativePathToMainFile string if args.ClonePackage != nil { scriptWithRunFunction, actualRelativePathToMainFile, detectedPackageId, detectedPackageReplaceOptions, interpretationError = @@ -594,9 +600,89 @@ func (apicService *ApiContainerService) GetStarlarkRun(_ context.Context, _ *emp return apicService.starlarkRun, nil } -func (apicService *ApiContainerService) GetStarlark +func (apicService *ApiContainerService) GetStarlarkPackagePlanYaml(ctx context.Context, args *kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) { + packageIdFromArgs := args.GetPackageId() + serializedParams := args.GetSerializedParams() + requestedRelativePathToMainFile := args.GetRelativePathToMainFile() + mainFuncName := args.GetMainFunctionName() + + var scriptWithRunFunction string + var interpretationError *startosis_errors.InterpretationError + var detectedPackageId string + var detectedPackageReplaceOptions map[string]string + var actualRelativePathToMainFile string + scriptWithRunFunction, actualRelativePathToMainFile, detectedPackageId, detectedPackageReplaceOptions, interpretationError = + apicService.runStarlarkPackageSetup(packageIdFromArgs, true, nil, requestedRelativePathToMainFile) + if interpretationError != nil { + return nil, interpretationError + } + + var apiInterpretationError *kurtosis_core_rpc_api_bindings.StarlarkInterpretationError + _, instructionsPlan, apiInterpretationError := apicService.startosisInterpreter.Interpret( // tedi: why interpret return an api interpretation error instead of a starlark one? + ctx, + detectedPackageId, + mainFuncName, + detectedPackageReplaceOptions, + actualRelativePathToMainFile, + scriptWithRunFunction, + serializedParams, + false, + enclave_structure.NewEnclaveComponents(), + resolver.NewInstructionsPlanMask(0)) + if apiInterpretationError != nil { + interpretationError = startosis_errors.NewInterpretationError(apiInterpretationError.GetErrorMessage()) + return nil, interpretationError + } + pyg := startosis_engine.NewPlanYamlGenerator( + instructionsPlan, + apicService.serviceNetwork, + packageIdFromArgs, + apicService.packageContentProvider, + "", + detectedPackageReplaceOptions) + planYamlBytes, err := pyg.GenerateYaml() + if err != nil { + return nil, err + } + + return &kurtosis_core_rpc_api_bindings.PlanYaml{PlanYaml: string(planYamlBytes)}, nil +} + +func (apicService *ApiContainerService) GetStarlarkScriptPlanYaml(ctx context.Context, args *kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) { + serializedStarlarkScript := args.GetSerializedScript() + serializedParams := args.GetSerializedParams() + mainFuncName := args.GetMainFunctionName() + noPackageReplaceOptions := map[string]string{} + var apiInterpretationError *kurtosis_core_rpc_api_bindings.StarlarkInterpretationError + _, instructionsPlan, apiInterpretationError := apicService.startosisInterpreter.Interpret( // tedi: why interpret return an api interpretation error instead of a starlark one? + ctx, + startosis_constants.PackageIdPlaceholderForStandaloneScript, + mainFuncName, + noPackageReplaceOptions, + startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, + serializedStarlarkScript, + serializedParams, + false, + enclave_structure.NewEnclaveComponents(), + resolver.NewInstructionsPlanMask(0)) + if apiInterpretationError != nil { + return nil, startosis_errors.NewInterpretationError(apiInterpretationError.GetErrorMessage()) + } + pyg := startosis_engine.NewPlanYamlGenerator( + instructionsPlan, + apicService.serviceNetwork, + startosis_constants.PackageIdPlaceholderForStandaloneScript, + apicService.packageContentProvider, + "", + noPackageReplaceOptions) + planYamlBytes, err := pyg.GenerateYaml() + if err != nil { + return nil, err + } + return &kurtosis_core_rpc_api_bindings.PlanYaml{PlanYaml: string(planYamlBytes)}, nil +} // ==================================================================================================== // From 247f6cc9c4e122550543d611d88ebb65e9cee7df Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 22 Feb 2024 12:11:16 -0500 Subject: [PATCH 23/75] impl plan yaml endpoint in enclave mngr --- .../kurtosis_enclave_manager_api.proto | 4 +- enclave-manager/server/server.go | 71 +++++++++++++++++++ 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto b/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto index 1fef3dcc5a..a61f052582 100644 --- a/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto +++ b/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto @@ -91,11 +91,11 @@ message StarlarkScriptPlanYamlArgs { string apic_ip_address = 1; int32 apic_port = 2; - api_container_api.StarlarkScriptPlanYamlArgs starlark_package_plan_yaml_args = 3; + api_container_api.StarlarkScriptPlanYamlArgs starlark_script_plan_yaml_args = 3; } message StarlarkPackagePlanYamlArgs { string apic_ip_address = 1; int32 apic_port = 2; - api_container_api.StarlarkPackagePlanYamlArgs starlark_script_plan_yaml_args = 3; + api_container_api.StarlarkPackagePlanYamlArgs starlark_package_plan_yaml_args = 3; } \ No newline at end of file diff --git a/enclave-manager/server/server.go b/enclave-manager/server/server.go index 5952e7a188..198ca9297d 100644 --- a/enclave-manager/server/server.go +++ b/enclave-manager/server/server.go @@ -426,6 +426,77 @@ func (c *WebServer) GetStarlarkRun( return resp, nil } +func (c *WebServer) GetStarlarkScriptPlanYaml( + ctx context.Context, + req *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs], +) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) { + auth, err := c.ValidateRequestAuthorization(ctx, c.enforceAuth, req.Header()) + if err != nil { + return nil, stacktrace.Propagate(err, "Authentication attempt failed") + } + if !auth { + return nil, stacktrace.Propagate(err, "User not authorized") + } + apiContainerServiceClient, err := c.createAPICClient(req.Msg.ApicIpAddress, req.Msg.ApicPort) + if err != nil { + return nil, stacktrace.Propagate(err, "Failed to create the APIC client") + } + + request := &connect.Request[kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs]{ + Msg: &kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs{ + SerializedScript: req.Msg.StarlarkPackagePlanYamlArgs.SerializedScript, + SerializedParams: req.Msg.StarlarkPackagePlanYamlArgs.SerializedParams, + MainFunctionName: req.Msg.StarlarkPackagePlanYamlArgs.MainFunctionName, + }, + } + result, err := (*apiContainerServiceClient).GetStarlarkScriptPlanYaml(ctx, request) + if err != nil { + return nil, err + } + resp := &connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml]{ + Msg: &kurtosis_core_rpc_api_bindings.PlanYaml{ + PlanYaml: result.Msg.PlanYaml, + }, + } + return resp, nil +} + +func (c *WebServer) GetStarlarkPackagePlanYaml( + ctx context.Context, + req *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs], +) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) { + auth, err := c.ValidateRequestAuthorization(ctx, c.enforceAuth, req.Header()) + if err != nil { + return nil, stacktrace.Propagate(err, "Authentication attempt failed") + } + if !auth { + return nil, stacktrace.Propagate(err, "User not authorized") + } + apiContainerServiceClient, err := c.createAPICClient(req.Msg.ApicIpAddress, req.Msg.ApicPort) + if err != nil { + return nil, stacktrace.Propagate(err, "Failed to create the APIC client") + } + + request := &connect.Request[kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs]{ + Msg: &kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs{ + PackageId: req.Msg.StarlarkScriptPlanYamlArgs.PackageId, + SerializedParams: req.Msg.StarlarkScriptPlanYamlArgs.SerializedParams, + RelativePathToMainFile: req.Msg.StarlarkScriptPlanYamlArgs.RelativePathToMainFile, + MainFunctionName: req.Msg.StarlarkScriptPlanYamlArgs.MainFunctionName, + }, + } + result, err := (*apiContainerServiceClient).GetStarlarkPackagePlanYaml(ctx, request) + if err != nil { + return nil, err + } + resp := &connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml]{ + Msg: &kurtosis_core_rpc_api_bindings.PlanYaml{ + PlanYaml: result.Msg.PlanYaml, + }, + } + return resp, nil +} + func (c *WebServer) createAPICClient( ip string, port int32, From 316f182bb21360d5a2d2f3455a59dce8376b8090 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 22 Feb 2024 12:31:47 -0500 Subject: [PATCH 24/75] fix protobuf --- .../kurtosis_enclave_manager_api.pb.go | 449 ++++++++---------- .../kurtosis_enclave_manager_api.connect.go | 24 +- .../kurtosis_enclave_manager_api_grpc.pb.go | 20 +- .../kurtosis_enclave_manager_api.proto | 9 +- .../kurtosis_enclave_manager_api_connect.ts | 4 +- .../src/kurtosis_enclave_manager_api_pb.ts | 53 +-- enclave-manager/server/server.go | 14 +- 7 files changed, 239 insertions(+), 334 deletions(-) diff --git a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api.pb.go b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api.pb.go index 588ceeef6d..fe054ac9d1 100644 --- a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api.pb.go +++ b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api.pb.go @@ -586,67 +586,25 @@ func (x *GetStarlarkRunRequest) GetApicPort() int32 { return 0 } -type PlanYaml struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PlanYaml string `protobuf:"bytes,1,opt,name=plan_yaml,json=planYaml,proto3" json:"plan_yaml,omitempty"` -} - -func (x *PlanYaml) Reset() { - *x = PlanYaml{} - if protoimpl.UnsafeEnabled { - mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PlanYaml) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PlanYaml) ProtoMessage() {} - -func (x *PlanYaml) ProtoReflect() protoreflect.Message { - mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PlanYaml.ProtoReflect.Descriptor instead. -func (*PlanYaml) Descriptor() ([]byte, []int) { - return file_kurtosis_enclave_manager_api_proto_rawDescGZIP(), []int{9} -} - -func (x *PlanYaml) GetPlanYaml() string { - if x != nil { - return x.PlanYaml - } - return "" -} - +// ============================================================================================== +// +// Get Starlark Plan Yaml +// +// ============================================================================================== type StarlarkScriptPlanYamlArgs struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ApicIpAddress string `protobuf:"bytes,1,opt,name=apic_ip_address,json=apicIpAddress,proto3" json:"apic_ip_address,omitempty"` - ApicPort int32 `protobuf:"varint,2,opt,name=apic_port,json=apicPort,proto3" json:"apic_port,omitempty"` - StarlarkPackagePlanYamlArgs *kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs `protobuf:"bytes,3,opt,name=starlark_package_plan_yaml_args,json=starlarkPackagePlanYamlArgs,proto3" json:"starlark_package_plan_yaml_args,omitempty"` + ApicIpAddress string `protobuf:"bytes,1,opt,name=apic_ip_address,json=apicIpAddress,proto3" json:"apic_ip_address,omitempty"` + ApicPort int32 `protobuf:"varint,2,opt,name=apic_port,json=apicPort,proto3" json:"apic_port,omitempty"` + StarlarkScriptPlanYamlArgs *kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs `protobuf:"bytes,3,opt,name=starlark_script_plan_yaml_args,json=starlarkScriptPlanYamlArgs,proto3" json:"starlark_script_plan_yaml_args,omitempty"` } func (x *StarlarkScriptPlanYamlArgs) Reset() { *x = StarlarkScriptPlanYamlArgs{} if protoimpl.UnsafeEnabled { - mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[10] + mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -659,7 +617,7 @@ func (x *StarlarkScriptPlanYamlArgs) String() string { func (*StarlarkScriptPlanYamlArgs) ProtoMessage() {} func (x *StarlarkScriptPlanYamlArgs) ProtoReflect() protoreflect.Message { - mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[10] + mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -672,7 +630,7 @@ func (x *StarlarkScriptPlanYamlArgs) ProtoReflect() protoreflect.Message { // Deprecated: Use StarlarkScriptPlanYamlArgs.ProtoReflect.Descriptor instead. func (*StarlarkScriptPlanYamlArgs) Descriptor() ([]byte, []int) { - return file_kurtosis_enclave_manager_api_proto_rawDescGZIP(), []int{10} + return file_kurtosis_enclave_manager_api_proto_rawDescGZIP(), []int{9} } func (x *StarlarkScriptPlanYamlArgs) GetApicIpAddress() string { @@ -689,9 +647,9 @@ func (x *StarlarkScriptPlanYamlArgs) GetApicPort() int32 { return 0 } -func (x *StarlarkScriptPlanYamlArgs) GetStarlarkPackagePlanYamlArgs() *kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs { +func (x *StarlarkScriptPlanYamlArgs) GetStarlarkScriptPlanYamlArgs() *kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs { if x != nil { - return x.StarlarkPackagePlanYamlArgs + return x.StarlarkScriptPlanYamlArgs } return nil } @@ -701,15 +659,15 @@ type StarlarkPackagePlanYamlArgs struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ApicIpAddress string `protobuf:"bytes,1,opt,name=apic_ip_address,json=apicIpAddress,proto3" json:"apic_ip_address,omitempty"` - ApicPort int32 `protobuf:"varint,2,opt,name=apic_port,json=apicPort,proto3" json:"apic_port,omitempty"` - StarlarkScriptPlanYamlArgs *kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs `protobuf:"bytes,3,opt,name=starlark_script_plan_yaml_args,json=starlarkScriptPlanYamlArgs,proto3" json:"starlark_script_plan_yaml_args,omitempty"` + ApicIpAddress string `protobuf:"bytes,1,opt,name=apic_ip_address,json=apicIpAddress,proto3" json:"apic_ip_address,omitempty"` + ApicPort int32 `protobuf:"varint,2,opt,name=apic_port,json=apicPort,proto3" json:"apic_port,omitempty"` + StarlarkPackagePlanYamlArgs *kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs `protobuf:"bytes,3,opt,name=starlark_package_plan_yaml_args,json=starlarkPackagePlanYamlArgs,proto3" json:"starlark_package_plan_yaml_args,omitempty"` } func (x *StarlarkPackagePlanYamlArgs) Reset() { *x = StarlarkPackagePlanYamlArgs{} if protoimpl.UnsafeEnabled { - mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[11] + mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -722,7 +680,7 @@ func (x *StarlarkPackagePlanYamlArgs) String() string { func (*StarlarkPackagePlanYamlArgs) ProtoMessage() {} func (x *StarlarkPackagePlanYamlArgs) ProtoReflect() protoreflect.Message { - mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[11] + mi := &file_kurtosis_enclave_manager_api_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -735,7 +693,7 @@ func (x *StarlarkPackagePlanYamlArgs) ProtoReflect() protoreflect.Message { // Deprecated: Use StarlarkPackagePlanYamlArgs.ProtoReflect.Descriptor instead. func (*StarlarkPackagePlanYamlArgs) Descriptor() ([]byte, []int) { - return file_kurtosis_enclave_manager_api_proto_rawDescGZIP(), []int{11} + return file_kurtosis_enclave_manager_api_proto_rawDescGZIP(), []int{10} } func (x *StarlarkPackagePlanYamlArgs) GetApicIpAddress() string { @@ -752,9 +710,9 @@ func (x *StarlarkPackagePlanYamlArgs) GetApicPort() int32 { return 0 } -func (x *StarlarkPackagePlanYamlArgs) GetStarlarkScriptPlanYamlArgs() *kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs { +func (x *StarlarkPackagePlanYamlArgs) GetStarlarkPackagePlanYamlArgs() *kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs { if x != nil { - return x.StarlarkScriptPlanYamlArgs + return x.StarlarkPackagePlanYamlArgs } return nil } @@ -854,144 +812,141 @@ var file_kurtosis_enclave_manager_api_proto_rawDesc = []byte{ 0x63, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x70, 0x69, 0x63, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x70, 0x69, 0x63, 0x50, 0x6f, 0x72, 0x74, 0x22, 0x27, - 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x6c, - 0x61, 0x6e, 0x5f, 0x79, 0x61, 0x6d, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, - 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x22, 0xd6, 0x01, 0x0a, 0x1a, 0x53, 0x74, 0x61, 0x72, - 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, - 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x69, - 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0d, 0x61, 0x70, 0x69, 0x63, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, - 0x0a, 0x09, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x08, 0x61, 0x70, 0x69, 0x63, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x73, 0x0a, 0x1f, 0x73, - 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5f, - 0x70, 0x6c, 0x61, 0x6e, 0x5f, 0x79, 0x61, 0x6d, 0x6c, 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, - 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x70, 0x69, 0x63, 0x50, 0x6f, 0x72, 0x74, 0x22, 0xd4, + 0x01, 0x0a, 0x1a, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x12, 0x26, 0x0a, + 0x0f, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x70, 0x69, 0x63, 0x49, 0x70, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x70, 0x6f, + 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x70, 0x69, 0x63, 0x50, 0x6f, + 0x72, 0x74, 0x12, 0x71, 0x0a, 0x1e, 0x73, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x5f, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x5f, 0x70, 0x6c, 0x61, 0x6e, 0x5f, 0x79, 0x61, 0x6d, 0x6c, 0x5f, + 0x61, 0x72, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x61, 0x70, 0x69, + 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, + 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x52, 0x1a, 0x73, 0x74, 0x61, 0x72, 0x6c, + 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, + 0x6c, 0x41, 0x72, 0x67, 0x73, 0x22, 0xd8, 0x01, 0x0a, 0x1b, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, + 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, + 0x6c, 0x41, 0x72, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x69, 0x70, + 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, + 0x61, 0x70, 0x69, 0x63, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, + 0x09, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x08, 0x61, 0x70, 0x69, 0x63, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x74, 0x0a, 0x1f, 0x73, 0x74, + 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5f, 0x70, + 0x6c, 0x61, 0x6e, 0x5f, 0x79, 0x61, 0x6d, 0x6c, 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, + 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, + 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x52, 0x1b, 0x73, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, - 0x22, 0xd6, 0x01, 0x0a, 0x1b, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, - 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, - 0x12, 0x26, 0x0a, 0x0f, 0x61, 0x70, 0x69, 0x63, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x70, 0x69, 0x63, 0x49, - 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x70, 0x69, 0x63, - 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x70, 0x69, - 0x63, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x72, 0x0a, 0x1e, 0x73, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, - 0x6b, 0x5f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x5f, 0x70, 0x6c, 0x61, 0x6e, 0x5f, 0x79, 0x61, - 0x6d, 0x6c, 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, - 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, - 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x52, 0x1a, 0x73, - 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, - 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x32, 0xc2, 0x0c, 0x0a, 0x1c, 0x4b, 0x75, - 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x4d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x64, 0x0a, 0x05, 0x43, 0x68, - 0x65, 0x63, 0x6b, 0x12, 0x2c, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, - 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x48, - 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x2d, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, - 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x61, - 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x48, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x73, 0x12, - 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1f, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, - 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x0b, 0x47, 0x65, - 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x2c, 0x2e, 0x6b, 0x75, 0x72, 0x74, - 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, - 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x58, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, - 0x6f, 0x67, 0x73, 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, - 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x41, - 0x72, 0x67, 0x73, 0x1a, 0x22, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, - 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0xa1, 0x01, 0x0a, 0x1e, - 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, - 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x55, 0x75, 0x69, 0x64, 0x73, 0x12, 0x42, - 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, - 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, - 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x4e, 0x61, - 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x55, 0x75, 0x69, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, - 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, + 0x32, 0xb4, 0x0c, 0x0a, 0x1c, 0x4b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x45, 0x6e, 0x63, + 0x6c, 0x61, 0x76, 0x65, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x12, 0x64, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x2c, 0x2e, 0x6b, 0x75, 0x72, + 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, + 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x45, 0x6e, + 0x63, 0x6c, 0x61, 0x76, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1f, + 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x45, + 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x65, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, + 0x12, 0x2c, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, + 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, + 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, + 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x67, + 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x22, 0x2e, 0x65, 0x6e, 0x67, + 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x30, 0x01, 0x12, 0xa1, 0x01, 0x0a, 0x1e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, - 0x55, 0x75, 0x69, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x79, 0x0a, 0x12, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, - 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x33, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, + 0x55, 0x75, 0x69, 0x64, 0x73, 0x12, 0x42, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, - 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, + 0x69, 0x66, 0x61, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x55, 0x75, 0x69, + 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x61, 0x70, 0x69, 0x5f, + 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x4e, + 0x61, 0x6d, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x55, 0x75, 0x69, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x79, 0x0a, 0x12, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, + 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x33, 0x2e, 0x6b, + 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, + 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x22, 0x00, 0x30, + 0x01, 0x12, 0x77, 0x0a, 0x11, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, + 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x32, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, + 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x52, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x77, 0x0a, 0x11, 0x52, 0x75, - 0x6e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, - 0x32, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, - 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x52, 0x75, 0x6e, 0x53, 0x74, - 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, - 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, - 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x22, - 0x00, 0x30, 0x01, 0x12, 0x53, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x63, - 0x6c, 0x61, 0x76, 0x65, 0x12, 0x1d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, - 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x41, - 0x72, 0x67, 0x73, 0x1a, 0x21, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x98, 0x01, 0x0a, 0x1c, 0x49, 0x6e, 0x73, - 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, - 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3d, 0x2e, 0x6b, 0x75, 0x72, 0x74, - 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, - 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, - 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x73, - 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, - 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x79, 0x0a, 0x15, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, - 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x36, 0x2e, 0x6b, - 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, - 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, - 0x64, 0x44, 0x61, 0x74, 0x61, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x22, 0x00, 0x30, 0x01, 0x12, 0x4a, - 0x0a, 0x0e, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, - 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x65, - 0x73, 0x74, 0x72, 0x6f, 0x79, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x41, 0x72, 0x67, 0x73, - 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x6e, 0x0a, 0x0e, 0x47, 0x65, - 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x12, 0x2f, 0x2e, 0x6b, - 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, - 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, - 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, - 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x77, 0x0a, 0x19, 0x47, 0x65, - 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, - 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x34, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, - 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x22, 0x2e, - 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, - 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, - 0x6c, 0x22, 0x00, 0x12, 0x79, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, + 0x73, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x53, 0x0a, 0x0d, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x12, 0x1d, 0x2e, 0x65, 0x6e, + 0x67, 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, + 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x21, 0x2e, 0x65, 0x6e, 0x67, + 0x69, 0x6e, 0x65, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6e, + 0x63, 0x6c, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x98, 0x01, 0x0a, 0x1c, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, + 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, + 0x12, 0x3d, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, + 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x73, 0x70, + 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, + 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x37, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, + 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, + 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x79, 0x0a, 0x15, 0x44, 0x6f, + 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, 0x66, + 0x61, 0x63, 0x74, 0x12, 0x36, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, + 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x44, + 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x74, 0x69, + 0x66, 0x61, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x61, 0x70, + 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, + 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x43, 0x68, 0x75, 0x6e, + 0x6b, 0x22, 0x00, 0x30, 0x01, 0x12, 0x4a, 0x0a, 0x0e, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, + 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, + 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, 0x45, 0x6e, 0x63, 0x6c, + 0x61, 0x76, 0x65, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, + 0x00, 0x12, 0x6e, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, + 0x52, 0x75, 0x6e, 0x12, 0x2f, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, + 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x47, + 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, + 0x6c, 0x61, 0x72, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x70, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, + 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x34, + 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, + 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, + 0x72, 0x6b, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, + 0x41, 0x72, 0x67, 0x73, 0x1a, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, + 0x6c, 0x22, 0x00, 0x12, 0x72, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x35, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x6c, 0x61, 0x72, 0x6b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, - 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x22, 0x2e, 0x6b, 0x75, 0x72, 0x74, 0x6f, - 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x22, 0x00, 0x42, 0x64, - 0x5a, 0x62, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x72, - 0x74, 0x6f, 0x73, 0x69, 0x73, 0x2d, 0x74, 0x65, 0x63, 0x68, 0x2f, 0x6b, 0x75, 0x72, 0x74, 0x6f, - 0x73, 0x69, 0x73, 0x2f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x2d, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x6b, - 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x5f, 0x62, 0x69, 0x6e, 0x64, - 0x69, 0x6e, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x59, 0x61, 0x6d, 0x6c, 0x41, 0x72, 0x67, 0x73, 0x1a, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x63, + 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x6c, 0x61, + 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x22, 0x00, 0x42, 0x64, 0x5a, 0x62, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x2d, 0x74, + 0x65, 0x63, 0x68, 0x2f, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, 0x2f, 0x65, 0x6e, 0x63, + 0x6c, 0x61, 0x76, 0x65, 0x2d, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x6b, 0x75, 0x72, 0x74, 0x6f, 0x73, 0x69, 0x73, + 0x5f, 0x65, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x5f, 0x61, 0x70, 0x69, 0x5f, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1007,7 +962,7 @@ func file_kurtosis_enclave_manager_api_proto_rawDescGZIP() []byte { } var file_kurtosis_enclave_manager_api_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_kurtosis_enclave_manager_api_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_kurtosis_enclave_manager_api_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_kurtosis_enclave_manager_api_proto_goTypes = []interface{}{ (HealthCheckResponse_ServingStatus)(0), // 0: kurtosis_enclave_manager.HealthCheckResponse.ServingStatus (*HealthCheckRequest)(nil), // 1: kurtosis_enclave_manager.HealthCheckRequest @@ -1019,65 +974,65 @@ var file_kurtosis_enclave_manager_api_proto_goTypes = []interface{}{ (*InspectFilesArtifactContentsRequest)(nil), // 7: kurtosis_enclave_manager.InspectFilesArtifactContentsRequest (*DownloadFilesArtifactRequest)(nil), // 8: kurtosis_enclave_manager.DownloadFilesArtifactRequest (*GetStarlarkRunRequest)(nil), // 9: kurtosis_enclave_manager.GetStarlarkRunRequest - (*PlanYaml)(nil), // 10: kurtosis_enclave_manager.PlanYaml - (*StarlarkScriptPlanYamlArgs)(nil), // 11: kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs - (*StarlarkPackagePlanYamlArgs)(nil), // 12: kurtosis_enclave_manager.StarlarkPackagePlanYamlArgs - (*kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs)(nil), // 13: api_container_api.RunStarlarkPackageArgs - (*kurtosis_core_rpc_api_bindings.RunStarlarkScriptArgs)(nil), // 14: api_container_api.RunStarlarkScriptArgs - (*kurtosis_core_rpc_api_bindings.FilesArtifactNameAndUuid)(nil), // 15: api_container_api.FilesArtifactNameAndUuid - (*kurtosis_core_rpc_api_bindings.DownloadFilesArtifactArgs)(nil), // 16: api_container_api.DownloadFilesArtifactArgs - (*kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs)(nil), // 17: api_container_api.StarlarkScriptPlanYamlArgs - (*kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs)(nil), // 18: api_container_api.StarlarkPackagePlanYamlArgs - (*emptypb.Empty)(nil), // 19: google.protobuf.Empty - (*kurtosis_engine_rpc_api_bindings.GetServiceLogsArgs)(nil), // 20: engine_api.GetServiceLogsArgs - (*kurtosis_engine_rpc_api_bindings.CreateEnclaveArgs)(nil), // 21: engine_api.CreateEnclaveArgs - (*kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs)(nil), // 22: engine_api.DestroyEnclaveArgs - (*kurtosis_engine_rpc_api_bindings.GetEnclavesResponse)(nil), // 23: engine_api.GetEnclavesResponse - (*kurtosis_core_rpc_api_bindings.GetServicesResponse)(nil), // 24: api_container_api.GetServicesResponse - (*kurtosis_engine_rpc_api_bindings.GetServiceLogsResponse)(nil), // 25: engine_api.GetServiceLogsResponse - (*kurtosis_core_rpc_api_bindings.ListFilesArtifactNamesAndUuidsResponse)(nil), // 26: api_container_api.ListFilesArtifactNamesAndUuidsResponse - (*kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine)(nil), // 27: api_container_api.StarlarkRunResponseLine - (*kurtosis_engine_rpc_api_bindings.CreateEnclaveResponse)(nil), // 28: engine_api.CreateEnclaveResponse - (*kurtosis_core_rpc_api_bindings.InspectFilesArtifactContentsResponse)(nil), // 29: api_container_api.InspectFilesArtifactContentsResponse - (*kurtosis_core_rpc_api_bindings.StreamedDataChunk)(nil), // 30: api_container_api.StreamedDataChunk - (*kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse)(nil), // 31: api_container_api.GetStarlarkRunResponse + (*StarlarkScriptPlanYamlArgs)(nil), // 10: kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs + (*StarlarkPackagePlanYamlArgs)(nil), // 11: kurtosis_enclave_manager.StarlarkPackagePlanYamlArgs + (*kurtosis_core_rpc_api_bindings.RunStarlarkPackageArgs)(nil), // 12: api_container_api.RunStarlarkPackageArgs + (*kurtosis_core_rpc_api_bindings.RunStarlarkScriptArgs)(nil), // 13: api_container_api.RunStarlarkScriptArgs + (*kurtosis_core_rpc_api_bindings.FilesArtifactNameAndUuid)(nil), // 14: api_container_api.FilesArtifactNameAndUuid + (*kurtosis_core_rpc_api_bindings.DownloadFilesArtifactArgs)(nil), // 15: api_container_api.DownloadFilesArtifactArgs + (*kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs)(nil), // 16: api_container_api.StarlarkScriptPlanYamlArgs + (*kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs)(nil), // 17: api_container_api.StarlarkPackagePlanYamlArgs + (*emptypb.Empty)(nil), // 18: google.protobuf.Empty + (*kurtosis_engine_rpc_api_bindings.GetServiceLogsArgs)(nil), // 19: engine_api.GetServiceLogsArgs + (*kurtosis_engine_rpc_api_bindings.CreateEnclaveArgs)(nil), // 20: engine_api.CreateEnclaveArgs + (*kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs)(nil), // 21: engine_api.DestroyEnclaveArgs + (*kurtosis_engine_rpc_api_bindings.GetEnclavesResponse)(nil), // 22: engine_api.GetEnclavesResponse + (*kurtosis_core_rpc_api_bindings.GetServicesResponse)(nil), // 23: api_container_api.GetServicesResponse + (*kurtosis_engine_rpc_api_bindings.GetServiceLogsResponse)(nil), // 24: engine_api.GetServiceLogsResponse + (*kurtosis_core_rpc_api_bindings.ListFilesArtifactNamesAndUuidsResponse)(nil), // 25: api_container_api.ListFilesArtifactNamesAndUuidsResponse + (*kurtosis_core_rpc_api_bindings.StarlarkRunResponseLine)(nil), // 26: api_container_api.StarlarkRunResponseLine + (*kurtosis_engine_rpc_api_bindings.CreateEnclaveResponse)(nil), // 27: engine_api.CreateEnclaveResponse + (*kurtosis_core_rpc_api_bindings.InspectFilesArtifactContentsResponse)(nil), // 28: api_container_api.InspectFilesArtifactContentsResponse + (*kurtosis_core_rpc_api_bindings.StreamedDataChunk)(nil), // 29: api_container_api.StreamedDataChunk + (*kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse)(nil), // 30: api_container_api.GetStarlarkRunResponse + (*kurtosis_core_rpc_api_bindings.PlanYaml)(nil), // 31: api_container_api.PlanYaml } var file_kurtosis_enclave_manager_api_proto_depIdxs = []int32{ 0, // 0: kurtosis_enclave_manager.HealthCheckResponse.status:type_name -> kurtosis_enclave_manager.HealthCheckResponse.ServingStatus - 13, // 1: kurtosis_enclave_manager.RunStarlarkPackageRequest.RunStarlarkPackageArgs:type_name -> api_container_api.RunStarlarkPackageArgs - 14, // 2: kurtosis_enclave_manager.RunStarlarkScriptRequest.RunStarlarkScriptArgs:type_name -> api_container_api.RunStarlarkScriptArgs - 15, // 3: kurtosis_enclave_manager.InspectFilesArtifactContentsRequest.file_names_and_uuid:type_name -> api_container_api.FilesArtifactNameAndUuid - 16, // 4: kurtosis_enclave_manager.DownloadFilesArtifactRequest.download_files_artifacts_args:type_name -> api_container_api.DownloadFilesArtifactArgs - 17, // 5: kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs.starlark_package_plan_yaml_args:type_name -> api_container_api.StarlarkScriptPlanYamlArgs - 18, // 6: kurtosis_enclave_manager.StarlarkPackagePlanYamlArgs.starlark_script_plan_yaml_args:type_name -> api_container_api.StarlarkPackagePlanYamlArgs + 12, // 1: kurtosis_enclave_manager.RunStarlarkPackageRequest.RunStarlarkPackageArgs:type_name -> api_container_api.RunStarlarkPackageArgs + 13, // 2: kurtosis_enclave_manager.RunStarlarkScriptRequest.RunStarlarkScriptArgs:type_name -> api_container_api.RunStarlarkScriptArgs + 14, // 3: kurtosis_enclave_manager.InspectFilesArtifactContentsRequest.file_names_and_uuid:type_name -> api_container_api.FilesArtifactNameAndUuid + 15, // 4: kurtosis_enclave_manager.DownloadFilesArtifactRequest.download_files_artifacts_args:type_name -> api_container_api.DownloadFilesArtifactArgs + 16, // 5: kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs.starlark_script_plan_yaml_args:type_name -> api_container_api.StarlarkScriptPlanYamlArgs + 17, // 6: kurtosis_enclave_manager.StarlarkPackagePlanYamlArgs.starlark_package_plan_yaml_args:type_name -> api_container_api.StarlarkPackagePlanYamlArgs 1, // 7: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.Check:input_type -> kurtosis_enclave_manager.HealthCheckRequest - 19, // 8: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetEnclaves:input_type -> google.protobuf.Empty + 18, // 8: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetEnclaves:input_type -> google.protobuf.Empty 3, // 9: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServices:input_type -> kurtosis_enclave_manager.GetServicesRequest - 20, // 10: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServiceLogs:input_type -> engine_api.GetServiceLogsArgs + 19, // 10: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServiceLogs:input_type -> engine_api.GetServiceLogsArgs 4, // 11: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.ListFilesArtifactNamesAndUuids:input_type -> kurtosis_enclave_manager.GetListFilesArtifactNamesAndUuidsRequest 5, // 12: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkPackage:input_type -> kurtosis_enclave_manager.RunStarlarkPackageRequest 6, // 13: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkScript:input_type -> kurtosis_enclave_manager.RunStarlarkScriptRequest - 21, // 14: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.CreateEnclave:input_type -> engine_api.CreateEnclaveArgs + 20, // 14: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.CreateEnclave:input_type -> engine_api.CreateEnclaveArgs 7, // 15: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.InspectFilesArtifactContents:input_type -> kurtosis_enclave_manager.InspectFilesArtifactContentsRequest 8, // 16: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DownloadFilesArtifact:input_type -> kurtosis_enclave_manager.DownloadFilesArtifactRequest - 22, // 17: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DestroyEnclave:input_type -> engine_api.DestroyEnclaveArgs + 21, // 17: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DestroyEnclave:input_type -> engine_api.DestroyEnclaveArgs 9, // 18: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkRun:input_type -> kurtosis_enclave_manager.GetStarlarkRunRequest - 11, // 19: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkScriptPlanYaml:input_type -> kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs - 12, // 20: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkPackagePlanYaml:input_type -> kurtosis_enclave_manager.StarlarkPackagePlanYamlArgs + 10, // 19: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkScriptPlanYaml:input_type -> kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs + 11, // 20: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkPackagePlanYaml:input_type -> kurtosis_enclave_manager.StarlarkPackagePlanYamlArgs 2, // 21: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.Check:output_type -> kurtosis_enclave_manager.HealthCheckResponse - 23, // 22: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetEnclaves:output_type -> engine_api.GetEnclavesResponse - 24, // 23: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServices:output_type -> api_container_api.GetServicesResponse - 25, // 24: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServiceLogs:output_type -> engine_api.GetServiceLogsResponse - 26, // 25: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.ListFilesArtifactNamesAndUuids:output_type -> api_container_api.ListFilesArtifactNamesAndUuidsResponse - 27, // 26: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkPackage:output_type -> api_container_api.StarlarkRunResponseLine - 27, // 27: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkScript:output_type -> api_container_api.StarlarkRunResponseLine - 28, // 28: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.CreateEnclave:output_type -> engine_api.CreateEnclaveResponse - 29, // 29: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.InspectFilesArtifactContents:output_type -> api_container_api.InspectFilesArtifactContentsResponse - 30, // 30: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DownloadFilesArtifact:output_type -> api_container_api.StreamedDataChunk - 19, // 31: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DestroyEnclave:output_type -> google.protobuf.Empty - 31, // 32: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkRun:output_type -> api_container_api.GetStarlarkRunResponse - 10, // 33: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkScriptPlanYaml:output_type -> kurtosis_enclave_manager.PlanYaml - 10, // 34: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkPackagePlanYaml:output_type -> kurtosis_enclave_manager.PlanYaml + 22, // 22: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetEnclaves:output_type -> engine_api.GetEnclavesResponse + 23, // 23: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServices:output_type -> api_container_api.GetServicesResponse + 24, // 24: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetServiceLogs:output_type -> engine_api.GetServiceLogsResponse + 25, // 25: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.ListFilesArtifactNamesAndUuids:output_type -> api_container_api.ListFilesArtifactNamesAndUuidsResponse + 26, // 26: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkPackage:output_type -> api_container_api.StarlarkRunResponseLine + 26, // 27: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.RunStarlarkScript:output_type -> api_container_api.StarlarkRunResponseLine + 27, // 28: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.CreateEnclave:output_type -> engine_api.CreateEnclaveResponse + 28, // 29: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.InspectFilesArtifactContents:output_type -> api_container_api.InspectFilesArtifactContentsResponse + 29, // 30: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DownloadFilesArtifact:output_type -> api_container_api.StreamedDataChunk + 18, // 31: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.DestroyEnclave:output_type -> google.protobuf.Empty + 30, // 32: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkRun:output_type -> api_container_api.GetStarlarkRunResponse + 31, // 33: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkScriptPlanYaml:output_type -> api_container_api.PlanYaml + 31, // 34: kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkPackagePlanYaml:output_type -> api_container_api.PlanYaml 21, // [21:35] is the sub-list for method output_type 7, // [7:21] is the sub-list for method input_type 7, // [7:7] is the sub-list for extension type_name @@ -1200,18 +1155,6 @@ func file_kurtosis_enclave_manager_api_proto_init() { } } file_kurtosis_enclave_manager_api_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PlanYaml); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_kurtosis_enclave_manager_api_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StarlarkScriptPlanYamlArgs); i { case 0: return &v.state @@ -1223,7 +1166,7 @@ func file_kurtosis_enclave_manager_api_proto_init() { return nil } } - file_kurtosis_enclave_manager_api_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_kurtosis_enclave_manager_api_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StarlarkPackagePlanYamlArgs); i { case 0: return &v.state @@ -1242,7 +1185,7 @@ func file_kurtosis_enclave_manager_api_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_kurtosis_enclave_manager_api_proto_rawDesc, NumEnums: 1, - NumMessages: 12, + NumMessages: 11, NumExtensions: 0, NumServices: 1, }, diff --git a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_bindingsconnect/kurtosis_enclave_manager_api.connect.go b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_bindingsconnect/kurtosis_enclave_manager_api.connect.go index 95009ac32c..d5ae26ed0f 100644 --- a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_bindingsconnect/kurtosis_enclave_manager_api.connect.go +++ b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_bindingsconnect/kurtosis_enclave_manager_api.connect.go @@ -96,8 +96,8 @@ type KurtosisEnclaveManagerServerClient interface { DownloadFilesArtifact(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.DownloadFilesArtifactRequest]) (*connect.ServerStreamForClient[kurtosis_core_rpc_api_bindings.StreamedDataChunk], error) DestroyEnclave(context.Context, *connect.Request[kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs]) (*connect.Response[emptypb.Empty], error) GetStarlarkRun(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.GetStarlarkRunRequest]) (*connect.Response[kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse], error) - GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) - GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) + GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) + GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) } // NewKurtosisEnclaveManagerServerClient constructs a client for the @@ -171,12 +171,12 @@ func NewKurtosisEnclaveManagerServerClient(httpClient connect.HTTPClient, baseUR baseURL+KurtosisEnclaveManagerServerGetStarlarkRunProcedure, opts..., ), - getStarlarkScriptPlanYaml: connect.NewClient[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs, kurtosis_enclave_manager_api_bindings.PlanYaml]( + getStarlarkScriptPlanYaml: connect.NewClient[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs, kurtosis_core_rpc_api_bindings.PlanYaml]( httpClient, baseURL+KurtosisEnclaveManagerServerGetStarlarkScriptPlanYamlProcedure, opts..., ), - getStarlarkPackagePlanYaml: connect.NewClient[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs, kurtosis_enclave_manager_api_bindings.PlanYaml]( + getStarlarkPackagePlanYaml: connect.NewClient[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs, kurtosis_core_rpc_api_bindings.PlanYaml]( httpClient, baseURL+KurtosisEnclaveManagerServerGetStarlarkPackagePlanYamlProcedure, opts..., @@ -198,8 +198,8 @@ type kurtosisEnclaveManagerServerClient struct { downloadFilesArtifact *connect.Client[kurtosis_enclave_manager_api_bindings.DownloadFilesArtifactRequest, kurtosis_core_rpc_api_bindings.StreamedDataChunk] destroyEnclave *connect.Client[kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs, emptypb.Empty] getStarlarkRun *connect.Client[kurtosis_enclave_manager_api_bindings.GetStarlarkRunRequest, kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse] - getStarlarkScriptPlanYaml *connect.Client[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs, kurtosis_enclave_manager_api_bindings.PlanYaml] - getStarlarkPackagePlanYaml *connect.Client[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs, kurtosis_enclave_manager_api_bindings.PlanYaml] + getStarlarkScriptPlanYaml *connect.Client[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs, kurtosis_core_rpc_api_bindings.PlanYaml] + getStarlarkPackagePlanYaml *connect.Client[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs, kurtosis_core_rpc_api_bindings.PlanYaml] } // Check calls kurtosis_enclave_manager.KurtosisEnclaveManagerServer.Check. @@ -268,13 +268,13 @@ func (c *kurtosisEnclaveManagerServerClient) GetStarlarkRun(ctx context.Context, // GetStarlarkScriptPlanYaml calls // kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkScriptPlanYaml. -func (c *kurtosisEnclaveManagerServerClient) GetStarlarkScriptPlanYaml(ctx context.Context, req *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) { +func (c *kurtosisEnclaveManagerServerClient) GetStarlarkScriptPlanYaml(ctx context.Context, req *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) { return c.getStarlarkScriptPlanYaml.CallUnary(ctx, req) } // GetStarlarkPackagePlanYaml calls // kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkPackagePlanYaml. -func (c *kurtosisEnclaveManagerServerClient) GetStarlarkPackagePlanYaml(ctx context.Context, req *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) { +func (c *kurtosisEnclaveManagerServerClient) GetStarlarkPackagePlanYaml(ctx context.Context, req *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) { return c.getStarlarkPackagePlanYaml.CallUnary(ctx, req) } @@ -293,8 +293,8 @@ type KurtosisEnclaveManagerServerHandler interface { DownloadFilesArtifact(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.DownloadFilesArtifactRequest], *connect.ServerStream[kurtosis_core_rpc_api_bindings.StreamedDataChunk]) error DestroyEnclave(context.Context, *connect.Request[kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs]) (*connect.Response[emptypb.Empty], error) GetStarlarkRun(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.GetStarlarkRunRequest]) (*connect.Response[kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse], error) - GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) - GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) + GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) + GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) } // NewKurtosisEnclaveManagerServerHandler builds an HTTP handler from the service implementation. It @@ -460,10 +460,10 @@ func (UnimplementedKurtosisEnclaveManagerServerHandler) GetStarlarkRun(context.C return nil, connect.NewError(connect.CodeUnimplemented, errors.New("kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkRun is not implemented")) } -func (UnimplementedKurtosisEnclaveManagerServerHandler) GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) { +func (UnimplementedKurtosisEnclaveManagerServerHandler) GetStarlarkScriptPlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkScriptPlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkScriptPlanYaml is not implemented")) } -func (UnimplementedKurtosisEnclaveManagerServerHandler) GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_enclave_manager_api_bindings.PlanYaml], error) { +func (UnimplementedKurtosisEnclaveManagerServerHandler) GetStarlarkPackagePlanYaml(context.Context, *connect.Request[kurtosis_enclave_manager_api_bindings.StarlarkPackagePlanYamlArgs]) (*connect.Response[kurtosis_core_rpc_api_bindings.PlanYaml], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkPackagePlanYaml is not implemented")) } diff --git a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_grpc.pb.go b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_grpc.pb.go index cca6659d42..229a14a55d 100644 --- a/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_grpc.pb.go +++ b/enclave-manager/api/golang/kurtosis_enclave_manager_api_bindings/kurtosis_enclave_manager_api_grpc.pb.go @@ -54,8 +54,8 @@ type KurtosisEnclaveManagerServerClient interface { DownloadFilesArtifact(ctx context.Context, in *DownloadFilesArtifactRequest, opts ...grpc.CallOption) (KurtosisEnclaveManagerServer_DownloadFilesArtifactClient, error) DestroyEnclave(ctx context.Context, in *kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs, opts ...grpc.CallOption) (*emptypb.Empty, error) GetStarlarkRun(ctx context.Context, in *GetStarlarkRunRequest, opts ...grpc.CallOption) (*kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse, error) - GetStarlarkScriptPlanYaml(ctx context.Context, in *StarlarkScriptPlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) - GetStarlarkPackagePlanYaml(ctx context.Context, in *StarlarkPackagePlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) + GetStarlarkScriptPlanYaml(ctx context.Context, in *StarlarkScriptPlanYamlArgs, opts ...grpc.CallOption) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) + GetStarlarkPackagePlanYaml(ctx context.Context, in *StarlarkPackagePlanYamlArgs, opts ...grpc.CallOption) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) } type kurtosisEnclaveManagerServerClient struct { @@ -266,8 +266,8 @@ func (c *kurtosisEnclaveManagerServerClient) GetStarlarkRun(ctx context.Context, return out, nil } -func (c *kurtosisEnclaveManagerServerClient) GetStarlarkScriptPlanYaml(ctx context.Context, in *StarlarkScriptPlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) { - out := new(PlanYaml) +func (c *kurtosisEnclaveManagerServerClient) GetStarlarkScriptPlanYaml(ctx context.Context, in *StarlarkScriptPlanYamlArgs, opts ...grpc.CallOption) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) { + out := new(kurtosis_core_rpc_api_bindings.PlanYaml) err := c.cc.Invoke(ctx, KurtosisEnclaveManagerServer_GetStarlarkScriptPlanYaml_FullMethodName, in, out, opts...) if err != nil { return nil, err @@ -275,8 +275,8 @@ func (c *kurtosisEnclaveManagerServerClient) GetStarlarkScriptPlanYaml(ctx conte return out, nil } -func (c *kurtosisEnclaveManagerServerClient) GetStarlarkPackagePlanYaml(ctx context.Context, in *StarlarkPackagePlanYamlArgs, opts ...grpc.CallOption) (*PlanYaml, error) { - out := new(PlanYaml) +func (c *kurtosisEnclaveManagerServerClient) GetStarlarkPackagePlanYaml(ctx context.Context, in *StarlarkPackagePlanYamlArgs, opts ...grpc.CallOption) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) { + out := new(kurtosis_core_rpc_api_bindings.PlanYaml) err := c.cc.Invoke(ctx, KurtosisEnclaveManagerServer_GetStarlarkPackagePlanYaml_FullMethodName, in, out, opts...) if err != nil { return nil, err @@ -300,8 +300,8 @@ type KurtosisEnclaveManagerServerServer interface { DownloadFilesArtifact(*DownloadFilesArtifactRequest, KurtosisEnclaveManagerServer_DownloadFilesArtifactServer) error DestroyEnclave(context.Context, *kurtosis_engine_rpc_api_bindings.DestroyEnclaveArgs) (*emptypb.Empty, error) GetStarlarkRun(context.Context, *GetStarlarkRunRequest) (*kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse, error) - GetStarlarkScriptPlanYaml(context.Context, *StarlarkScriptPlanYamlArgs) (*PlanYaml, error) - GetStarlarkPackagePlanYaml(context.Context, *StarlarkPackagePlanYamlArgs) (*PlanYaml, error) + GetStarlarkScriptPlanYaml(context.Context, *StarlarkScriptPlanYamlArgs) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) + GetStarlarkPackagePlanYaml(context.Context, *StarlarkPackagePlanYamlArgs) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) } // UnimplementedKurtosisEnclaveManagerServerServer should be embedded to have forward compatible implementations. @@ -344,10 +344,10 @@ func (UnimplementedKurtosisEnclaveManagerServerServer) DestroyEnclave(context.Co func (UnimplementedKurtosisEnclaveManagerServerServer) GetStarlarkRun(context.Context, *GetStarlarkRunRequest) (*kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStarlarkRun not implemented") } -func (UnimplementedKurtosisEnclaveManagerServerServer) GetStarlarkScriptPlanYaml(context.Context, *StarlarkScriptPlanYamlArgs) (*PlanYaml, error) { +func (UnimplementedKurtosisEnclaveManagerServerServer) GetStarlarkScriptPlanYaml(context.Context, *StarlarkScriptPlanYamlArgs) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStarlarkScriptPlanYaml not implemented") } -func (UnimplementedKurtosisEnclaveManagerServerServer) GetStarlarkPackagePlanYaml(context.Context, *StarlarkPackagePlanYamlArgs) (*PlanYaml, error) { +func (UnimplementedKurtosisEnclaveManagerServerServer) GetStarlarkPackagePlanYaml(context.Context, *StarlarkPackagePlanYamlArgs) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStarlarkPackagePlanYaml not implemented") } diff --git a/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto b/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto index a61f052582..97fe2a0a15 100644 --- a/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto +++ b/enclave-manager/api/protobuf/kurtosis_enclave_manager_api.proto @@ -21,8 +21,8 @@ service KurtosisEnclaveManagerServer { rpc DownloadFilesArtifact(DownloadFilesArtifactRequest) returns (stream api_container_api.StreamedDataChunk) {}; rpc DestroyEnclave(engine_api.DestroyEnclaveArgs) returns (google.protobuf.Empty) {}; rpc GetStarlarkRun(GetStarlarkRunRequest) returns (api_container_api.GetStarlarkRunResponse) {}; - rpc GetStarlarkScriptPlanYaml(StarlarkScriptPlanYamlArgs) returns (PlanYaml) {}; - rpc GetStarlarkPackagePlanYaml(StarlarkPackagePlanYamlArgs) returns (PlanYaml) {}; + rpc GetStarlarkScriptPlanYaml(StarlarkScriptPlanYamlArgs) returns (api_container_api.PlanYaml) {}; + rpc GetStarlarkPackagePlanYaml(StarlarkPackagePlanYamlArgs) returns (api_container_api.PlanYaml) {}; } message HealthCheckRequest { @@ -82,11 +82,6 @@ message GetStarlarkRunRequest{ // ============================================================================================== // Get Starlark Plan Yaml // ============================================================================================== - -message PlanYaml { - string plan_yaml = 1; -} - message StarlarkScriptPlanYamlArgs { string apic_ip_address = 1; int32 apic_port = 2; diff --git a/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_connect.ts b/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_connect.ts index 07632f23da..8db61a99a1 100644 --- a/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_connect.ts +++ b/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_connect.ts @@ -3,10 +3,10 @@ /* eslint-disable */ // @ts-nocheck -import { DownloadFilesArtifactRequest, GetListFilesArtifactNamesAndUuidsRequest, GetServicesRequest, GetStarlarkRunRequest, HealthCheckRequest, HealthCheckResponse, InspectFilesArtifactContentsRequest, PlanYaml, RunStarlarkPackageRequest, RunStarlarkScriptRequest, StarlarkPackagePlanYamlArgs, StarlarkScriptPlanYamlArgs } from "./kurtosis_enclave_manager_api_pb.js"; +import { DownloadFilesArtifactRequest, GetListFilesArtifactNamesAndUuidsRequest, GetServicesRequest, GetStarlarkRunRequest, HealthCheckRequest, HealthCheckResponse, InspectFilesArtifactContentsRequest, RunStarlarkPackageRequest, RunStarlarkScriptRequest, StarlarkPackagePlanYamlArgs, StarlarkScriptPlanYamlArgs } from "./kurtosis_enclave_manager_api_pb.js"; import { Empty, MethodKind } from "@bufbuild/protobuf"; import { CreateEnclaveArgs, CreateEnclaveResponse, DestroyEnclaveArgs, GetEnclavesResponse, GetServiceLogsArgs, GetServiceLogsResponse } from "./engine_service_pb.js"; -import { GetServicesResponse, GetStarlarkRunResponse, InspectFilesArtifactContentsResponse, ListFilesArtifactNamesAndUuidsResponse, StarlarkRunResponseLine, StreamedDataChunk } from "./api_container_service_pb.js"; +import { GetServicesResponse, GetStarlarkRunResponse, InspectFilesArtifactContentsResponse, ListFilesArtifactNamesAndUuidsResponse, PlanYaml, StarlarkRunResponseLine, StreamedDataChunk } from "./api_container_service_pb.js"; /** * @generated from service kurtosis_enclave_manager.KurtosisEnclaveManagerServer diff --git a/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_pb.ts b/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_pb.ts index 6a0269277b..af2407b0d3 100644 --- a/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_pb.ts +++ b/enclave-manager/api/typescript/src/kurtosis_enclave_manager_api_pb.ts @@ -441,43 +441,10 @@ export class GetStarlarkRunRequest extends Message { } /** - * @generated from message kurtosis_enclave_manager.PlanYaml - */ -export class PlanYaml extends Message { - /** - * @generated from field: string plan_yaml = 1; - */ - planYaml = ""; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "kurtosis_enclave_manager.PlanYaml"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "plan_yaml", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): PlanYaml { - return new PlanYaml().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): PlanYaml { - return new PlanYaml().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): PlanYaml { - return new PlanYaml().fromJsonString(jsonString, options); - } - - static equals(a: PlanYaml | PlainMessage | undefined, b: PlanYaml | PlainMessage | undefined): boolean { - return proto3.util.equals(PlanYaml, a, b); - } -} - -/** + * ============================================================================================== + * Get Starlark Plan Yaml + * ============================================================================================== + * * @generated from message kurtosis_enclave_manager.StarlarkScriptPlanYamlArgs */ export class StarlarkScriptPlanYamlArgs extends Message { @@ -492,9 +459,9 @@ export class StarlarkScriptPlanYamlArgs extends Message) { super(); @@ -506,7 +473,7 @@ export class StarlarkScriptPlanYamlArgs extends Message [ { no: 1, name: "apic_ip_address", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 2, name: "apic_port", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, - { no: 3, name: "starlark_package_plan_yaml_args", kind: "message", T: StarlarkScriptPlanYamlArgs$1 }, + { no: 3, name: "starlark_script_plan_yaml_args", kind: "message", T: StarlarkScriptPlanYamlArgs$1 }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): StarlarkScriptPlanYamlArgs { @@ -541,9 +508,9 @@ export class StarlarkPackagePlanYamlArgs extends Message) { super(); @@ -555,7 +522,7 @@ export class StarlarkPackagePlanYamlArgs extends Message [ { no: 1, name: "apic_ip_address", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 2, name: "apic_port", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, - { no: 3, name: "starlark_script_plan_yaml_args", kind: "message", T: StarlarkPackagePlanYamlArgs$1 }, + { no: 3, name: "starlark_package_plan_yaml_args", kind: "message", T: StarlarkPackagePlanYamlArgs$1 }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): StarlarkPackagePlanYamlArgs { diff --git a/enclave-manager/server/server.go b/enclave-manager/server/server.go index 198ca9297d..1b0c30f997 100644 --- a/enclave-manager/server/server.go +++ b/enclave-manager/server/server.go @@ -444,9 +444,9 @@ func (c *WebServer) GetStarlarkScriptPlanYaml( request := &connect.Request[kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs]{ Msg: &kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs{ - SerializedScript: req.Msg.StarlarkPackagePlanYamlArgs.SerializedScript, - SerializedParams: req.Msg.StarlarkPackagePlanYamlArgs.SerializedParams, - MainFunctionName: req.Msg.StarlarkPackagePlanYamlArgs.MainFunctionName, + SerializedScript: req.Msg.StarlarkScriptPlanYamlArgs.SerializedScript, + SerializedParams: req.Msg.StarlarkScriptPlanYamlArgs.SerializedParams, + MainFunctionName: req.Msg.StarlarkScriptPlanYamlArgs.MainFunctionName, }, } result, err := (*apiContainerServiceClient).GetStarlarkScriptPlanYaml(ctx, request) @@ -479,10 +479,10 @@ func (c *WebServer) GetStarlarkPackagePlanYaml( request := &connect.Request[kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs]{ Msg: &kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs{ - PackageId: req.Msg.StarlarkScriptPlanYamlArgs.PackageId, - SerializedParams: req.Msg.StarlarkScriptPlanYamlArgs.SerializedParams, - RelativePathToMainFile: req.Msg.StarlarkScriptPlanYamlArgs.RelativePathToMainFile, - MainFunctionName: req.Msg.StarlarkScriptPlanYamlArgs.MainFunctionName, + PackageId: req.Msg.StarlarkPackagePlanYamlArgs.PackageId, + SerializedParams: req.Msg.StarlarkPackagePlanYamlArgs.SerializedParams, + RelativePathToMainFile: req.Msg.StarlarkPackagePlanYamlArgs.RelativePathToMainFile, + MainFunctionName: req.Msg.StarlarkPackagePlanYamlArgs.MainFunctionName, }, } result, err := (*apiContainerServiceClient).GetStarlarkPackagePlanYaml(ctx, request) From 4ab95ea18108a5733f942af101dcddaea8af628b Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 22 Feb 2024 14:37:59 -0500 Subject: [PATCH 25/75] impl endpoints in gateway --- .../api_container_gateway_service_server.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cli/cli/kurtosis_gateway/server/api_container_gateway/api_container_gateway_service_server.go b/cli/cli/kurtosis_gateway/server/api_container_gateway/api_container_gateway_service_server.go index 4821100ca2..2ee0606d93 100644 --- a/cli/cli/kurtosis_gateway/server/api_container_gateway/api_container_gateway_service_server.go +++ b/cli/cli/kurtosis_gateway/server/api_container_gateway/api_container_gateway_service_server.go @@ -230,6 +230,22 @@ func (service *ApiContainerGatewayServiceServer) GetStarlarkRun(ctx context.Cont return remoteApiContainerResponse, nil } +func (service *ApiContainerGatewayServiceServer) GetStarlarkScriptPlanYaml(ctx context.Context, args *kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) { + remoteApiContainerResponse, err := service.remoteApiContainerClient.GetStarlarkScriptPlanYaml(ctx, args) + if err != nil { + return nil, stacktrace.Propagate(err, errorCallingRemoteApiContainerFromGateway) + } + return remoteApiContainerResponse, nil +} + +func (service *ApiContainerGatewayServiceServer) GetStarlarkPackagePlanYaml(ctx context.Context, args *kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) { + remoteApiContainerResponse, err := service.remoteApiContainerClient.GetStarlarkPackagePlanYaml(ctx, args) + if err != nil { + return nil, stacktrace.Propagate(err, errorCallingRemoteApiContainerFromGateway) + } + return remoteApiContainerResponse, nil +} + // ==================================================================================================== // // Private helper methods From 8a67c71e8b064e5533d32abbeed7c952694ae0da Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 22 Feb 2024 15:14:51 -0500 Subject: [PATCH 26/75] fmt --- .../startosis_engine/kurtosis_instruction/tasks/run_sh.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go index da24071c1f..d519ceffd5 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go @@ -26,7 +26,7 @@ import ( const ( RunShBuiltinName = "run_sh" - DefaultRunShImageName = "badouralix/curl-jq" + DefaultRunShImageName = "badouralix/curl-jq" shScriptPrintCharLimit = 80 runningShScriptPrefix = "Running sh script" ) From 1972b4385a8611db7cb82aee274138c01e3ff52f Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 22 Feb 2024 18:25:42 -0500 Subject: [PATCH 27/75] tidy --- cli/cli/go.mod | 15 ++++------ cli/cli/go.sum | 29 +++++------------- core/launcher/go.mod | 16 ++++++++-- core/launcher/go.sum | 68 ++++++++++++++++++++++++++++++++++++++++-- engine/launcher/go.mod | 16 ++++++++-- engine/launcher/go.sum | 68 ++++++++++++++++++++++++++++++++++++++++-- engine/server/go.mod | 2 +- 7 files changed, 171 insertions(+), 43 deletions(-) diff --git a/cli/cli/go.mod b/cli/cli/go.mod index 8061858727..0e52ce70c5 100644 --- a/cli/cli/go.mod +++ b/cli/cli/go.mod @@ -50,9 +50,7 @@ require ( github.com/cli/oauth v1.0.1 github.com/compose-spec/compose-go v1.17.0 github.com/fatih/color v1.13.0 - github.com/go-git/go-git/v5 v5.11.0 github.com/google/go-github/v50 v50.2.0 - github.com/henvic/httpretty v0.1.3 github.com/joho/godotenv v1.5.1 github.com/kurtosis-tech/kurtosis-portal/api/golang v0.0.0-20230818182330-1a86869414d2 github.com/kurtosis-tech/kurtosis/cloud/api/golang v0.0.0 @@ -84,7 +82,6 @@ require ( github.com/cloudflare/circl v1.3.3 // indirect github.com/containerd/containerd v1.7.2 // indirect github.com/containerd/typeurl/v2 v2.1.1 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/danieljoos/wincred v1.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect @@ -99,9 +96,7 @@ require ( github.com/gammazero/workerpool v1.1.2 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/gin-gonic/gin v1.9.1 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.5.0 // indirect - github.com/go-logr/logr v1.2.3 // indirect + github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.1 // indirect @@ -110,7 +105,6 @@ require ( github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect @@ -121,10 +115,10 @@ require ( github.com/google/uuid v1.4.0 // indirect github.com/gorilla/websocket v1.5.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/henvic/httpretty v0.1.3 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.2 // indirect @@ -146,15 +140,17 @@ require ( github.com/muesli/termenv v0.13.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/nwaples/rardecode v1.1.3 // indirect + github.com/onsi/ginkgo/v2 v2.11.0 // indirect + github.com/onsi/gomega v1.27.10 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc3 // indirect github.com/pascaldekloe/name v1.0.1 // indirect github.com/pelletier/go-toml/v2 v2.0.9 // indirect github.com/pierrec/lz4 v2.6.1+incompatible // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.4.4 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/cors v1.9.0 // indirect github.com/segmentio/backo-go v1.0.0 // indirect github.com/segmentio/encoding v0.2.7 // indirect @@ -198,7 +194,6 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/segmentio/analytics-go.v3 v3.1.0 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect k8s.io/klog/v2 v2.90.1 // indirect k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect nhooyr.io/websocket v1.8.7 // indirect diff --git a/cli/cli/go.sum b/cli/cli/go.sum index 5cb753030d..7dfe986120 100644 --- a/cli/cli/go.sum +++ b/cli/cli/go.sum @@ -126,8 +126,6 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0= -github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= -github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE= github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -160,7 +158,6 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= @@ -193,13 +190,6 @@ github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= -github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= -github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= -github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= -github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -209,8 +199,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= @@ -230,7 +220,7 @@ github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+j github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o= github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= @@ -253,8 +243,6 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -363,8 +351,6 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= @@ -504,11 +490,12 @@ github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtb github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo/v2 v2.9.1 h1:zie5Ly042PD3bsCvsSOPvRnFwyo3rKe64TJlD6nu0mk= +github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= +github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -535,8 +522,6 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -580,6 +565,7 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE= github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= @@ -1019,7 +1005,6 @@ gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/segmentio/analytics-go.v3 v3.1.0 h1:UzxH1uaGZRpMKDhJyBz0pexz6yUoBU3x8bJsRk/HV6U= gopkg.in/segmentio/analytics-go.v3 v3.1.0/go.mod h1:4QqqlTlSSpVlWA9/9nDcPw+FkM2yv1NQoYjUbL9/JAw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/core/launcher/go.mod b/core/launcher/go.mod index 6e19016f80..5ddb18bfe1 100644 --- a/core/launcher/go.mod +++ b/core/launcher/go.mod @@ -19,16 +19,28 @@ require github.com/kurtosis-tech/kurtosis/metrics-library/golang v0.0.0-20231206 require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-logr/logr v1.2.3 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/kr/pretty v0.3.1 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/segmentio/backo-go v1.0.0 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.15.0 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + golang.org/x/text v0.14.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/segmentio/analytics-go.v3 v3.1.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/api v0.27.2 // indirect k8s.io/apimachinery v0.27.2 // indirect + k8s.io/klog/v2 v2.90.1 // indirect k8s.io/utils v0.0.0-20230711102312-30195339c3c7 // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect ) diff --git a/core/launcher/go.sum b/core/launcher/go.sum index b28854ec36..073aae64e6 100644 --- a/core/launcher/go.sum +++ b/core/launcher/go.sum @@ -4,8 +4,20 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -17,23 +29,29 @@ github.com/kurtosis-tech/kurtosis/metrics-library/golang v0.0.0-20231206095907-9 github.com/kurtosis-tech/kurtosis/metrics-library/golang v0.0.0-20231206095907-9bdf0d02cb90/go.mod h1:iI48cMGK2g4lkccaUPSVd+kjVnrKdwK5eCdCqHQIsmA= github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409 h1:YQTATifMUwZEtZYb0LVA7DK2pj8s71iY8rzweuUQ5+g= github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409/go.mod h1:y5weVs5d9wXXHcDA1awRxkIhhHC1xxYJN8a7aXnE6S8= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/segmentio/backo-go v1.0.0 h1:kbOAtGJY2DqOR0jfRkYEorx/b18RgtepGtY3+Cpe6qA= github.com/segmentio/backo-go v1.0.0/go.mod h1:kJ9mm9YmoWSkk+oQ+5Cj8DEoRCX2JT6As4kEtIIOp1M= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -41,21 +59,65 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c h1:3lbZUMbMiGUW/LMkfsEABsc5zNT9+b1CvsJx47JzJ8g= github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c/go.mod h1:UrdRz5enIKZ63MEE3IF9l2/ebyx59GyGgPi+tICQdmM= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/segmentio/analytics-go.v3 v3.1.0 h1:UzxH1uaGZRpMKDhJyBz0pexz6yUoBU3x8bJsRk/HV6U= gopkg.in/segmentio/analytics-go.v3 v3.1.0/go.mod h1:4QqqlTlSSpVlWA9/9nDcPw+FkM2yv1NQoYjUbL9/JAw= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +k8s.io/api v0.27.2 h1:+H17AJpUMvl+clT+BPnKf0E3ksMAzoBBg7CntpSuADo= +k8s.io/api v0.27.2/go.mod h1:ENmbocXfBT2ADujUXcBhHV55RIT31IIEvkntP6vZKS4= k8s.io/apimachinery v0.27.2 h1:vBjGaKKieaIreI+oQwELalVG4d8f3YAMNpWLzDXkxeg= k8s.io/apimachinery v0.27.2/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= +k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= +k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/utils v0.0.0-20230711102312-30195339c3c7 h1:ZgnF1KZsYxWIifwSNZFZgNtWE89WI5yiP5WwlfDoIyc= k8s.io/utils v0.0.0-20230711102312-30195339c3c7/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/engine/launcher/go.mod b/engine/launcher/go.mod index a4bc2bc276..285e64c067 100644 --- a/engine/launcher/go.mod +++ b/engine/launcher/go.mod @@ -22,16 +22,28 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-logr/logr v1.2.3 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/kr/pretty v0.3.1 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/segmentio/backo-go v1.0.0 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.15.0 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + golang.org/x/text v0.14.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/segmentio/analytics-go.v3 v3.1.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/api v0.27.2 // indirect k8s.io/apimachinery v0.27.2 // indirect + k8s.io/klog/v2 v2.90.1 // indirect k8s.io/utils v0.0.0-20230711102312-30195339c3c7 // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect ) diff --git a/engine/launcher/go.sum b/engine/launcher/go.sum index b28854ec36..073aae64e6 100644 --- a/engine/launcher/go.sum +++ b/engine/launcher/go.sum @@ -4,8 +4,20 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -17,23 +29,29 @@ github.com/kurtosis-tech/kurtosis/metrics-library/golang v0.0.0-20231206095907-9 github.com/kurtosis-tech/kurtosis/metrics-library/golang v0.0.0-20231206095907-9bdf0d02cb90/go.mod h1:iI48cMGK2g4lkccaUPSVd+kjVnrKdwK5eCdCqHQIsmA= github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409 h1:YQTATifMUwZEtZYb0LVA7DK2pj8s71iY8rzweuUQ5+g= github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409/go.mod h1:y5weVs5d9wXXHcDA1awRxkIhhHC1xxYJN8a7aXnE6S8= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/segmentio/backo-go v1.0.0 h1:kbOAtGJY2DqOR0jfRkYEorx/b18RgtepGtY3+Cpe6qA= github.com/segmentio/backo-go v1.0.0/go.mod h1:kJ9mm9YmoWSkk+oQ+5Cj8DEoRCX2JT6As4kEtIIOp1M= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -41,21 +59,65 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c h1:3lbZUMbMiGUW/LMkfsEABsc5zNT9+b1CvsJx47JzJ8g= github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c/go.mod h1:UrdRz5enIKZ63MEE3IF9l2/ebyx59GyGgPi+tICQdmM= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/segmentio/analytics-go.v3 v3.1.0 h1:UzxH1uaGZRpMKDhJyBz0pexz6yUoBU3x8bJsRk/HV6U= gopkg.in/segmentio/analytics-go.v3 v3.1.0/go.mod h1:4QqqlTlSSpVlWA9/9nDcPw+FkM2yv1NQoYjUbL9/JAw= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +k8s.io/api v0.27.2 h1:+H17AJpUMvl+clT+BPnKf0E3ksMAzoBBg7CntpSuADo= +k8s.io/api v0.27.2/go.mod h1:ENmbocXfBT2ADujUXcBhHV55RIT31IIEvkntP6vZKS4= k8s.io/apimachinery v0.27.2 h1:vBjGaKKieaIreI+oQwELalVG4d8f3YAMNpWLzDXkxeg= k8s.io/apimachinery v0.27.2/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= +k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= +k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/utils v0.0.0-20230711102312-30195339c3c7 h1:ZgnF1KZsYxWIifwSNZFZgNtWE89WI5yiP5WwlfDoIyc= k8s.io/utils v0.0.0-20230711102312-30195339c3c7/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/engine/server/go.mod b/engine/server/go.mod index 5d5765be45..9820ff8ffe 100644 --- a/engine/server/go.mod +++ b/engine/server/go.mod @@ -97,7 +97,7 @@ require ( github.com/kurtosis-tech/kurtosis/contexts-config-store v0.0.0 // indirect github.com/kurtosis-tech/kurtosis/enclave-manager/api/golang v0.0.0-20230828153722-32770ca96513 // indirect github.com/kurtosis-tech/kurtosis/kurtosis_version v0.0.0 // indirect - github.com/kurtosis-tech/kurtosis/utils v0.0.0-00010101000000-000000000000 // indirect + github.com/kurtosis-tech/kurtosis/utils v0.0.0-20240104153602-385833de9d76 // indirect github.com/labstack/gommon v0.4.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect From 5397fe6bf3752ea633ca08c752cbf3add78e5227 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 22 Feb 2024 18:38:16 -0500 Subject: [PATCH 28/75] lint --- .../startosis_engine/plan_yaml_generator.go | 60 ++++++++----------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index bc81e45cd4..a0dd6b7c37 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -80,9 +80,6 @@ type PlanYamlGeneratorImpl struct { packageReplaceOptions map[string]string - // stores all future references returned from instructions so they can be referenced later - futureReferencesStore map[string]string - // technically files artifacts are future references but we store them separately bc they are easily identifiable // and have a distinct structure (FilesArtifact) filesArtifactIndex map[string]*FilesArtifact @@ -111,7 +108,10 @@ func NewPlanYamlGenerator( packageReplaceOptions: packageReplaceOptions, locatorOfModuleInWhichThisBuiltInIsBeingCalled: locatorOfModuleInWhichThisBuiltInIsBeingCalled, planYaml: &PlanYaml{ - PackageId: packageId, + PackageId: packageId, + Services: []*Service{}, + FilesArtifacts: []*FilesArtifact{}, + Tasks: []*Task{}, }, filesArtifactIndex: map[string]*FilesArtifact{}, serviceIndex: map[string]*Service{}, @@ -162,7 +162,8 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc arguments := kurtosisInstruction.GetArguments() // start building Service Yaml object - service := &Service{} + service := &Service{} //nolint:exhaustruct + service.Uuid = string(addServiceInstruction.GetUuid()) // TODO: mock uuid generator for testing serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) @@ -175,15 +176,12 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc if err != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", add_service.ServiceConfigArgName) } - serviceConfig, err := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? + serviceConfig, _ := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? // TODO: add this error back in pyg.serviceNetwork, pyg.locatorOfModuleInWhichThisBuiltInIsBeingCalled, pyg.planYaml.PackageId, pyg.packageContentProvider, pyg.packageReplaceOptions) - if err != nil { - return err - } service.Image = serviceConfig.GetContainerImageName() // TODO: support image build specs, image registry specs, nix build specs service.Cmd = serviceConfig.GetCmdArgs() @@ -193,7 +191,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc service.Ports = []*Port{} for portName, configPort := range serviceConfig.GetPrivatePorts() { // TODO: support public ports - port := &Port{ + port := &Port{ //nolint:exhaustruct TransportProtocol: TransportProtocol(configPort.GetTransportProtocol().String()), Name: portName, Number: configPort.GetNumber(), @@ -226,8 +224,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc serviceFilesArtifactExpansions := serviceConfig.GetFilesArtifactsExpansion() if serviceFilesArtifactExpansions != nil { for mountPath, artifactIdentifiers := range serviceFilesArtifactExpansions.ServiceDirpathsToArtifactIdentifiers { - var fileMount *FileMount - fileMount = &FileMount{ + fileMount := &FileMount{ //nolint:exhaustruct MountPath: mountPath, } @@ -236,7 +233,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc var filesArtifact *FilesArtifact // if there's already a files artifact that exists with this name from a previous instruction, reference that if potentialFilesArtifact, ok := pyg.filesArtifactIndex[identifier]; ok { - filesArtifact = &FilesArtifact{ + filesArtifact = &FilesArtifact{ //nolint:exhaustruct Uuid: potentialFilesArtifact.Uuid, Name: potentialFilesArtifact.Name, } @@ -244,7 +241,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // otherwise create a new one // the only information we have about a files artifact that didn't already exist is the name // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ + filesArtifact = &FilesArtifact{ //nolint:exhaustruct Name: identifier, } pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) @@ -272,7 +269,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(uploadFilesInstr if castErr != nil { return castErr } - filesArtifact = &FilesArtifact{ + filesArtifact = &FilesArtifact{ //nolint:exhaustruct Uuid: string(uploadFilesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction Name: filesArtifactName, } @@ -299,7 +296,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(renderTempla if castErr != nil { return castErr } - filesArtifact = &FilesArtifact{ + filesArtifact = &FilesArtifact{ //nolint:exhaustruct Uuid: string(renderTemplatesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction Name: filesArtifactName, } @@ -337,7 +334,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst //if castErr != nil { // return castErr //} - task = &Task{ + task = &Task{ //nolint:exhaustruct Uuid: instructionUuid, TaskType: SHELL, } @@ -402,7 +399,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst var filesArtifact *FilesArtifact // if there's already a files artifact that exists with this name from a previous instruction, reference that if potentialFilesArtifact, ok := pyg.filesArtifactIndex[fileArtifactName]; ok { - filesArtifact = &FilesArtifact{ + filesArtifact = &FilesArtifact{ //nolint:exhaustruct Uuid: potentialFilesArtifact.Uuid, Name: potentialFilesArtifact.Name, } @@ -410,7 +407,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst // otherwise create a new one // the only information we have about a files artifact that didn't already exist is the name // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ + filesArtifact = &FilesArtifact{ //nolint:exhaustruct Name: fileArtifactName, } // add to the index and append to the plan yaml @@ -431,7 +428,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst // - add them to files artifacts list // - add them to the store section of run sh var store []*FilesArtifact - storeSpecs, err := tasks.ParseStoreFilesArg(pyg.serviceNetwork, arguments) + storeSpecs, _ := tasks.ParseStoreFilesArg(pyg.serviceNetwork, arguments) // TODO: catch this error //if err != startosis_errors.WrapWithInterpretationError(nil, "") { catch this error // return err @@ -445,7 +442,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst } pyg.filesArtifactIndex[storeSpec.GetName()] = newFilesArtifactFromStoreSpec pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, newFilesArtifactFromStoreSpec) - store = append(store, &FilesArtifact{ + store = append(store, &FilesArtifact{ //nolint:exhaustruct Uuid: instructionUuid, Name: storeSpec.GetName(), }) @@ -467,7 +464,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi //if castErr != nil { // return castErr //} - task = &Task{ + task = &Task{ //nolint:exhaustruct Uuid: instructionUuid, TaskType: PYTHON, } @@ -525,9 +522,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi if sliceParsingErr != nil { return startosis_errors.WrapWithInterpretationError(err, "error occurred while converting Starlark list of passed arguments to a golang string slice") } - for _, arg := range argsList { - task.PythonArgs = append(task.PythonArgs, arg) - } + task.PythonArgs = append(task.PythonArgs, argsList...) } if arguments.IsSet(tasks.PackagesArgName) { @@ -539,9 +534,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi if sliceParsingErr != nil { return startosis_errors.WrapWithInterpretationError(err, "error occurred while converting Starlark list of packages to a golang string slice") } - for _, pkg := range packagesList { - task.PythonPackages = append(task.PythonPackages, pkg) - } + task.PythonPackages = append(task.PythonPackages, packagesList...) } // for files: @@ -561,7 +554,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi var filesArtifact *FilesArtifact // if there's already a files artifact that exists with this name from a previous instruction, reference that if potentialFilesArtifact, ok := pyg.filesArtifactIndex[fileArtifactName]; ok { - filesArtifact = &FilesArtifact{ + filesArtifact = &FilesArtifact{ //nolint:exhaustruct Uuid: potentialFilesArtifact.Uuid, Name: potentialFilesArtifact.Name, } @@ -569,7 +562,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi // otherwise create a new one // the only information we have about a files artifact that didn't already exist is the name // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ + filesArtifact = &FilesArtifact{ //nolint:exhaustruct Name: fileArtifactName, } // add to the index and append to the plan yaml @@ -590,7 +583,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi // - add them to files artifacts list // - add them to the store section of run sh var store []*FilesArtifact - storeSpecs, err := tasks.ParseStoreFilesArg(pyg.serviceNetwork, arguments) + storeSpecs, _ := tasks.ParseStoreFilesArg(pyg.serviceNetwork, arguments) // TODO: catch this error //if err != startosis_errors.WrapWithInterpretationError(nil, "") { catch this error // return err @@ -604,7 +597,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi } pyg.filesArtifactIndex[storeSpec.GetName()] = newFilesArtifactFromStoreSpec pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, newFilesArtifactFromStoreSpec) - store = append(store, &FilesArtifact{ + store = append(store, &FilesArtifact{ //nolint:exhaustruct Uuid: instructionUuid, Name: storeSpec.GetName(), }) @@ -624,7 +617,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreServiceFiles(storeServi if castErr != nil { return castErr } - filesArtifact = &FilesArtifact{ + filesArtifact = &FilesArtifact{ //nolint:exhaustruct Uuid: string(storeServiceFilesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction Name: filesArtifactName, } @@ -656,7 +649,6 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreServiceFiles(storeServi func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(RemoveServiceInstruction *instructions_plan.ScheduledInstruction) error { // TODO: update the plan yaml based on an add_service - panic("remove service not implemented yet") return nil } From 88d4d689be50c8b719b9577a4cef6d05b3f7703c Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 23 Feb 2024 15:23:26 -0500 Subject: [PATCH 29/75] minor fixes --- .../server/startosis_engine/plan_yaml.go | 2 +- .../server/startosis_engine/plan_yaml_generator.go | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index a5f6091e2e..30ec91c149 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -21,7 +21,7 @@ type PlanYaml struct { type Service struct { Name string `yaml:"name,omitempty"` // done Uuid string `yaml:"uuid,omitempty"` // done - Image string `yaml:"image,omitempty"` // done + Image string `yaml:"image,omitempty"` // done // TOOD: support ImageBuildSpec Cmd []string `yaml:"command,omitempty"` // done Entrypoint []string `yaml:"entrypoint,omitempty"` // done EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` // done diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index a0dd6b7c37..57333b8454 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -234,8 +234,8 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // if there's already a files artifact that exists with this name from a previous instruction, reference that if potentialFilesArtifact, ok := pyg.filesArtifactIndex[identifier]; ok { filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Uuid: potentialFilesArtifact.Uuid, Name: potentialFilesArtifact.Name, + Uuid: potentialFilesArtifact.Uuid, } } else { // otherwise create a new one @@ -270,8 +270,8 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(uploadFilesInstr return castErr } filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Uuid: string(uploadFilesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction Name: filesArtifactName, + Uuid: string(uploadFilesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction } // get files of returned files artifact off render templates config @@ -400,8 +400,8 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst // if there's already a files artifact that exists with this name from a previous instruction, reference that if potentialFilesArtifact, ok := pyg.filesArtifactIndex[fileArtifactName]; ok { filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Uuid: potentialFilesArtifact.Uuid, Name: potentialFilesArtifact.Name, + Uuid: potentialFilesArtifact.Uuid, } } else { // otherwise create a new one @@ -469,7 +469,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi TaskType: PYTHON, } - // get runcmd, image and set them in the yaml + // get run cmd, image and set them in the yaml arguments := runPythonInstruction.GetInstruction().GetArguments() runCommand, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, tasks.RunArgName) if err != nil { @@ -647,6 +647,12 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreServiceFiles(storeServi return nil } +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instructions_plan.ScheduledInstruction) error { + // TODO: update the plan yaml based on an add_service + + return nil +} + func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(RemoveServiceInstruction *instructions_plan.ScheduledInstruction) error { // TODO: update the plan yaml based on an add_service return nil From cf8319033edbcc37dfa38f8fadf4f581b06fa47f Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 23 Feb 2024 15:33:19 -0500 Subject: [PATCH 30/75] use switch statement for image conversion --- .../service_config/service_config.go | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go b/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go index 4b8022c34c..a414bbff50 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go @@ -679,38 +679,37 @@ func convertImage( packageId string, packageContentProvider startosis_packages.PackageContentProvider, packageReplaceOptions map[string]string) (string, *image_build_spec.ImageBuildSpec, *image_registry_spec.ImageRegistrySpec, *nix_build_spec.NixBuildSpec, *startosis_errors.InterpretationError) { - imageBuildSpecStarlarkType, isImageBuildSpecStarlarkType := image.(*ImageBuildSpec) - imageSpecStarlarkType, isImageRegistrySpecStarlarkType := image.(*ImageSpec) - nixBuildSpecStarlarkType, isNixBuildSpecStarlarkType := image.(*NixBuildSpec) - if isImageBuildSpecStarlarkType { - imageBuildSpec, interpretationErr := imageBuildSpecStarlarkType.ToKurtosisType(locatorOfModuleInWhichThisBuiltInIsBeingCalled, packageId, packageContentProvider, packageReplaceOptions) + switch image := image.(type) { + case *ImageBuildSpec: + imageBuildSpec, interpretationErr := image.ToKurtosisType(locatorOfModuleInWhichThisBuiltInIsBeingCalled, packageId, packageContentProvider, packageReplaceOptions) if interpretationErr != nil { return "", nil, nil, nil, interpretationErr } - imageName, interpretationErr := imageBuildSpecStarlarkType.GetImageName() + imageName, interpretationErr := image.GetImageName() if interpretationErr != nil { return "", nil, nil, nil, interpretationErr } return imageName, imageBuildSpec, nil, nil, nil - } else if isImageRegistrySpecStarlarkType { - imageRegistrySpec, interpretationErr := imageSpecStarlarkType.ToKurtosisType() + case *ImageSpec: + imageRegistrySpec, interpretationErr := image.ToKurtosisType() if interpretationErr != nil { return "", nil, nil, nil, interpretationErr } return imageRegistrySpec.GetImageName(), nil, imageRegistrySpec, nil, nil - } else if isNixBuildSpecStarlarkType { - nixBuildSpec, interpretationErr := nixBuildSpecStarlarkType.ToKurtosisType(locatorOfModuleInWhichThisBuiltInIsBeingCalled, packageId, packageContentProvider, packageReplaceOptions) + case *NixBuildSpec: + nixBuildSpec, interpretationErr := image.ToKurtosisType(locatorOfModuleInWhichThisBuiltInIsBeingCalled, packageId, packageContentProvider, packageReplaceOptions) if interpretationErr != nil { return "", nil, nil, nil, interpretationErr } return nixBuildSpec.GetImageName(), nil, nil, nixBuildSpec, nil - } else { + default: imageName, interpretationErr := kurtosis_types.SafeCastToString(image, ImageAttr) if interpretationErr != nil { return "", nil, nil, nil, interpretationErr } return imageName, nil, nil, nil, nil } + } func convertTolerations(tolerationsList *starlark.List) ([]v1.Toleration, *startosis_errors.InterpretationError) { From 2aa7e6e5f13f41fa8f2bc2ed175dfbab49c0a0d8 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 23 Feb 2024 15:55:38 -0500 Subject: [PATCH 31/75] add exec test --- .../plan_yaml_generator_test.go | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 226e4d8f91..cb7dd6cf03 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -79,19 +79,14 @@ func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { mainFunctionName := "" relativePathToMainFile := "main.star" - serializedScript := `def run(plan, args): - plan.add_service( - name="tedi", - config=ServiceConfig( - image="postgres:alpine", - cmd=["touch", "hi.txt"], - ) - ) - - hi_files_artifact = plan.store_service_files( - name="hi-file", - src="hi.txt", - service_name="tedi", + serializedScript := `postgres_package = import_module("github.com/kurtosis-tech/postgres-package/main.star") + +def run(plan, args): + postgres_package.run(plan) + result = plan.exec( + service_name = "postgres", + recipe = ExecRecipe(command = ["echo", "Hello, world"]), + acceptable_codes=[0] ) ` serializedJsonParams := "{}" From ea4dfa0c5221c3042c4870f27ea7c1ca169e16c1 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 26 Feb 2024 10:57:33 -0500 Subject: [PATCH 32/75] checkpoint --- .../plan_yaml_generator_test.go | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index cb7dd6cf03..28d0ebc2d5 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -69,24 +69,46 @@ func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { } func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { - barModulePath := "github.com/foo/bar/hi.txt" - seedModules := map[string]string{ - barModulePath: "a=\"World!\"", - } - require.Nil(suite.T(), suite.packageContentProvider.BulkAddFileContent(seedModules)) + barModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server" + barModuleContents := `# Use an existing docker image as a base +FROM alpine:latest + +# Run commands to install necessary dependencies +RUN apk add --update nodejs npm + +# Set the working directory inside the container +WORKDIR /app + +# Copy the current directory contents into the container at /app +COPY . /app + +# Install app dependencies +RUN npm install + +# Expose a port the app runs on +EXPOSE 3000 + +# Define environment variable +ENV NODE_ENV=production + +# Command to run the application +CMD ["node", "app.js"] +` + require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(barModulePath, barModuleContents)) packageId := "github.com/kurtosis-tech/plan-yaml-prac" mainFunctionName := "" relativePathToMainFile := "main.star" - serializedScript := `postgres_package = import_module("github.com/kurtosis-tech/postgres-package/main.star") - -def run(plan, args): - postgres_package.run(plan) - result = plan.exec( - service_name = "postgres", - recipe = ExecRecipe(command = ["echo", "Hello, world"]), - acceptable_codes=[0] + serializedScript := `def run(plan, args): + plan.add_service( + name="tedi", + config=ServiceConfig( + image=ImageBuildSpec( + image_name="smth", + build_context_dir="./" + ) + ) ) ` serializedJsonParams := "{}" @@ -153,7 +175,6 @@ services: func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorSimplerScripButNotSoSimple() { script := ` def run(plan): - service_name = "partyService" From ae9f7ce4a203d3e6ac45d31896e1778b5878e790 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 26 Feb 2024 15:05:05 -0500 Subject: [PATCH 33/75] support image build spec --- .../service_config/service_config.go | 1 - .../server/startosis_engine/plan.yml | 16 ++---- .../server/startosis_engine/plan_yaml.go | 13 ++++- .../startosis_engine/plan_yaml_generator.go | 33 ++++++++++++- .../plan_yaml_generator_test.go | 49 ++++++++++++------- 5 files changed, 80 insertions(+), 32 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go b/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go index a414bbff50..c0e7d0ed5c 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/service_config.go @@ -709,7 +709,6 @@ func convertImage( } return imageName, nil, nil, nil, nil } - } func convertTolerations(tolerationsList *starlark.List) ([]v1.Toleration, *startosis_errors.InterpretationError) { diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index 0edc3f193d..aa761000f7 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,13 +1,7 @@ packageId: github.com/kurtosis-tech/plan-yaml-prac services: -- uuid: 2418173d9f184bd5a850b4ae8a1d0e06 - name: tedi - image: postgres:alpine - command: - - touch - - hi.txt -filesArtifacts: -- uuid: 2418173d9f184bd5a850b4ae8a1d0e06 - name: hi-file - files: - - hi.txt +- name: tedi + uuid: e77f8c7514c34c6f804f3332ddd1a16f + image: + name: smth + registry: ./server diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 30ec91c149..1147493154 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -21,7 +21,7 @@ type PlanYaml struct { type Service struct { Name string `yaml:"name,omitempty"` // done Uuid string `yaml:"uuid,omitempty"` // done - Image string `yaml:"image,omitempty"` // done // TOOD: support ImageBuildSpec + Image *ImageSpec `yaml:"image,omitempty"` // done // TOOD: support ImageBuildSpec Cmd []string `yaml:"command,omitempty"` // done Entrypoint []string `yaml:"entrypoint,omitempty"` // done EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` // done @@ -31,6 +31,17 @@ type Service struct { // TODO: support remaining fields in the ServiceConfig } +type ImageSpec struct { + ImageName string `yaml:"name,omitempty"` + + // for built images + BuildContextLocator string `yaml:"buildContextLocator,omitempty"` + TargetStage string `yaml:"targetStage,omitempty"` + + // for images from registry + Registry string `yaml:"registry,omitempty"` +} + // FilesArtifact represents a collection of files. type FilesArtifact struct { Name string `yaml:"name,omitempty"` diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 57333b8454..5e34ef044d 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -11,6 +11,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_type_constructor" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" @@ -176,14 +177,42 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc if err != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", add_service.ServiceConfigArgName) } - serviceConfig, _ := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? // TODO: add this error back in + serviceConfig, serviceConfigErr := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? // TODO: add this error back in pyg.serviceNetwork, pyg.locatorOfModuleInWhichThisBuiltInIsBeingCalled, pyg.planYaml.PackageId, pyg.packageContentProvider, pyg.packageReplaceOptions) + if serviceConfigErr != nil { + return serviceConfigErr + } + + // get image info + rawImageAttrValue, _, interpretationErr := kurtosis_type_constructor.ExtractAttrValue[starlark.Value](starlarkServiceConfig.KurtosisValueTypeDefault, service_config.ImageAttr) + if interpretationErr != nil { + return interpretationErr + } + image := &ImageSpec{ + ImageName: serviceConfig.GetContainerImageName(), + } + imageBuildSpec := serviceConfig.GetImageBuildSpec() + if imageBuildSpec != nil { + switch img := rawImageAttrValue.(type) { + case *service_config.ImageBuildSpec: + contextLocator, err := img.GetBuildContextLocator() + if err != nil { + return err + } + image.BuildContextLocator = contextLocator + } + image.TargetStage = imageBuildSpec.GetTargetStage() + } + imageSpec := serviceConfig.GetImageRegistrySpec() + if imageSpec != nil { + image.Registry = imageSpec.GetRegistryAddr() + } + service.Image = image - service.Image = serviceConfig.GetContainerImageName() // TODO: support image build specs, image registry specs, nix build specs service.Cmd = serviceConfig.GetCmdArgs() service.Entrypoint = serviceConfig.GetEntrypointArgs() diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 28d0ebc2d5..701ddde56c 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -60,17 +60,18 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.serviceNetwork.EXPECT().GetApiContainerInfo().Return(apiContainerInfo) } -//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { -// suite.Run(t, new(PlanYamlGeneratorTestSuite)) -//} +func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { + suite.Run(t, new(PlanYamlGeneratorTestSuite)) +} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() } func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { - barModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server" - barModuleContents := `# Use an existing docker image as a base + dockerfileModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server/Dockerfile" + serverModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server" + dockerfileContents := `# Use an existing docker image as a base FROM alpine:latest # Run commands to install necessary dependencies @@ -94,9 +95,11 @@ ENV NODE_ENV=production # Command to run the application CMD ["node", "app.js"] ` - require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(barModulePath, barModuleContents)) + require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(dockerfileModulePath, dockerfileContents)) + require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(serverModulePath, "")) packageId := "github.com/kurtosis-tech/plan-yaml-prac" + locatorOfModuleInWhichThisBuiltinIsBeingCalled := "github.com/kurtosis-tech/plan-yaml-prac/main.star" // this is going to cause problems, this value is different for every builtin in the plan and thus needs to be set per instruction mainFunctionName := "" relativePathToMainFile := "main.star" @@ -104,9 +107,11 @@ CMD ["node", "app.js"] plan.add_service( name="tedi", config=ServiceConfig( - image=ImageBuildSpec( - image_name="smth", - build_context_dir="./" + image=ImageSpec( + image="smth", + username="tedi", + password="tedi", + registry="./server" ) ) ) @@ -114,14 +119,14 @@ CMD ["node", "app.js"] serializedJsonParams := "{}" _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 2, instructionsPlan.Size()) + require.Equal(suite.T(), 1, instructionsPlan.Size()) pyg := NewPlanYamlGenerator( instructionsPlan, suite.serviceNetwork, packageId, suite.packageContentProvider, - "", // figure out if this is needed + locatorOfModuleInWhichThisBuiltinIsBeingCalled, // figure out if this is needed noPackageReplaceOptions, ) yamlBytes, err := pyg.GenerateYaml() @@ -283,9 +288,14 @@ func (suite *PlanYamlGeneratorTestSuite) TestConvertPlanYamlToYamlBytes(t *testi services := []*Service{ { - Name: "tedi", - Uuid: "uuid", - Image: "postgres:alpine", + Name: "tedi", + Uuid: "uuid", + Image: &ImageSpec{ + ImageName: "postgres", + BuildContextLocator: "", + TargetStage: "", + Registry: "", + }, EnvVars: []*EnvironmentVariable{ { Key: "kevin", @@ -294,9 +304,14 @@ func (suite *PlanYamlGeneratorTestSuite) TestConvertPlanYamlToYamlBytes(t *testi }, }, { - Name: "kaleb", - Uuid: "uuid", - Image: "postgres:alpine", + Name: "kaleb", + Uuid: "uuid", + Image: &ImageSpec{ + ImageName: "something", + BuildContextLocator: "", + TargetStage: "", + Registry: "", + }, EnvVars: []*EnvironmentVariable{ { Key: "kevin", From 8c7a4197a8ad0b24a999e810264163da8348f9e7 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 26 Feb 2024 16:37:35 -0500 Subject: [PATCH 34/75] remove locator of module var --- .../server/startosis_engine/plan.yml | 7 --- .../server/startosis_engine/plan_yaml.go | 5 +++ .../startosis_engine/plan_yaml_generator.go | 44 ++++++++++++++++--- .../plan_yaml_generator_test.go | 30 ++++++------- .../startosis_engine/startosis_runner.go | 1 - 5 files changed, 59 insertions(+), 28 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index aa761000f7..e69de29bb2 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,7 +0,0 @@ -packageId: github.com/kurtosis-tech/plan-yaml-prac -services: -- name: tedi - uuid: e77f8c7514c34c6f804f3332ddd1a16f - image: - name: smth - registry: ./server diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 1147493154..0c00819dee 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -7,6 +7,7 @@ const ( SHELL TaskType = "sh" PYTHON TaskType = "python" + EXEC TaskType = "exec" ) // TODO: there's really no point in making any of these references, consider just making them copies @@ -92,6 +93,10 @@ type Task struct { // only exists on PYTHON tasks PythonPackages []string `yaml:"pythonPackages,omitempty"` PythonArgs []string `yaml:"pythonArgs,omitempty"` + + // service name + ServiceName string `yaml:"serviceName,omitempty"` + AcceptableCodes []int64 `yaml:"acceptableCodes,omitempty"` } // TaskType represents the type of task (either PYTHON or SHELL) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 5e34ef044d..196b089c2c 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -5,6 +5,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files" @@ -14,6 +15,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_type_constructor" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/recipe" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" "go.starlark.net/starlark" @@ -77,8 +79,6 @@ type PlanYamlGeneratorImpl struct { packageContentProvider startosis_packages.PackageContentProvider - locatorOfModuleInWhichThisBuiltInIsBeingCalled string - packageReplaceOptions map[string]string // technically files artifacts are future references but we store them separately bc they are easily identifiable @@ -100,14 +100,12 @@ func NewPlanYamlGenerator( serviceNetwork service_network.ServiceNetwork, packageId string, packageContentProvider startosis_packages.PackageContentProvider, - locatorOfModuleInWhichThisBuiltInIsBeingCalled string, packageReplaceOptions map[string]string) *PlanYamlGeneratorImpl { return &PlanYamlGeneratorImpl{ plan: plan, serviceNetwork: serviceNetwork, packageContentProvider: packageContentProvider, packageReplaceOptions: packageReplaceOptions, - locatorOfModuleInWhichThisBuiltInIsBeingCalled: locatorOfModuleInWhichThisBuiltInIsBeingCalled, planYaml: &PlanYaml{ PackageId: packageId, Services: []*Service{}, @@ -145,6 +143,8 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { err = pyg.updatePlanYamlFromUploadFiles(scheduledInstruction) case store_service_files.StoreServiceFilesBuiltinName: err = pyg.updatePlanYamlFromStoreServiceFiles(scheduledInstruction) + case exec.ExecBuiltinName: + err = pyg.updatePlanYamlFromExec(scheduledInstruction) default: // skip if this instruction is not one that will update the plan yaml continue @@ -179,7 +179,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc } serviceConfig, serviceConfigErr := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? // TODO: add this error back in pyg.serviceNetwork, - pyg.locatorOfModuleInWhichThisBuiltInIsBeingCalled, + kurtosisInstruction.GetPositionInOriginalScript().GetFilename(), pyg.planYaml.PackageId, pyg.packageContentProvider, pyg.packageReplaceOptions) @@ -678,7 +678,41 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreServiceFiles(storeServi func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instructions_plan.ScheduledInstruction) error { // TODO: update the plan yaml based on an add_service + var task *Task + + arguments := execInstruction.GetInstruction().GetArguments() + serviceNameArgumentValue, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, exec.ServiceNameArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", exec.ServiceNameArgName) + } + task = &Task{ + ServiceName: serviceNameArgumentValue.GoString(), + } + execRecipe, err := builtin_argument.ExtractArgumentValue[*recipe.ExecRecipe](arguments, exec.RecipeArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", exec.RecipeArgName) + } + commandStarlarkList, _, interpretationErr := kurtosis_type_constructor.ExtractAttrValue[*starlark.List](execRecipe.KurtosisValueTypeDefault, recipe.CommandAttr) + if interpretationErr != nil { + return interpretationErr + } + task.RunCmd = commandStarlarkList.String() + + acceptableCodes := []int64{0} + if arguments.IsSet(exec.AcceptableCodesArgName) { + acceptableCodesValue, err := builtin_argument.ExtractArgumentValue[*starlark.List](arguments, exec.AcceptableCodesArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%v' argument", acceptableCodes) + } + acceptableCodes, err = kurtosis_types.SafeCastToIntegerSlice(acceptableCodesValue) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to parse '%v' argument", acceptableCodes) + } + } + task.AcceptableCodes = acceptableCodes + + pyg.planYaml.Tasks = append(pyg.planYaml.Tasks, task) return nil } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 701ddde56c..9d579875aa 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -99,34 +99,39 @@ CMD ["node", "app.js"] require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(serverModulePath, "")) packageId := "github.com/kurtosis-tech/plan-yaml-prac" - locatorOfModuleInWhichThisBuiltinIsBeingCalled := "github.com/kurtosis-tech/plan-yaml-prac/main.star" // this is going to cause problems, this value is different for every builtin in the plan and thus needs to be set per instruction mainFunctionName := "" relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): plan.add_service( - name="tedi", + name="db", config=ServiceConfig( - image=ImageSpec( - image="smth", - username="tedi", - password="tedi", - registry="./server" - ) + image="postgres:alpine", + env_vars = { + "POSTGRES_DB": "tedi", + "POSTGRES_USER": "tedi", + "POSTGRES_PASSWORD": "tedi", + } ) ) + + result = plan.exec( + service_name = "db", + recipe = ExecRecipe(command = ["echo", "Hello, world"]), + acceptable_codes=[156], + ) + plan.print(result) ` serializedJsonParams := "{}" _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 1, instructionsPlan.Size()) + require.Equal(suite.T(), 3, instructionsPlan.Size()) pyg := NewPlanYamlGenerator( instructionsPlan, suite.serviceNetwork, packageId, suite.packageContentProvider, - locatorOfModuleInWhichThisBuiltinIsBeingCalled, // figure out if this is needed noPackageReplaceOptions, ) yamlBytes, err := pyg.GenerateYaml() @@ -158,7 +163,6 @@ def run(plan): suite.serviceNetwork, startosis_constants.PackageIdPlaceholderForStandaloneScript, suite.packageContentProvider, - "", // figure out if this is needed noPackageReplaceOptions) yamlBytes, err := pyg.GenerateYaml() require.NoError(suite.T(), err) @@ -210,7 +214,6 @@ def run(plan): suite.serviceNetwork, startosis_constants.PackageIdPlaceholderForStandaloneScript, suite.packageContentProvider, - "", // figure out if this is needed noPackageReplaceOptions) yamlBytes, err := pyg.GenerateYaml() require.NoError(suite.T(), err) @@ -265,7 +268,6 @@ def run(plan): suite.serviceNetwork, startosis_constants.PackageIdPlaceholderForStandaloneScript, suite.packageContentProvider, - "", // figure out if this is needed noPackageReplaceOptions) yamlBytes, err := pyg.GenerateYaml() require.NoError(suite.T(), err) @@ -477,7 +479,6 @@ def run( suite.serviceNetwork, packageId, suite.packageContentProvider, - "", // figure out if this is needed noPackageReplaceOptions, ) yamlBytes, err := pyg.GenerateYaml() @@ -554,7 +555,6 @@ func (suite *PlanYamlGeneratorTestSuite) TestSimpleScriptWithFilesArtifact() { suite.serviceNetwork, packageId, suite.packageContentProvider, - "", // figure out if this is needed noPackageReplaceOptions, ) yamlBytes, err := pyg.GenerateYaml() diff --git a/core/server/api_container/server/startosis_engine/startosis_runner.go b/core/server/api_container/server/startosis_engine/startosis_runner.go index 294472c7f7..86a6c5afd9 100644 --- a/core/server/api_container/server/startosis_engine/startosis_runner.go +++ b/core/server/api_container/server/startosis_engine/startosis_runner.go @@ -170,7 +170,6 @@ func (runner *StartosisRunner) Run( runner.startosisInterpreter.serviceNetwork, packageId, runner.startosisInterpreter.packageContentProvider, - "", // don't think this matters? but figure out if it does packageReplaceOptions, ) planYaml, err := pyg.GenerateYaml() From 579a432b194149da34ee83b3115f19bd961e1194 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 26 Feb 2024 16:51:33 -0500 Subject: [PATCH 35/75] remove service --- .../startosis_engine/plan_yaml_generator.go | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 196b089c2c..e89d7f32e8 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -716,8 +716,24 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instru return nil } -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(RemoveServiceInstruction *instructions_plan.ScheduledInstruction) error { - // TODO: update the plan yaml based on an add_service +func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(removeServiceInstruction *instructions_plan.ScheduledInstruction) error { + arguments := removeServiceInstruction.GetInstruction().GetArguments() + + serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, remove_service.ServiceNameArgName) + if err != nil { + return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", remove_service.ServiceNameArgName) + } + + delete(pyg.serviceIndex, serviceName.GoString()) + + for idx, service := range pyg.planYaml.Services { + if service.Name == serviceName.GoString() { + pyg.planYaml.Services[idx] = pyg.planYaml.Services[len(pyg.planYaml.Services)-1] + pyg.planYaml.Services = pyg.planYaml.Services[:len(pyg.planYaml.Services)-1] + return nil + } + } + return nil } From 679ed739291040b5ab4788bd91a8b2f8ed880792 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 27 Feb 2024 22:52:28 -0500 Subject: [PATCH 36/75] fix plan gen calls --- .../server/api_container_service.go | 2 - .../plan_yaml_generator_test.go | 75 +++++++++++++++++-- 2 files changed, 70 insertions(+), 7 deletions(-) diff --git a/core/server/api_container/server/api_container_service.go b/core/server/api_container/server/api_container_service.go index 4d61e9ffeb..6d5f01b2a4 100644 --- a/core/server/api_container/server/api_container_service.go +++ b/core/server/api_container/server/api_container_service.go @@ -638,7 +638,6 @@ func (apicService *ApiContainerService) GetStarlarkPackagePlanYaml(ctx context.C apicService.serviceNetwork, packageIdFromArgs, apicService.packageContentProvider, - "", detectedPackageReplaceOptions) planYamlBytes, err := pyg.GenerateYaml() if err != nil { @@ -674,7 +673,6 @@ func (apicService *ApiContainerService) GetStarlarkScriptPlanYaml(ctx context.Co apicService.serviceNetwork, startosis_constants.PackageIdPlaceholderForStandaloneScript, apicService.packageContentProvider, - "", noPackageReplaceOptions) planYamlBytes, err := pyg.GenerateYaml() if err != nil { diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 9d579875aa..43dea1bd37 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -3,13 +3,17 @@ package startosis_engine import ( "context" "fmt" + "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/service" + "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/database_accessors/enclave_db/file_artifacts_db" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_plan_persistence" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/shared_helpers" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider" + "github.com/kurtosis-tech/kurtosis/core/server/commons/enclave_data_directory" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "net" @@ -22,8 +26,13 @@ type PlanYamlGeneratorTestSuite struct { serviceNetwork *service_network.MockServiceNetwork packageContentProvider *mock_package_content_provider.MockPackageContentProvider runtimeValueStore *runtime_value_store.RuntimeValueStore + kurtosisBackend *backend_interface.KurtosisBackend + filesArtifactStore *enclave_data_directory.FilesArtifactStore interpreter *StartosisInterpreter + validator *StartosisValidator + executor *StartosisExecutor + runner *StartosisRunner } func (suite *PlanYamlGeneratorTestSuite) SetupTest() { @@ -41,8 +50,6 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { // mock service network suite.serviceNetwork = service_network.NewMockServiceNetwork(suite.T()) - suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "") - service.NewServiceRegistration( testServiceName, service.ServiceUUID(fmt.Sprintf("%s-%s", testServiceName, serviceUuidSuffix)), @@ -58,16 +65,74 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { 51243, "134123") suite.serviceNetwork.EXPECT().GetApiContainerInfo().Return(apiContainerInfo) -} -func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { - suite.Run(t, new(PlanYamlGeneratorTestSuite)) + suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "") + + // mock kurtosis backend? + + // mock files artifact for testing + timesCalled := 0 + mockedGenerateNameMethod := func() string { + timesCalled = timesCalled + 1 + if timesCalled == 4 { + return "last-noun" + } + return "adjective-noun" + } + + artifactIdToUUIDMap := map[string]string{} + + fileArtifactDb, err := file_artifacts_db.GetFileArtifactsDbForTesting(enclaveDb, artifactIdToUUIDMap) + require.Nil(suite.T(), err) + + suite.filesArtifactStore = enclave_data_directory.NewFilesArtifactStoreForTesting("/", "/", fileArtifactDb, 3, mockedGenerateNameMethod) + suite.validator = NewStartosisValidator(suite.kurtosisBackend, suite.serviceNetwork, suite.filesArtifactStore) + + // mock the starlark value serde? + suite.executor = NewStartosisExecutor(nil, suite.runtimeValueStore, enclave_plan_persistence.NewEnclavePlan(), enclaveDb) + + suite.runner = NewStartosisRunner(suite.interpreter, suite.validator, suite.executor) } +//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { +// suite.Run(t, new(PlanYamlGeneratorTestSuite)) +//} + func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() } +func (suite *PlanYamlGeneratorTestSuite) TestFullExecution() { + packageId := "github.com/kurtosis-tech/plan-yaml-prac" + mainFunctionName := "" + relativePathToMainFile := "main.star" + + serializedScript := `def run(plan, args): + plan.add_service( + name="db", + config=ServiceConfig( + image="postgres:alpine", + env_vars = { + "POSTGRES_DB": "tedi", + "POSTGRES_USER": "tedi", + "POSTGRES_PASSWORD": "tedi", + } + ) + ) + + result = plan.exec( + service_name = "db", + recipe = ExecRecipe(command = ["echo", "Hello, world"]), + acceptable_codes=[156], + ) + plan.print(result) +` + serializedJsonParams := "{}" + _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 3, instructionsPlan.Size()) +} + func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { dockerfileModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server/Dockerfile" serverModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server" From e85af57917c03ba131b51c05b899898704753c1a Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 27 Feb 2024 23:01:45 -0500 Subject: [PATCH 37/75] lint --- .../server/startosis_engine/plan_yaml_generator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index e89d7f32e8..0316161b98 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -192,7 +192,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc if interpretationErr != nil { return interpretationErr } - image := &ImageSpec{ + image := &ImageSpec{ //nolint:exhaustruct ImageName: serviceConfig.GetContainerImageName(), } imageBuildSpec := serviceConfig.GetImageBuildSpec() @@ -685,7 +685,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instru if err != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", exec.ServiceNameArgName) } - task = &Task{ + task = &Task{ //nolint:exhaustruct ServiceName: serviceNameArgumentValue.GoString(), } From 9109cac2d3063ac82775a80747a4a5f96737d536 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Wed, 28 Feb 2024 12:59:29 -0500 Subject: [PATCH 38/75] add exec task type --- .../server/startosis_engine/plan.yml | 14 +++++ .../startosis_engine/plan_yaml_generator.go | 1 + .../plan_yaml_generator_test.go | 57 ++++--------------- 3 files changed, 27 insertions(+), 45 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index e69de29bb2..51207e05bd 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -0,0 +1,14 @@ +packageId: github.com/kurtosis-tech/plan-yaml-prac + +services: +- name: database + uuid: 1 + image: + name: postgres:latest +- name: tedi + uuid: 2 + image: + name: ubuntu:latest + envVars: + - key: DB_URL + value: '{{ kurtosis.4.ip_address }}' \ No newline at end of file diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 0316161b98..13183e7fbf 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -687,6 +687,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instru } task = &Task{ //nolint:exhaustruct ServiceName: serviceNameArgumentValue.GoString(), + TaskType: EXEC, } execRecipe, err := builtin_argument.ExtractArgumentValue[*recipe.ExecRecipe](arguments, exec.RecipeArgName) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 43dea1bd37..2bffcdaf9f 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -102,37 +102,6 @@ func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() } -func (suite *PlanYamlGeneratorTestSuite) TestFullExecution() { - packageId := "github.com/kurtosis-tech/plan-yaml-prac" - mainFunctionName := "" - relativePathToMainFile := "main.star" - - serializedScript := `def run(plan, args): - plan.add_service( - name="db", - config=ServiceConfig( - image="postgres:alpine", - env_vars = { - "POSTGRES_DB": "tedi", - "POSTGRES_USER": "tedi", - "POSTGRES_PASSWORD": "tedi", - } - ) - ) - - result = plan.exec( - service_name = "db", - recipe = ExecRecipe(command = ["echo", "Hello, world"]), - acceptable_codes=[156], - ) - plan.print(result) -` - serializedJsonParams := "{}" - _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) - require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 3, instructionsPlan.Size()) -} - func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { dockerfileModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server/Dockerfile" serverModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server" @@ -168,29 +137,27 @@ CMD ["node", "app.js"] relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - plan.add_service( - name="db", + database = plan.add_service( + name="database", config=ServiceConfig( - image="postgres:alpine", - env_vars = { - "POSTGRES_DB": "tedi", - "POSTGRES_USER": "tedi", - "POSTGRES_PASSWORD": "tedi", - } + image="postgres:latest", ) ) - result = plan.exec( - service_name = "db", - recipe = ExecRecipe(command = ["echo", "Hello, world"]), - acceptable_codes=[156], + plan.add_service( + name="tedi", + config=ServiceConfig( + image="ubuntu:latest", + env_vars={ + "DB_URL": database.ip_address + }, + ) ) - plan.print(result) ` serializedJsonParams := "{}" _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 3, instructionsPlan.Size()) + require.Equal(suite.T(), 2, instructionsPlan.Size()) pyg := NewPlanYamlGenerator( instructionsPlan, From 31a1be60a65eca962ac7684860a2a2707c4b696f Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 29 Feb 2024 08:50:48 -0500 Subject: [PATCH 39/75] assign monotonically increasing uuids --- .../server/startosis_engine/plan.yml | 38 ++++++++---- .../server/startosis_engine/plan_yaml.go | 6 +- .../startosis_engine/plan_yaml_generator.go | 59 +++++++++++-------- .../plan_yaml_generator_test.go | 45 +++++++------- 4 files changed, 86 insertions(+), 62 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index 51207e05bd..3dacfb347b 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,14 +1,26 @@ packageId: github.com/kurtosis-tech/plan-yaml-prac - -services: -- name: database - uuid: 1 - image: - name: postgres:latest -- name: tedi - uuid: 2 - image: - name: ubuntu:latest - envVars: - - key: DB_URL - value: '{{ kurtosis.4.ip_address }}' \ No newline at end of file +filesArtifacts: +- uuid: 1 + name: bye-file + files: + - bye.txt +- uuid: 3 + name: hi-file + files: + - /hi.txt +tasks: +- uuid: 2 + taskType: sh + command: echo $(cat /root/bye.txt) > hi.txt + image: badouralix/curl-jq + files: + - mountPath: /root + filesArtifacts: + - uuid: 1 + name: bye-file + store: + - uuid: 3 + name: hi-file + envVar: + - key: HELLO + value: Hello! diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 0c00819dee..f5a979218f 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -20,8 +20,8 @@ type PlanYaml struct { // Service represents a service in the system. type Service struct { + Uuid int `yaml:"uuid,omitempty"` // done Name string `yaml:"name,omitempty"` // done - Uuid string `yaml:"uuid,omitempty"` // done Image *ImageSpec `yaml:"image,omitempty"` // done // TOOD: support ImageBuildSpec Cmd []string `yaml:"command,omitempty"` // done Entrypoint []string `yaml:"entrypoint,omitempty"` // done @@ -45,8 +45,8 @@ type ImageSpec struct { // FilesArtifact represents a collection of files. type FilesArtifact struct { + Uuid int `yaml:"uuid,omitempty"` Name string `yaml:"name,omitempty"` - Uuid string `yaml:"uuid,omitempty"` Files []string `yaml:"files,omitempty"` } @@ -79,8 +79,8 @@ type FileMount struct { // Task represents a task to be executed. type Task struct { + Uuid int `yaml:"uuid,omitempty"` // done Name string `yaml:"name,omitempty"` // done - Uuid string `yaml:"uuid,omitempty"` // done TaskType TaskType `yaml:"taskType,omitempty"` // done RunCmd string `yaml:"command,omitempty"` // done Image string `yaml:"image,omitempty"` // done diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 13183e7fbf..ec8e1126a2 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -93,6 +93,8 @@ type PlanYamlGeneratorImpl struct { // Representation of plan in yaml the plan is being processed, the yaml gets updated planYaml *PlanYaml + + uuidGenerator int } func NewPlanYamlGenerator( @@ -114,8 +116,7 @@ func NewPlanYamlGenerator( }, filesArtifactIndex: map[string]*FilesArtifact{}, serviceIndex: map[string]*Service{}, - taskIndex: map[string]*Task{}, - } + taskIndex: map[string]*Task{}} } func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { @@ -165,7 +166,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // start building Service Yaml object service := &Service{} //nolint:exhaustruct - service.Uuid = string(addServiceInstruction.GetUuid()) // TODO: mock uuid generator for testing + service.Uuid = pyg.generateUuid() serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) if err != nil { @@ -272,6 +273,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args filesArtifact = &FilesArtifact{ //nolint:exhaustruct Name: identifier, + Uuid: pyg.generateUuid(), } pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) pyg.filesArtifactIndex[identifier] = filesArtifact @@ -300,7 +302,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(uploadFilesInstr } filesArtifact = &FilesArtifact{ //nolint:exhaustruct Name: filesArtifactName, - Uuid: string(uploadFilesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction + Uuid: pyg.generateUuid(), } // get files of returned files artifact off render templates config @@ -326,7 +328,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(renderTempla return castErr } filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Uuid: string(renderTemplatesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction + Uuid: pyg.generateUuid(), Name: filesArtifactName, } @@ -356,15 +358,13 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(renderTempla func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *instructions_plan.ScheduledInstruction) error { var task *Task - // set instruction uuid - instructionUuid := string(runShInstruction.GetUuid()) // get the name of //runShInstructionName, castErr := kurtosis_types.SafeCastToString(runShInstruction.GetInstruction(), "") //if castErr != nil { // return castErr //} task = &Task{ //nolint:exhaustruct - Uuid: instructionUuid, + Uuid: pyg.generateUuid(), TaskType: SHELL, } @@ -438,6 +438,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args filesArtifact = &FilesArtifact{ //nolint:exhaustruct Name: fileArtifactName, + Uuid: pyg.generateUuid(), } // add to the index and append to the plan yaml pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) @@ -464,15 +465,16 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst //} for _, storeSpec := range storeSpecs { // add the FilesArtifact to list of all files artifacts and index + uuid := pyg.generateUuid() var newFilesArtifactFromStoreSpec = &FilesArtifact{ - Uuid: instructionUuid, + Uuid: uuid, Name: storeSpec.GetName(), Files: []string{storeSpec.GetSrc()}, } pyg.filesArtifactIndex[storeSpec.GetName()] = newFilesArtifactFromStoreSpec pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, newFilesArtifactFromStoreSpec) store = append(store, &FilesArtifact{ //nolint:exhaustruct - Uuid: instructionUuid, + Uuid: uuid, Name: storeSpec.GetName(), }) } @@ -486,15 +488,12 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstruction *instructions_plan.ScheduledInstruction) error { var task *Task - // set instruction uuid - instructionUuid := string(runPythonInstruction.GetUuid()) - // get the name of //runShInstructionName, castErr := kurtosis_types.SafeCastToString(runShInstruction.GetInstruction(), "") //if castErr != nil { // return castErr //} task = &Task{ //nolint:exhaustruct - Uuid: instructionUuid, + Uuid: pyg.generateUuid(), TaskType: PYTHON, } @@ -593,6 +592,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args filesArtifact = &FilesArtifact{ //nolint:exhaustruct Name: fileArtifactName, + Uuid: pyg.generateUuid(), } // add to the index and append to the plan yaml pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) @@ -619,15 +619,16 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi //} for _, storeSpec := range storeSpecs { // add the FilesArtifact to list of all files artifacts and index + uuid := pyg.generateUuid() var newFilesArtifactFromStoreSpec = &FilesArtifact{ - Uuid: instructionUuid, + Uuid: uuid, Name: storeSpec.GetName(), Files: []string{storeSpec.GetSrc()}, } pyg.filesArtifactIndex[storeSpec.GetName()] = newFilesArtifactFromStoreSpec pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, newFilesArtifactFromStoreSpec) store = append(store, &FilesArtifact{ //nolint:exhaustruct - Uuid: instructionUuid, + Uuid: uuid, Name: storeSpec.GetName(), }) } @@ -647,21 +648,21 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreServiceFiles(storeServi return castErr } filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Uuid: string(storeServiceFilesInstruction.GetUuid()), // give the FilesArtifact the uuid of the originating instruction + Uuid: pyg.generateUuid(), Name: filesArtifactName, } arguments := storeServiceFilesInstruction.GetInstruction().GetArguments() // set the uuid to be the uuid of the service that this files artifact comes from - serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, store_service_files.ServiceNameArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", store_service_files.ServiceNameArgName) - } - if service, ok := pyg.serviceIndex[serviceName.GoString()]; !ok { - return startosis_errors.NewInterpretationError("A service that hasn't been tracked was found on a store service instruction.") - } else { - filesArtifact.Uuid = service.Uuid - } + //serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, store_service_files.ServiceNameArgName) + //if err != nil { + // return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", store_service_files.ServiceNameArgName) + //} + //if service, ok := pyg.serviceIndex[serviceName.GoString()]; !ok { + // return startosis_errors.NewInterpretationError("A service that hasn't been tracked was found on a store service instruction.") + //} else { + // filesArtifact.Uuid = service.Uuid + //} // parse for files src, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, store_service_files.SrcArgName) @@ -688,6 +689,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instru task = &Task{ //nolint:exhaustruct ServiceName: serviceNameArgumentValue.GoString(), TaskType: EXEC, + Uuid: pyg.generateUuid(), } execRecipe, err := builtin_argument.ExtractArgumentValue[*recipe.ExecRecipe](arguments, exec.RecipeArgName) @@ -752,3 +754,8 @@ func convertPlanYamlToYaml(planYaml *PlanYaml) ([]byte, error) { func getBuiltinNameFromInstruction(instruction *instructions_plan.ScheduledInstruction) string { return instruction.GetInstruction().GetCanonicalInstruction(false).GetInstructionName() } + +func (pyg *PlanYamlGeneratorImpl) generateUuid() int { + pyg.uuidGenerator++ + return pyg.uuidGenerator +} diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 2bffcdaf9f..e70d4b14cf 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -94,9 +94,9 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.runner = NewStartosisRunner(suite.interpreter, suite.validator, suite.executor) } -//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { -// suite.Run(t, new(PlanYamlGeneratorTestSuite)) -//} +func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { + suite.Run(t, new(PlanYamlGeneratorTestSuite)) +} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() @@ -137,27 +137,32 @@ CMD ["node", "app.js"] relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - database = plan.add_service( - name="database", - config=ServiceConfig( - image="postgres:latest", - ) + bye_files_artifact = plan.render_templates( + name="bye-file", + config={ + "bye.txt": struct( + template="Bye bye!", + data={} + ) + } ) - plan.add_service( - name="tedi", - config=ServiceConfig( - image="ubuntu:latest", - env_vars={ - "DB_URL": database.ip_address - }, - ) + plan.run_sh( + run="echo $(cat /root/bye.txt) > hi.txt", + env_vars = { + "HELLO": "Hello!" + }, + files = { + "/root": bye_files_artifact, + }, + store=[ + StoreSpec(src="/hi.txt", name="hi-file") + ] ) ` serializedJsonParams := "{}" _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 2, instructionsPlan.Size()) pyg := NewPlanYamlGenerator( instructionsPlan, @@ -323,7 +328,7 @@ func (suite *PlanYamlGeneratorTestSuite) TestConvertPlanYamlToYamlBytes(t *testi services := []*Service{ { Name: "tedi", - Uuid: "uuid", + Uuid: 1, Image: &ImageSpec{ ImageName: "postgres", BuildContextLocator: "", @@ -339,7 +344,7 @@ func (suite *PlanYamlGeneratorTestSuite) TestConvertPlanYamlToYamlBytes(t *testi }, { Name: "kaleb", - Uuid: "uuid", + Uuid: 1, Image: &ImageSpec{ ImageName: "something", BuildContextLocator: "", @@ -356,7 +361,7 @@ func (suite *PlanYamlGeneratorTestSuite) TestConvertPlanYamlToYamlBytes(t *testi } filesArtifacts := []*FilesArtifact{ { - Uuid: "something", + Uuid: 3, Name: "something", Files: nil, }, From 56d933175b2b9c562322329de8c0eb54e2f11f98 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 29 Feb 2024 09:30:57 -0500 Subject: [PATCH 40/75] save and detect future references on service --- .../server/startosis_engine/plan.yml | 33 +++---- .../startosis_engine/plan_yaml_generator.go | 85 ++++++++++++++++--- .../plan_yaml_generator_test.go | 39 ++++----- 3 files changed, 99 insertions(+), 58 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index 3dacfb347b..c26abe3fcb 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,26 +1,13 @@ packageId: github.com/kurtosis-tech/plan-yaml-prac -filesArtifacts: +services: - uuid: 1 - name: bye-file - files: - - bye.txt -- uuid: 3 - name: hi-file - files: - - /hi.txt -tasks: + name: database + image: + name: postgres:latest - uuid: 2 - taskType: sh - command: echo $(cat /root/bye.txt) > hi.txt - image: badouralix/curl-jq - files: - - mountPath: /root - filesArtifacts: - - uuid: 1 - name: bye-file - store: - - uuid: 3 - name: hi-file - envVar: - - key: HELLO - value: Hello! + name: tedi + image: + name: ubuntu:latest + envVars: + - key: DB_URL + value: '{{ kurtosis.1.ip_address }}' diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index ec8e1126a2..b35ef363cd 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -1,6 +1,7 @@ package startosis_engine import ( + "fmt" "github.com/go-yaml/yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan" @@ -18,7 +19,9 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/recipe" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" + "github.com/kurtosis-tech/stacktrace" "go.starlark.net/starlark" + "strings" ) // We need the package id and the args, the args need to be filled in @@ -95,6 +98,8 @@ type PlanYamlGeneratorImpl struct { planYaml *PlanYaml uuidGenerator int + + futureReferenceIndex map[string]string } func NewPlanYamlGenerator( @@ -114,9 +119,12 @@ func NewPlanYamlGenerator( FilesArtifacts: []*FilesArtifact{}, Tasks: []*Task{}, }, - filesArtifactIndex: map[string]*FilesArtifact{}, - serviceIndex: map[string]*Service{}, - taskIndex: map[string]*Task{}} + filesArtifactIndex: map[string]*FilesArtifact{}, + serviceIndex: map[string]*Service{}, + taskIndex: map[string]*Task{}, + uuidGenerator: 0, + futureReferenceIndex: map[string]string{}, + } } func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { @@ -165,17 +173,42 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // start building Service Yaml object service := &Service{} //nolint:exhaustruct + uuid := pyg.generateUuid() + service.Uuid = uuid - service.Uuid = pyg.generateUuid() - - serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) + // store future references of this service + returnValue := addServiceInstruction.GetReturnedValue() + returnedService, ok := returnValue.(*kurtosis_types.Service) + if !ok { + return stacktrace.NewError("Cast to service didn't work") + } + //futureRefServiceName, err := returnedService.GetName() + //if err != nil { + // return err + //} + //pyg.futureReferenceIndex[string(futureRefServiceName)] = fmt.Sprintf("{{ kurtosis.%v.service_name }}", uuid) + futureRefIPAddress, err := returnedService.GetIpAddress() if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", add_service.ServiceNameArgName) + return err } - service.Name = string(serviceName) - - starlarkServiceConfig, err := builtin_argument.ExtractArgumentValue[*service_config.ServiceConfig](arguments, add_service.ServiceConfigArgName) + pyg.futureReferenceIndex[futureRefIPAddress] = fmt.Sprintf("{{ kurtosis.%v.ip_address }}", uuid) + futureRefHostName, err := returnedService.GetHostname() if err != nil { + return err + } + pyg.futureReferenceIndex[futureRefHostName] = fmt.Sprintf("{{ kurtosis.%v.hostname }}", uuid) + + service.Uuid = uuid + + var regErr error + serviceName, regErr := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) + if regErr != nil { + return startosis_errors.WrapWithInterpretationError(regErr, "Unable to extract value for '%s' argument", add_service.ServiceNameArgName) + } + service.Name = pyg.swapFutureReference(serviceName.GoString()) // swap future references in the strings + + starlarkServiceConfig, regErr := builtin_argument.ExtractArgumentValue[*service_config.ServiceConfig](arguments, add_service.ServiceConfigArgName) + if regErr != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", add_service.ServiceConfigArgName) } serviceConfig, serviceConfigErr := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? // TODO: add this error back in @@ -214,8 +247,20 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc } service.Image = image - service.Cmd = serviceConfig.GetCmdArgs() - service.Entrypoint = serviceConfig.GetEntrypointArgs() + // detect future references + cmdArgs := []string{} + for _, cmdArg := range serviceConfig.GetCmdArgs() { + realCmdArg := pyg.swapFutureReference(cmdArg) + cmdArgs = append(cmdArgs, realCmdArg) + } + service.Cmd = cmdArgs + + entryArgs := []string{} + for _, entryArg := range serviceConfig.GetEntrypointArgs() { + realEntryArg := pyg.swapFutureReference(entryArg) + entryArgs = append(entryArgs, realEntryArg) + } + service.Entrypoint = entryArgs // ports service.Ports = []*Port{} @@ -236,9 +281,11 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // env vars service.EnvVars = []*EnvironmentVariable{} for key, val := range serviceConfig.GetEnvVars() { + // detect and future references + value := pyg.swapFutureReference(val) envVar := &EnvironmentVariable{ Key: key, - Value: val, + Value: value, } service.EnvVars = append(service.EnvVars, envVar) } @@ -759,3 +806,15 @@ func (pyg *PlanYamlGeneratorImpl) generateUuid() int { pyg.uuidGenerator++ return pyg.uuidGenerator } + +// if the string is a future reference, it swaps it out with what it should be +// else the string s is the same +func (pyg *PlanYamlGeneratorImpl) swapFutureReference(s string) string { + for futureRef, swappedValue := range pyg.futureReferenceIndex { + if strings.Contains(s, futureRef) { // TODO: handle case where s contains multiple future references + newString := strings.Replace(s, futureRef, swappedValue, -1) + return newString + } + } + return s +} diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index e70d4b14cf..9e74102865 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -94,9 +94,9 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.runner = NewStartosisRunner(suite.interpreter, suite.validator, suite.executor) } -func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { - suite.Run(t, new(PlanYamlGeneratorTestSuite)) -} +//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { +// suite.Run(t, new(PlanYamlGeneratorTestSuite)) +//} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() @@ -137,28 +137,23 @@ CMD ["node", "app.js"] relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - bye_files_artifact = plan.render_templates( - name="bye-file", - config={ - "bye.txt": struct( - template="Bye bye!", - data={} - ) - } + database = plan.add_service( + name="database", + config=ServiceConfig( + image="postgres:latest", + ) ) - plan.run_sh( - run="echo $(cat /root/bye.txt) > hi.txt", - env_vars = { - "HELLO": "Hello!" - }, - files = { - "/root": bye_files_artifact, - }, - store=[ - StoreSpec(src="/hi.txt", name="hi-file") - ] + plan.add_service( + name="tedi", + config=ServiceConfig( + image="ubuntu:latest", + env_vars={ + "DB_URL": database.ip_address + }, + ) ) + ` serializedJsonParams := "{}" _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) From 323ac97a75b58f4971217ee5bfbc3fef06dddd88 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 29 Feb 2024 09:41:19 -0500 Subject: [PATCH 41/75] fix exec cmd list --- .../server/startosis_engine/plan.yml | 25 +++++++++++++------ .../server/startosis_engine/plan_yaml.go | 2 +- .../startosis_engine/plan_yaml_generator.go | 19 +++++++++++--- .../plan_yaml_generator_test.go | 25 ++++++++++--------- 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index c26abe3fcb..3e0301a898 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,13 +1,22 @@ packageId: github.com/kurtosis-tech/plan-yaml-prac services: - uuid: 1 - name: database + name: db image: - name: postgres:latest -- uuid: 2 - name: tedi - image: - name: ubuntu:latest + name: postgres:alpine envVars: - - key: DB_URL - value: '{{ kurtosis.1.ip_address }}' + - key: POSTGRES_PASSWORD + value: tedi + - key: POSTGRES_DB + value: tedi + - key: POSTGRES_USER + value: tedi +tasks: +- uuid: 2 + taskType: exec + command: + - echo + - Hello, world + serviceName: db + acceptableCodes: + - 156 diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index f5a979218f..c8a9ab3b39 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -82,7 +82,7 @@ type Task struct { Uuid int `yaml:"uuid,omitempty"` // done Name string `yaml:"name,omitempty"` // done TaskType TaskType `yaml:"taskType,omitempty"` // done - RunCmd string `yaml:"command,omitempty"` // done + RunCmd []string `yaml:"command,omitempty"` // done Image string `yaml:"image,omitempty"` // done Files []*FileMount `yaml:"files,omitempty"` // done Store []*FilesArtifact `yaml:"store,omitempty"` // done diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index b35ef363cd..f9faf2a62a 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -421,7 +421,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst if err != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.RunArgName) } - task.RunCmd = runCommand.GoString() + task.RunCmd = []string{runCommand.GoString()} var image string if arguments.IsSet(tasks.ImageNameArgName) { @@ -550,7 +550,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi if err != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.RunArgName) } - task.RunCmd = runCommand.GoString() + task.RunCmd = []string{runCommand.GoString()} var image string if arguments.IsSet(tasks.ImageNameArgName) { @@ -747,7 +747,20 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instru if interpretationErr != nil { return interpretationErr } - task.RunCmd = commandStarlarkList.String() + // Convert Starlark list to Go slice + var cmdList []string + iter := commandStarlarkList.Iterate() + defer iter.Done() + var x starlark.Value + for iter.Next(&x) { + if i, ok := x.(starlark.String); ok { + cmdList = append(cmdList, i.GoString()) + } else { + // Handle the case if the element is not an integer + fmt.Println("Non-string element found in Starlark list") + } + } + task.RunCmd = cmdList acceptableCodes := []int64{0} if arguments.IsSet(exec.AcceptableCodesArgName) { diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 9e74102865..189e2385ca 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -137,23 +137,24 @@ CMD ["node", "app.js"] relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - database = plan.add_service( - name="database", - config=ServiceConfig( - image="postgres:latest", - ) - ) - plan.add_service( - name="tedi", + name="db", config=ServiceConfig( - image="ubuntu:latest", - env_vars={ - "DB_URL": database.ip_address - }, + image="postgres:alpine", + env_vars = { + "POSTGRES_DB": "tedi", + "POSTGRES_USER": "tedi", + "POSTGRES_PASSWORD": "tedi", + } ) ) + result = plan.exec( + service_name = "db", + recipe = ExecRecipe(command = ["echo", "Hello, world"]), + acceptable_codes=[156], + ) + plan.print(result) ` serializedJsonParams := "{}" _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) From 80ace33e5ef4c945cd76b0ec2daf89cb5d2db343 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 29 Feb 2024 10:01:33 -0500 Subject: [PATCH 42/75] finish swapping future ref mostly --- .../server/startosis_engine/plan.yml | 6 ++--- .../startosis_engine/plan_yaml_generator.go | 24 ++++++++----------- .../plan_yaml_generator_test.go | 4 ++-- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index 3e0301a898..3aa27a6390 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -5,18 +5,18 @@ services: image: name: postgres:alpine envVars: - - key: POSTGRES_PASSWORD - value: tedi - key: POSTGRES_DB value: tedi - key: POSTGRES_USER value: tedi + - key: POSTGRES_PASSWORD + value: tedi tasks: - uuid: 2 taskType: exec command: - echo - - Hello, world + - '{{ kurtosis.1.ip_address }}' serviceName: db acceptableCodes: - 156 diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index f9faf2a62a..8d867d4cc6 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -198,8 +198,6 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc } pyg.futureReferenceIndex[futureRefHostName] = fmt.Sprintf("{{ kurtosis.%v.hostname }}", uuid) - service.Uuid = uuid - var regErr error serviceName, regErr := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) if regErr != nil { @@ -421,7 +419,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst if err != nil { return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.RunArgName) } - task.RunCmd = []string{runCommand.GoString()} + task.RunCmd = []string{pyg.swapFutureReference(runCommand.GoString())} var image string if arguments.IsSet(tasks.ImageNameArgName) { @@ -597,6 +595,9 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi if sliceParsingErr != nil { return startosis_errors.WrapWithInterpretationError(err, "error occurred while converting Starlark list of passed arguments to a golang string slice") } + for idx, arg := range argsList { + argsList[idx] = pyg.swapFutureReference(arg) + } task.PythonArgs = append(task.PythonArgs, argsList...) } @@ -748,17 +749,12 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instru return interpretationErr } // Convert Starlark list to Go slice - var cmdList []string - iter := commandStarlarkList.Iterate() - defer iter.Done() - var x starlark.Value - for iter.Next(&x) { - if i, ok := x.(starlark.String); ok { - cmdList = append(cmdList, i.GoString()) - } else { - // Handle the case if the element is not an integer - fmt.Println("Non-string element found in Starlark list") - } + cmdList, sliceParsingErr := kurtosis_types.SafeCastToStringSlice(commandStarlarkList, tasks.PythonArgumentsArgName) + if sliceParsingErr != nil { + return startosis_errors.WrapWithInterpretationError(err, "error occurred while converting Starlark list of passed arguments to a golang string slice") + } + for idx, cmd := range cmdList { + cmdList[idx] = pyg.swapFutureReference(cmd) } task.RunCmd = cmdList diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 189e2385ca..7032526481 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -137,7 +137,7 @@ CMD ["node", "app.js"] relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - plan.add_service( + database = plan.add_service( name="db", config=ServiceConfig( image="postgres:alpine", @@ -151,7 +151,7 @@ CMD ["node", "app.js"] result = plan.exec( service_name = "db", - recipe = ExecRecipe(command = ["echo", "Hello, world"]), + recipe = ExecRecipe(command = ["echo", database.ip_address]), acceptable_codes=[156], ) plan.print(result) From 603281ff22d047415817437a1392e2cd2f6cc7e5 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 29 Feb 2024 12:33:31 -0500 Subject: [PATCH 43/75] change uuid from int to string type --- .../server/startosis_engine/plan_yaml.go | 6 ++--- .../startosis_engine/plan_yaml_generator.go | 25 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index c8a9ab3b39..1c0a0b0fb5 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -20,7 +20,7 @@ type PlanYaml struct { // Service represents a service in the system. type Service struct { - Uuid int `yaml:"uuid,omitempty"` // done + Uuid string `yaml:"uuid,omitempty"` // done Name string `yaml:"name,omitempty"` // done Image *ImageSpec `yaml:"image,omitempty"` // done // TOOD: support ImageBuildSpec Cmd []string `yaml:"command,omitempty"` // done @@ -45,7 +45,7 @@ type ImageSpec struct { // FilesArtifact represents a collection of files. type FilesArtifact struct { - Uuid int `yaml:"uuid,omitempty"` + Uuid string `yaml:"uuid,omitempty"` Name string `yaml:"name,omitempty"` Files []string `yaml:"files,omitempty"` } @@ -79,7 +79,7 @@ type FileMount struct { // Task represents a task to be executed. type Task struct { - Uuid int `yaml:"uuid,omitempty"` // done + Uuid string `yaml:"uuid,omitempty"` // done Name string `yaml:"name,omitempty"` // done TaskType TaskType `yaml:"taskType,omitempty"` // done RunCmd []string `yaml:"command,omitempty"` // done diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 8d867d4cc6..579d4be955 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -21,6 +21,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" "github.com/kurtosis-tech/stacktrace" "go.starlark.net/starlark" + "strconv" "strings" ) @@ -174,7 +175,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // start building Service Yaml object service := &Service{} //nolint:exhaustruct uuid := pyg.generateUuid() - service.Uuid = uuid + service.Uuid = strconv.Itoa(uuid) // store future references of this service returnValue := addServiceInstruction.GetReturnedValue() @@ -318,7 +319,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args filesArtifact = &FilesArtifact{ //nolint:exhaustruct Name: identifier, - Uuid: pyg.generateUuid(), + Uuid: strconv.Itoa(pyg.generateUuid()), } pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) pyg.filesArtifactIndex[identifier] = filesArtifact @@ -347,7 +348,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(uploadFilesInstr } filesArtifact = &FilesArtifact{ //nolint:exhaustruct Name: filesArtifactName, - Uuid: pyg.generateUuid(), + Uuid: strconv.Itoa(pyg.generateUuid()), } // get files of returned files artifact off render templates config @@ -373,7 +374,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(renderTempla return castErr } filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Uuid: pyg.generateUuid(), + Uuid: strconv.Itoa(pyg.generateUuid()), Name: filesArtifactName, } @@ -409,7 +410,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst // return castErr //} task = &Task{ //nolint:exhaustruct - Uuid: pyg.generateUuid(), + Uuid: strconv.Itoa(pyg.generateUuid()), TaskType: SHELL, } @@ -483,7 +484,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args filesArtifact = &FilesArtifact{ //nolint:exhaustruct Name: fileArtifactName, - Uuid: pyg.generateUuid(), + Uuid: strconv.Itoa(pyg.generateUuid()), } // add to the index and append to the plan yaml pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) @@ -510,7 +511,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst //} for _, storeSpec := range storeSpecs { // add the FilesArtifact to list of all files artifacts and index - uuid := pyg.generateUuid() + uuid := strconv.Itoa(pyg.generateUuid()) var newFilesArtifactFromStoreSpec = &FilesArtifact{ Uuid: uuid, Name: storeSpec.GetName(), @@ -538,7 +539,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi // return castErr //} task = &Task{ //nolint:exhaustruct - Uuid: pyg.generateUuid(), + Uuid: strconv.Itoa(pyg.generateUuid()), TaskType: PYTHON, } @@ -640,7 +641,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args filesArtifact = &FilesArtifact{ //nolint:exhaustruct Name: fileArtifactName, - Uuid: pyg.generateUuid(), + Uuid: strconv.Itoa(pyg.generateUuid()), } // add to the index and append to the plan yaml pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) @@ -667,7 +668,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi //} for _, storeSpec := range storeSpecs { // add the FilesArtifact to list of all files artifacts and index - uuid := pyg.generateUuid() + uuid := strconv.Itoa(pyg.generateUuid()) var newFilesArtifactFromStoreSpec = &FilesArtifact{ Uuid: uuid, Name: storeSpec.GetName(), @@ -696,7 +697,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreServiceFiles(storeServi return castErr } filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Uuid: pyg.generateUuid(), + Uuid: strconv.Itoa(pyg.generateUuid()), Name: filesArtifactName, } @@ -737,7 +738,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instru task = &Task{ //nolint:exhaustruct ServiceName: serviceNameArgumentValue.GoString(), TaskType: EXEC, - Uuid: pyg.generateUuid(), + Uuid: strconv.Itoa(pyg.generateUuid()), } execRecipe, err := builtin_argument.ExtractArgumentValue[*recipe.ExecRecipe](arguments, exec.RecipeArgName) From 0544d1b19db28c9a5d678caf3f6f81466bb13723 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 1 Mar 2024 10:30:29 -0500 Subject: [PATCH 44/75] fix future ref swapping --- .../server/startosis_engine/plan.yml | 27 ++++++----- .../server/startosis_engine/plan_yaml.go | 2 +- .../startosis_engine/plan_yaml_generator.go | 34 +++++++------- .../plan_yaml_generator_test.go | 45 +++++++++++++++---- 4 files changed, 69 insertions(+), 39 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index 3aa27a6390..72fbe8541d 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,22 +1,27 @@ packageId: github.com/kurtosis-tech/plan-yaml-prac services: -- uuid: 1 +- uuid: "1" name: db image: name: postgres:alpine envVars: - - key: POSTGRES_DB - value: tedi - key: POSTGRES_USER value: tedi - key: POSTGRES_PASSWORD value: tedi -tasks: -- uuid: 2 - taskType: exec + - key: POSTGRES_DB + value: tedi +- uuid: "2" + name: blob-spammer + image: + name: ethpandaops/tx-fuzz:master command: - - echo - - '{{ kurtosis.1.ip_address }}' - serviceName: db - acceptableCodes: - - 156 + - apk update && apk add curl jq && current_epoch=$(curl -s http://{{ kurtosis.1.ip_address + }}:5/eth/v2/beacon/blocks/head | jq -r ".version") && echo $current_epoch && while + [ $current_epoch != "deneb" ]; do echo "waiting for deneb, current epoch is $current_epoch"; + current_epoch=$(curl -s http://{{ kurtosis.1.ip_address }}:5/eth/v2/beacon/blocks/head + | jq -r ".version"); sleep 1; done && echo "sleep is over, starting to send blob + transactions" && /tx-fuzz.bin blobs --rpc={{ kurtosis.1.ip_address }} --sk=["0x12"] + entrypoint: + - /bin/sh + - -c diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go index 1c0a0b0fb5..4d307acdd3 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml.go @@ -22,7 +22,7 @@ type PlanYaml struct { type Service struct { Uuid string `yaml:"uuid,omitempty"` // done Name string `yaml:"name,omitempty"` // done - Image *ImageSpec `yaml:"image,omitempty"` // done // TOOD: support ImageBuildSpec + Image *ImageSpec `yaml:"image,omitempty"` // done Cmd []string `yaml:"command,omitempty"` // done Entrypoint []string `yaml:"entrypoint,omitempty"` // done EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` // done diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 579d4be955..b6fa01a20d 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -20,7 +20,9 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" "github.com/kurtosis-tech/stacktrace" + "github.com/sirupsen/logrus" "go.starlark.net/starlark" + "go.starlark.net/starlarkstruct" "strconv" "strings" ) @@ -165,6 +167,7 @@ func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { } // at the very end, convert the plan yaml representation into a yaml + logrus.Infof("FUTURE REFERENCE INDEX: %v", pyg.futureReferenceIndex) return convertPlanYamlToYaml(pyg.planYaml) } @@ -183,11 +186,6 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruc if !ok { return stacktrace.NewError("Cast to service didn't work") } - //futureRefServiceName, err := returnedService.GetName() - //if err != nil { - // return err - //} - //pyg.futureReferenceIndex[string(futureRefServiceName)] = fmt.Sprintf("{{ kurtosis.%v.service_name }}", uuid) futureRefIPAddress, err := returnedService.GetIpAddress() if err != nil { return err @@ -404,11 +402,13 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(renderTempla func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *instructions_plan.ScheduledInstruction) error { var task *Task - // get the name of - //runShInstructionName, castErr := kurtosis_types.SafeCastToString(runShInstruction.GetInstruction(), "") - //if castErr != nil { - // return castErr - //} + // store run sh future references + returnValue := runShInstruction.GetReturnedValue() + _, ok := returnValue.(*starlarkstruct.Struct) + if !ok { + return stacktrace.NewError("Cast to service didn't work") + } + task = &Task{ //nolint:exhaustruct Uuid: strconv.Itoa(pyg.generateUuid()), TaskType: SHELL, @@ -534,10 +534,8 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstruction *instructions_plan.ScheduledInstruction) error { var task *Task - //runShInstructionName, castErr := kurtosis_types.SafeCastToString(runShInstruction.GetInstruction(), "") - //if castErr != nil { - // return castErr - //} + // store future references + task = &Task{ //nolint:exhaustruct Uuid: strconv.Itoa(pyg.generateUuid()), TaskType: PYTHON, @@ -820,11 +818,11 @@ func (pyg *PlanYamlGeneratorImpl) generateUuid() int { // if the string is a future reference, it swaps it out with what it should be // else the string s is the same func (pyg *PlanYamlGeneratorImpl) swapFutureReference(s string) string { + newString := s for futureRef, swappedValue := range pyg.futureReferenceIndex { - if strings.Contains(s, futureRef) { // TODO: handle case where s contains multiple future references - newString := strings.Replace(s, futureRef, swappedValue, -1) - return newString + if strings.Contains(s, futureRef) { + newString = strings.Replace(s, futureRef, swappedValue, -1) } } - return s + return newString } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 7032526481..2df2b4c885 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -148,13 +148,40 @@ CMD ["node", "app.js"] } ) ) - - result = plan.exec( - service_name = "db", - recipe = ExecRecipe(command = ["echo", database.ip_address]), - acceptable_codes=[156], + + dencunTime = (5 * 32 * 1) + 5 + config = ServiceConfig( + image="ethpandaops/tx-fuzz:master", + entrypoint=["/bin/sh", "-c"], + cmd=[ + " && ".join( + [ + "apk update", + "apk add curl jq", + 'current_epoch=$(curl -s http://{0}:{1}/eth/v2/beacon/blocks/head | jq -r ".version")'.format( + database.ip_address, 5 + ), + "echo $current_epoch", + 'while [ $current_epoch != "deneb" ]; do echo "waiting for deneb, current epoch is $current_epoch"; current_epoch=$(curl -s http://{0}:{1}/eth/v2/beacon/blocks/head | jq -r ".version"); sleep {2}; done'.format( + database.ip_address, + 5, + 1, + ), + 'echo "sleep is over, starting to send blob transactions"', + "/tx-fuzz.bin blobs --rpc={} --sk={}".format( + database.ip_address, + ["0x12"], + ), + ] + ) + ], + min_cpu=100, + max_cpu=1000, + min_memory=256, + max_memory=512, + node_selectors={"smth":"smth"}, ) - plan.print(result) + plan.add_service("blob-spammer", config) ` serializedJsonParams := "{}" _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) @@ -324,7 +351,7 @@ func (suite *PlanYamlGeneratorTestSuite) TestConvertPlanYamlToYamlBytes(t *testi services := []*Service{ { Name: "tedi", - Uuid: 1, + Uuid: "1", Image: &ImageSpec{ ImageName: "postgres", BuildContextLocator: "", @@ -340,7 +367,7 @@ func (suite *PlanYamlGeneratorTestSuite) TestConvertPlanYamlToYamlBytes(t *testi }, { Name: "kaleb", - Uuid: 1, + Uuid: "1", Image: &ImageSpec{ ImageName: "something", BuildContextLocator: "", @@ -357,7 +384,7 @@ func (suite *PlanYamlGeneratorTestSuite) TestConvertPlanYamlToYamlBytes(t *testi } filesArtifacts := []*FilesArtifact{ { - Uuid: 3, + Uuid: "3", Name: "something", Files: nil, }, From ccc256bfc5fd7e6ea540e8d7c2b96fdee095e0fc Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 1 Mar 2024 11:18:09 -0500 Subject: [PATCH 45/75] store future references from tasks --- .../server/startosis_engine/plan.yml | 34 +++---- .../startosis_engine/plan_yaml_generator.go | 88 ++++++++++++++++--- .../plan_yaml_generator_test.go | 80 ++++++----------- 3 files changed, 112 insertions(+), 90 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index 72fbe8541d..31d9ba25fd 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,27 +1,17 @@ packageId: github.com/kurtosis-tech/plan-yaml-prac services: -- uuid: "1" - name: db - image: - name: postgres:alpine - envVars: - - key: POSTGRES_USER - value: tedi - - key: POSTGRES_PASSWORD - value: tedi - - key: POSTGRES_DB - value: tedi - uuid: "2" - name: blob-spammer + name: database image: - name: ethpandaops/tx-fuzz:master + name: postgres:latest + envVars: + - key: VAR_1 + value: '{{ kurtosis.1.output }}' + - key: VAR_2 + value: '{{ kurtosis.1.code }}' +tasks: +- uuid: "1" + taskType: sh command: - - apk update && apk add curl jq && current_epoch=$(curl -s http://{{ kurtosis.1.ip_address - }}:5/eth/v2/beacon/blocks/head | jq -r ".version") && echo $current_epoch && while - [ $current_epoch != "deneb" ]; do echo "waiting for deneb, current epoch is $current_epoch"; - current_epoch=$(curl -s http://{{ kurtosis.1.ip_address }}:5/eth/v2/beacon/blocks/head - | jq -r ".version"); sleep 1; done && echo "sleep is over, starting to send blob - transactions" && /tx-fuzz.bin blobs --rpc={{ kurtosis.1.ip_address }} --sk=["0x12"] - entrypoint: - - /bin/sh - - -c + - echo some stuff + image: badouralix/curl-jq diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index b6fa01a20d..54192f9a30 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -401,16 +401,36 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(renderTempla func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *instructions_plan.ScheduledInstruction) error { var task *Task + var interpErr *startosis_errors.InterpretationError + taskUuid := pyg.generateUuid() // store run sh future references returnValue := runShInstruction.GetReturnedValue() - _, ok := returnValue.(*starlarkstruct.Struct) + runShStruct, ok := returnValue.(*starlarkstruct.Struct) if !ok { return stacktrace.NewError("Cast to service didn't work") } + starlarkCodeVal, err := runShStruct.Attr("code") + if err != nil { + return err + } + starlarkCodeFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkCodeVal, "run sh code") + if interpErr != nil { + return interpErr + } + pyg.futureReferenceIndex[starlarkCodeFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.code }}", taskUuid) + starlarkOutputVal, err := runShStruct.Attr("output") + if err != nil { + return err + } + starlarkOutputFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkOutputVal, "run sh code") + if interpErr != nil { + return interpErr + } + pyg.futureReferenceIndex[starlarkOutputFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.output }}", taskUuid) task = &Task{ //nolint:exhaustruct - Uuid: strconv.Itoa(pyg.generateUuid()), + Uuid: strconv.Itoa(taskUuid), TaskType: SHELL, } @@ -533,11 +553,35 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstruction *instructions_plan.ScheduledInstruction) error { var task *Task + taskUuid := pyg.generateUuid() // store future references + returnValue := runPythonInstruction.GetReturnedValue() + runPythonStruct, ok := returnValue.(*starlarkstruct.Struct) + if !ok { + return stacktrace.NewError("Cast to service didn't work") + } + starlarkCodeVal, err := runPythonStruct.Attr("code") + if err != nil { + return err + } + starlarkCodeFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkCodeVal, "run python code") + if interpErr != nil { + return interpErr + } + pyg.futureReferenceIndex[starlarkCodeFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.code }}", taskUuid) + starlarkOutputVal, err := runPythonStruct.Attr("output") + if err != nil { + return err + } + starlarkOutputFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkOutputVal, "run python output") + if interpErr != nil { + return interpErr + } + pyg.futureReferenceIndex[starlarkOutputFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.output }}", taskUuid) task = &Task{ //nolint:exhaustruct - Uuid: strconv.Itoa(pyg.generateUuid()), + Uuid: strconv.Itoa(taskUuid), TaskType: PYTHON, } @@ -700,16 +744,6 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreServiceFiles(storeServi } arguments := storeServiceFilesInstruction.GetInstruction().GetArguments() - // set the uuid to be the uuid of the service that this files artifact comes from - //serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, store_service_files.ServiceNameArgName) - //if err != nil { - // return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", store_service_files.ServiceNameArgName) - //} - //if service, ok := pyg.serviceIndex[serviceName.GoString()]; !ok { - // return startosis_errors.NewInterpretationError("A service that hasn't been tracked was found on a store service instruction.") - //} else { - // filesArtifact.Uuid = service.Uuid - //} // parse for files src, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, store_service_files.SrcArgName) @@ -727,6 +761,32 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreServiceFiles(storeServi func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instructions_plan.ScheduledInstruction) error { // TODO: update the plan yaml based on an add_service var task *Task + taskUuid := pyg.generateUuid() + + // store future references + returnValue := execInstruction.GetReturnedValue() + execStruct, ok := returnValue.(*starlarkstruct.Struct) + if !ok { + return stacktrace.NewError("Cast to service didn't work") + } + starlarkCodeVal, err := execStruct.Attr("code") + if err != nil { + return err + } + starlarkCodeFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkCodeVal, "exec code") + if interpErr != nil { + return interpErr + } + pyg.futureReferenceIndex[starlarkCodeFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.code }}", taskUuid) + starlarkOutputVal, err := execStruct.Attr("output") + if err != nil { + return err + } + starlarkOutputFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkOutputVal, "exec output") + if interpErr != nil { + return interpErr + } + pyg.futureReferenceIndex[starlarkOutputFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.output }}", taskUuid) arguments := execInstruction.GetInstruction().GetArguments() serviceNameArgumentValue, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, exec.ServiceNameArgName) @@ -736,7 +796,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instru task = &Task{ //nolint:exhaustruct ServiceName: serviceNameArgumentValue.GoString(), TaskType: EXEC, - Uuid: strconv.Itoa(pyg.generateUuid()), + Uuid: strconv.Itoa(taskUuid), } execRecipe, err := builtin_argument.ExtractArgumentValue[*recipe.ExecRecipe](arguments, exec.RecipeArgName) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 2df2b4c885..2df44dc3df 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -9,6 +9,7 @@ import ( "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/database_accessors/enclave_db/file_artifacts_db" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_plan_persistence" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/interpretation_time_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/shared_helpers" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants" @@ -23,11 +24,12 @@ import ( type PlanYamlGeneratorTestSuite struct { suite.Suite - serviceNetwork *service_network.MockServiceNetwork - packageContentProvider *mock_package_content_provider.MockPackageContentProvider - runtimeValueStore *runtime_value_store.RuntimeValueStore - kurtosisBackend *backend_interface.KurtosisBackend - filesArtifactStore *enclave_data_directory.FilesArtifactStore + serviceNetwork *service_network.MockServiceNetwork + packageContentProvider *mock_package_content_provider.MockPackageContentProvider + runtimeValueStore *runtime_value_store.RuntimeValueStore + kurtosisBackend *backend_interface.KurtosisBackend + filesArtifactStore *enclave_data_directory.FilesArtifactStore + interpretationTimeValueStore *interpretation_time_value_store.InterpretationTimeValueStore interpreter *StartosisInterpreter validator *StartosisValidator @@ -47,6 +49,10 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { require.NoError(suite.T(), err) suite.runtimeValueStore = runtimeValueStore + // mock interpretation time value store + interpretationTimeValueStore, err := interpretation_time_value_store.CreateInterpretationTimeValueStore(enclaveDb, dummySerde) + require.NoError(suite.T(), err) + suite.interpretationTimeValueStore = interpretationTimeValueStore // mock service network suite.serviceNetwork = service_network.NewMockServiceNetwork(suite.T()) @@ -66,7 +72,7 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { "134123") suite.serviceNetwork.EXPECT().GetApiContainerInfo().Return(apiContainerInfo) - suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "") + suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "", suite.interpretationTimeValueStore) // mock kurtosis backend? @@ -94,9 +100,9 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.runner = NewStartosisRunner(suite.interpreter, suite.validator, suite.executor) } -//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { -// suite.Run(t, new(PlanYamlGeneratorTestSuite)) -//} +func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { + suite.Run(t, new(PlanYamlGeneratorTestSuite)) +} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() @@ -137,51 +143,17 @@ CMD ["node", "app.js"] relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - database = plan.add_service( - name="db", - config=ServiceConfig( - image="postgres:alpine", - env_vars = { - "POSTGRES_DB": "tedi", - "POSTGRES_USER": "tedi", - "POSTGRES_PASSWORD": "tedi", - } - ) - ) - - dencunTime = (5 * 32 * 1) + 5 - config = ServiceConfig( - image="ethpandaops/tx-fuzz:master", - entrypoint=["/bin/sh", "-c"], - cmd=[ - " && ".join( - [ - "apk update", - "apk add curl jq", - 'current_epoch=$(curl -s http://{0}:{1}/eth/v2/beacon/blocks/head | jq -r ".version")'.format( - database.ip_address, 5 - ), - "echo $current_epoch", - 'while [ $current_epoch != "deneb" ]; do echo "waiting for deneb, current epoch is $current_epoch"; current_epoch=$(curl -s http://{0}:{1}/eth/v2/beacon/blocks/head | jq -r ".version"); sleep {2}; done'.format( - database.ip_address, - 5, - 1, - ), - 'echo "sleep is over, starting to send blob transactions"', - "/tx-fuzz.bin blobs --rpc={} --sk={}".format( - database.ip_address, - ["0x12"], - ), - ] - ) - ], - min_cpu=100, - max_cpu=1000, - min_memory=256, - max_memory=512, - node_selectors={"smth":"smth"}, - ) - plan.add_service("blob-spammer", config) + result = plan.run_sh( + run="echo some stuff", + ) + + database = plan.add_service(name="database", config=ServiceConfig( + image="postgres:latest", + env_vars={ + "VAR_1": result.output, + "VAR_2": result.code + } + )) ` serializedJsonParams := "{}" _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) From a30d67e6fd7665ef05abeb8585bb61ad80b26a00 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 1 Mar 2024 11:46:49 -0500 Subject: [PATCH 46/75] comment out tests --- .../server/startosis_engine/plan_yaml_generator_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 2df44dc3df..f471dc12a2 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -100,9 +100,9 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.runner = NewStartosisRunner(suite.interpreter, suite.validator, suite.executor) } -func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { - suite.Run(t, new(PlanYamlGeneratorTestSuite)) -} +//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { +// suite.Run(t, new(PlanYamlGeneratorTestSuite)) +//} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() From 21e4eadfc66d9085b0f3c3fec2e02d95c0ff2c05 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 4 Mar 2024 05:48:42 -0500 Subject: [PATCH 47/75] fix exec --- .../server/startosis_engine/plan.yml | 36 ++++++++--- .../startosis_engine/plan_yaml_generator.go | 18 ++++-- .../plan_yaml_generator_test.go | 61 +++++++++---------- 3 files changed, 66 insertions(+), 49 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index 31d9ba25fd..79e6271ad8 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -1,17 +1,33 @@ packageId: github.com/kurtosis-tech/plan-yaml-prac services: -- uuid: "2" - name: database +- uuid: "1" + name: db image: name: postgres:latest envVars: - - key: VAR_1 - value: '{{ kurtosis.1.output }}' - - key: VAR_2 - value: '{{ kurtosis.1.code }}' + - key: POSTGRES_PASSWORD + value: tedi + - key: POSTGRES_DB + value: tedi + - key: POSTGRES_USER + value: tedi +- uuid: "3" + name: db2 + image: + name: postgres:latest + envVars: + - key: POSTGRES_DB + value: '{{ kurtosis.2.code }}' + - key: POSTGRES_USER + value: '{{ kurtosis.2.output }}' + - key: POSTGRES_PASSWORD + value: tedi tasks: -- uuid: "1" - taskType: sh +- uuid: "2" + taskType: exec command: - - echo some stuff - image: badouralix/curl-jq + - echo + - Hello, world + serviceName: db + acceptableCodes: + - 0 diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 54192f9a30..fc66bb6fdc 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -408,7 +408,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *inst returnValue := runShInstruction.GetReturnedValue() runShStruct, ok := returnValue.(*starlarkstruct.Struct) if !ok { - return stacktrace.NewError("Cast to service didn't work") + return stacktrace.NewError("Casting run sh return value to struct didn't work") } starlarkCodeVal, err := runShStruct.Attr("code") if err != nil { @@ -559,7 +559,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstructi returnValue := runPythonInstruction.GetReturnedValue() runPythonStruct, ok := returnValue.(*starlarkstruct.Struct) if !ok { - return stacktrace.NewError("Cast to service didn't work") + return stacktrace.NewError("Casting run python return value to a struct didn't work") } starlarkCodeVal, err := runPythonStruct.Attr("code") if err != nil { @@ -765,23 +765,29 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instru // store future references returnValue := execInstruction.GetReturnedValue() - execStruct, ok := returnValue.(*starlarkstruct.Struct) + execDict, ok := returnValue.(*starlark.Dict) if !ok { - return stacktrace.NewError("Cast to service didn't work") + return stacktrace.NewError("Casting exec return value to a struct didn't work") } - starlarkCodeVal, err := execStruct.Attr("code") + starlarkCodeVal, found, err := execDict.Get(starlark.String("code")) if err != nil { return err } + if !found { + return stacktrace.NewError("No code value found on exec dict") + } starlarkCodeFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkCodeVal, "exec code") if interpErr != nil { return interpErr } pyg.futureReferenceIndex[starlarkCodeFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.code }}", taskUuid) - starlarkOutputVal, err := execStruct.Attr("output") + starlarkOutputVal, found, err := execDict.Get(starlark.String("output")) if err != nil { return err } + if !found { + return stacktrace.NewError("No code value found on exec dict") + } starlarkOutputFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkOutputVal, "exec output") if interpErr != nil { return interpErr diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index f471dc12a2..2f4ee3645a 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -111,30 +111,8 @@ func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { dockerfileModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server/Dockerfile" serverModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server" - dockerfileContents := `# Use an existing docker image as a base -FROM alpine:latest + dockerfileContents := `` -# Run commands to install necessary dependencies -RUN apk add --update nodejs npm - -# Set the working directory inside the container -WORKDIR /app - -# Copy the current directory contents into the container at /app -COPY . /app - -# Install app dependencies -RUN npm install - -# Expose a port the app runs on -EXPOSE 3000 - -# Define environment variable -ENV NODE_ENV=production - -# Command to run the application -CMD ["node", "app.js"] -` require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(dockerfileModulePath, dockerfileContents)) require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(serverModulePath, "")) @@ -143,17 +121,34 @@ CMD ["node", "app.js"] relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - result = plan.run_sh( - run="echo some stuff", + plan.add_service( + name="db", + config=ServiceConfig( + image="postgres:latest", + env_vars={ + "POSTGRES_DB": "tedi", + "POSTGRES_USER": "tedi", + "POSTGRES_PASSWORD": "tedi", + } + ) + ) + result = plan.exec( + service_name="db", + recipe=ExecRecipe(command=["echo", "Hello, world"]), + acceptable_codes=[0], + ) + plan.print(result) + plan.add_service( + name="db2", + config=ServiceConfig( + image="postgres:latest", + env_vars={ + "POSTGRES_DB": result["code"], + "POSTGRES_USER": result["output"], + "POSTGRES_PASSWORD": "tedi", + } + ) ) - - database = plan.add_service(name="database", config=ServiceConfig( - image="postgres:latest", - env_vars={ - "VAR_1": result.output, - "VAR_2": result.code - } - )) ` serializedJsonParams := "{}" _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) From 61db9edacbb57feb81b091576d54a1a00f695d50 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 5 Mar 2024 17:42:00 -0500 Subject: [PATCH 48/75] start refactor --- .../server/api_container_service.go | 21 +--- .../instructions_plan/instructions_plan.go | 13 ++ .../kurtosis_instruction.go | 1 + .../startosis_engine/plan_yaml/plan_yaml.go | 112 ++++++++++++++++++ .../startosis_engine/plan_yaml_generator.go | 8 +- .../startosis_interpreter_plan_yaml_test.go | 100 ++++++++++++++++ .../startosis_engine/startosis_runner.go | 17 --- 7 files changed, 234 insertions(+), 38 deletions(-) create mode 100644 core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go create mode 100644 core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go diff --git a/core/server/api_container/server/api_container_service.go b/core/server/api_container/server/api_container_service.go index 6d5f01b2a4..eed9eec258 100644 --- a/core/server/api_container/server/api_container_service.go +++ b/core/server/api_container/server/api_container_service.go @@ -16,6 +16,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_structure" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan/resolver" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "io" "math" "net/http" @@ -633,18 +634,12 @@ func (apicService *ApiContainerService) GetStarlarkPackagePlanYaml(ctx context.C interpretationError = startosis_errors.NewInterpretationError(apiInterpretationError.GetErrorMessage()) return nil, interpretationError } - pyg := startosis_engine.NewPlanYamlGenerator( - instructionsPlan, - apicService.serviceNetwork, - packageIdFromArgs, - apicService.packageContentProvider, - detectedPackageReplaceOptions) - planYamlBytes, err := pyg.GenerateYaml() + planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(packageIdFromArgs)) if err != nil { return nil, err } - return &kurtosis_core_rpc_api_bindings.PlanYaml{PlanYaml: string(planYamlBytes)}, nil + return &kurtosis_core_rpc_api_bindings.PlanYaml{PlanYaml: planYaml}, nil } func (apicService *ApiContainerService) GetStarlarkScriptPlanYaml(ctx context.Context, args *kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) { @@ -668,18 +663,12 @@ func (apicService *ApiContainerService) GetStarlarkScriptPlanYaml(ctx context.Co if apiInterpretationError != nil { return nil, startosis_errors.NewInterpretationError(apiInterpretationError.GetErrorMessage()) } - pyg := startosis_engine.NewPlanYamlGenerator( - instructionsPlan, - apicService.serviceNetwork, - startosis_constants.PackageIdPlaceholderForStandaloneScript, - apicService.packageContentProvider, - noPackageReplaceOptions) - planYamlBytes, err := pyg.GenerateYaml() + planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) if err != nil { return nil, err } - return &kurtosis_core_rpc_api_bindings.PlanYaml{PlanYaml: string(planYamlBytes)}, nil + return &kurtosis_core_rpc_api_bindings.PlanYaml{PlanYaml: planYaml}, nil } // ==================================================================================================== diff --git a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go index caabaf9d98..ebe9a5abb9 100644 --- a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go +++ b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go @@ -3,6 +3,7 @@ package instructions_plan import ( "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/uuid_generator" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/stacktrace" "go.starlark.net/starlark" @@ -75,6 +76,18 @@ func (plan *InstructionsPlan) GeneratePlan() ([]*ScheduledInstruction, *startosi return generatedPlan, nil } +func (plan *InstructionsPlan) GenerateYaml(planYaml *plan_yaml.PlanYaml) (string, error) { + for _, instructionUuid := range plan.instructionsSequence { + _, found := plan.scheduledInstructionsIndex[instructionUuid] + if !found { + return "", startosis_errors.NewInterpretationError("Unexpected error generating the Kurtosis Instructions plan. Instruction with UUID '%s' was scheduled but could not be found in Kurtosis instruction index", instructionUuid) + } + // instruction.UpdatePlanYaml(planYaml) + } + planYamlBytes := []byte{} + return string(planYamlBytes), nil +} + func (plan *InstructionsPlan) Size() int { return len(plan.instructionsSequence) } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go index 6bcdf73c6a..74e12ac4f9 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go @@ -35,5 +35,6 @@ type KurtosisInstruction interface { // itself. In the current case, this is called in the executor, and it sets the UUID and the returned value. GetPersistableAttributes() *enclave_plan_persistence.EnclavePlanInstructionBuilder + // GetArguments returns arguments set on an instruction. These arguments are Starlark values that can be extracted. GetArguments() *builtin_argument.ArgumentValuesSet } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go new file mode 100644 index 0000000000..7c7ed253b5 --- /dev/null +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -0,0 +1,112 @@ +package plan_yaml + +const ( + HTTP ApplicationProtocol = "HTTP" + UDP TransportProtocol = "UDP" + TCP TransportProtocol = "TCP" + + SHELL TaskType = "sh" + PYTHON TaskType = "python" + EXEC TaskType = "exec" +) + +// TODO: there's really no point in making any of these references, consider just making them copies +type PlanYaml struct { + PackageId string `yaml:"packageId,omitempty"` + Services []*Service `yaml:"services,omitempty"` + FilesArtifacts []*FilesArtifact `yaml:"filesArtifacts,omitempty"` + Tasks []*Task `yaml:"tasks,omitempty"` +} + +// Service represents a service in the system. +type Service struct { + Uuid string `yaml:"uuid,omitempty"` // done + Name string `yaml:"name,omitempty"` // done + Image *ImageSpec `yaml:"image,omitempty"` // done + Cmd []string `yaml:"command,omitempty"` // done + Entrypoint []string `yaml:"entrypoint,omitempty"` // done + EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` // done + Ports []*Port `yaml:"ports,omitempty"` // done + Files []*FileMount `yaml:"files,omitempty"` // done + + // TODO: support remaining fields in the ServiceConfig +} + +type ImageSpec struct { + ImageName string `yaml:"name,omitempty"` + + // for built images + BuildContextLocator string `yaml:"buildContextLocator,omitempty"` + TargetStage string `yaml:"targetStage,omitempty"` + + // for images from registry + Registry string `yaml:"registry,omitempty"` +} + +// FilesArtifact represents a collection of files. +type FilesArtifact struct { + Uuid string `yaml:"uuid,omitempty"` + Name string `yaml:"name,omitempty"` + Files []string `yaml:"files,omitempty"` +} + +// EnvironmentVariable represents an environment variable. +type EnvironmentVariable struct { + Key string `yaml:"key,omitempty"` + Value string `yaml:"value,omitempty"` +} + +// Port represents a port. +type Port struct { + Name string `yaml:"name,omitempty"` + Number uint16 `yaml:"number,omitempty"` + + TransportProtocol TransportProtocol `yaml:"transportProtocol,omitempty"` + ApplicationProtocol ApplicationProtocol `yaml:"applicationProtocol,omitempty"` +} + +// ApplicationProtocol represents the application protocol used. +type ApplicationProtocol string + +// TransportProtocol represents transport protocol used. +type TransportProtocol string + +// FileMount represents a mount point for files. +type FileMount struct { + MountPath string `yaml:"mountPath,omitempty"` + FilesArtifacts []*FilesArtifact `yaml:"filesArtifacts,omitempty"` // TODO: support persistent directories +} + +// Task represents a task to be executed. +type Task struct { + Uuid string `yaml:"uuid,omitempty"` // done + Name string `yaml:"name,omitempty"` // done + TaskType TaskType `yaml:"taskType,omitempty"` // done + RunCmd []string `yaml:"command,omitempty"` // done + Image string `yaml:"image,omitempty"` // done + Files []*FileMount `yaml:"files,omitempty"` // done + Store []*FilesArtifact `yaml:"store,omitempty"` // done + + // only exists on SHELL tasks + EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` // done + + // only exists on PYTHON tasks + PythonPackages []string `yaml:"pythonPackages,omitempty"` + PythonArgs []string `yaml:"pythonArgs,omitempty"` + + // service name + ServiceName string `yaml:"serviceName,omitempty"` + AcceptableCodes []int64 `yaml:"acceptableCodes,omitempty"` +} + +// TaskType represents the type of task (either PYTHON or SHELL) +type TaskType string + +func CreateEmptyPlan(packageId string) *PlanYaml { + return &PlanYaml{ + PackageId: packageId, + Services: nil, + FilesArtifacts: nil, + Tasks: nil, + } +} diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index fc66bb6fdc..ccb4b10606 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -86,7 +86,9 @@ type PlanYamlGeneratorImpl struct { packageContentProvider startosis_packages.PackageContentProvider packageReplaceOptions map[string]string - + // consider using EnclaveComponents struct to manage services and files artifacts? + // this way we re use a common interface? + // but it doesn't have the // technically files artifacts are future references but we store them separately bc they are easily identifiable // and have a distinct structure (FilesArtifact) filesArtifactIndex map[string]*FilesArtifact @@ -94,9 +96,6 @@ type PlanYamlGeneratorImpl struct { // Store service index needed to see in case a service is referenced by a remove service, or store service later in the plan serviceIndex map[string]*Service - // TODO: do we need a task index? - taskIndex map[string]*Task - // Representation of plan in yaml the plan is being processed, the yaml gets updated planYaml *PlanYaml @@ -124,7 +123,6 @@ func NewPlanYamlGenerator( }, filesArtifactIndex: map[string]*FilesArtifact{}, serviceIndex: map[string]*Service{}, - taskIndex: map[string]*Task{}, uuidGenerator: 0, futureReferenceIndex: map[string]string{}, } diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go new file mode 100644 index 0000000000..4af4d5c5ee --- /dev/null +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go @@ -0,0 +1,100 @@ +package startosis_engine + +import ( + "context" + "fmt" + "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/service" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/interpretation_time_value_store" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/shared_helpers" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" +) + +type StartosisIntepreterPlanYamlTestSuite struct { + suite.Suite + serviceNetwork *service_network.MockServiceNetwork + packageContentProvider *mock_package_content_provider.MockPackageContentProvider + runtimeValueStore *runtime_value_store.RuntimeValueStore + interpretationTimeValueStore *interpretation_time_value_store.InterpretationTimeValueStore + + interpreter *StartosisInterpreter +} + +func (suite *StartosisIntepreterPlanYamlTestSuite) SetupTest() { + suite.packageContentProvider = mock_package_content_provider.NewMockPackageContentProvider() + enclaveDb := getEnclaveDBForTest(suite.T()) + + dummySerde := shared_helpers.NewDummyStarlarkValueSerDeForTest() + + runtimeValueStore, err := runtime_value_store.CreateRuntimeValueStore(dummySerde, enclaveDb) + require.NoError(suite.T(), err) + suite.runtimeValueStore = runtimeValueStore + suite.serviceNetwork = service_network.NewMockServiceNetwork(suite.T()) + + interpretationTimeValueStore, err := interpretation_time_value_store.CreateInterpretationTimeValueStore(enclaveDb, dummySerde) + require.NoError(suite.T(), err) + suite.interpretationTimeValueStore = interpretationTimeValueStore + require.NotNil(suite.T(), interpretationTimeValueStore) + + suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "", suite.interpretationTimeValueStore) + + service.NewServiceRegistration( + testServiceName, + service.ServiceUUID(fmt.Sprintf("%s-%s", testServiceName, serviceUuidSuffix)), + mockEnclaveUuid, + testServiceIpAddress, + string(testServiceName), + ) + suite.serviceNetwork.EXPECT().GetUniqueNameForFileArtifact().Maybe().Return(mockFileArtifactName, nil) + suite.serviceNetwork.EXPECT().GetEnclaveUuid().Maybe().Return(enclave.EnclaveUUID(mockEnclaveUuid)) + suite.serviceNetwork.EXPECT().ExistServiceRegistration(testServiceName).Maybe().Return(true, nil) +} + +//func TestRunStartosisIntepreterPlanYamlTestSuite(t *testing.T) { +// suite.Run(t, new(StartosisIntepreterPlanYamlTestSuite)) +//} + +func (suite *StartosisIntepreterPlanYamlTestSuite) TearDownTest() { + suite.packageContentProvider.RemoveAll() +} + +func (suite *StartosisIntepreterPlanYamlTestSuite) TestAddService() { + script := ` +def run(plan): + service_name = "serviceA" + config = ServiceConfig( + image = "` + testContainerImageName + `", + ports = { + "grpc": PortSpec(number = 1234, transport_protocol = "TCP", application_protocol = "http") + }, + ) + datastore_service = plan.add_service(name = service_name, config = config) +` + + _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, useDefaultMainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, script, startosis_constants.EmptyInputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 1, instructionsPlan.Size()) + + emptyPlanYaml := plan_yaml.CreateEmptyPlan(startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript) + planYaml, err := instructionsPlan.GenerateYaml(emptyPlanYaml) + require.NoError(suite.T(), err) + + expectedYaml := + `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT +services: +- name: serviceA + image: ` + testContainerImageName + ` + ports: + - name: grpc + number: 1234 + transportProtocol: TCP + applicationProtocol: http +` + require.Equal(suite.T(), expectedYaml, planYaml) +} diff --git a/core/server/api_container/server/startosis_engine/startosis_runner.go b/core/server/api_container/server/startosis_engine/startosis_runner.go index 86a6c5afd9..dd13197c73 100644 --- a/core/server/api_container/server/startosis_engine/startosis_runner.go +++ b/core/server/api_container/server/startosis_engine/startosis_runner.go @@ -164,23 +164,6 @@ func (runner *StartosisRunner) Run( startingExecutionMsg, defaultCurrentStepNumber, totalNumberOfInstructions) starlarkRunResponseLines <- progressInfo - if dryRun { - pyg := NewPlanYamlGenerator( - instructionsPlan, - runner.startosisInterpreter.serviceNetwork, - packageId, - runner.startosisInterpreter.packageContentProvider, - packageReplaceOptions, - ) - planYaml, err := pyg.GenerateYaml() - if err != nil { - starlarkRunResponseLines <- binding_constructors.NewStarlarkRunResponseLineFromWarning(err.Error()) - } - logrus.Infof("PLAN YAML:\n %v", string(planYaml)) - starlarkRunResponseLines <- binding_constructors.NewStarlarkRunResponseLineFromInfoMsg(string(planYaml)) - return - } - executionResponseLinesChan := runner.startosisExecutor.Execute(ctx, dryRun, parallelism, instructionsPlan.GetIndexOfFirstInstruction(), instructionsSequence, serializedScriptOutput) if isRunFinished, isRunSuccessful := forwardKurtosisResponseLineChannelUntilSourceIsClosed(executionResponseLinesChan, starlarkRunResponseLines); !isRunFinished { logrus.Warnf("Execution finished but no 'RunFinishedEvent' was received through the stream. This is unexpected as every execution should be terminal.") From 2c70e5f570c70f2673effd9954b6069a4ff7e112 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 5 Mar 2024 18:00:35 -0500 Subject: [PATCH 49/75] continue refactor --- .../instructions_plan/instructions_plan.go | 10 ++++++---- .../kurtosis_instruction/kurtosis_instruction.go | 3 +++ .../server/startosis_engine/plan_yaml/plan_yaml.go | 12 ++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go index ebe9a5abb9..8950bf5c8c 100644 --- a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go +++ b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go @@ -78,14 +78,16 @@ func (plan *InstructionsPlan) GeneratePlan() ([]*ScheduledInstruction, *startosi func (plan *InstructionsPlan) GenerateYaml(planYaml *plan_yaml.PlanYaml) (string, error) { for _, instructionUuid := range plan.instructionsSequence { - _, found := plan.scheduledInstructionsIndex[instructionUuid] + instruction, found := plan.scheduledInstructionsIndex[instructionUuid] if !found { return "", startosis_errors.NewInterpretationError("Unexpected error generating the Kurtosis Instructions plan. Instruction with UUID '%s' was scheduled but could not be found in Kurtosis instruction index", instructionUuid) } - // instruction.UpdatePlanYaml(planYaml) + err := instruction.kurtosisInstruction.UpdatePlan(planYaml) + if err != nil { + return "", startosis_errors.NewInterpretationError("An error occurred updating the plan.") // TODO: log information about the instruction? + } } - planYamlBytes := []byte{} - return string(planYamlBytes), nil + return planYaml.GenerateYaml() } func (plan *InstructionsPlan) Size() int { diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go index 74e12ac4f9..e043b59651 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go @@ -7,6 +7,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_structure" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" ) @@ -37,4 +38,6 @@ type KurtosisInstruction interface { // GetArguments returns arguments set on an instruction. These arguments are Starlark values that can be extracted. GetArguments() *builtin_argument.ArgumentValuesSet + + UpdatePlan(plan *plan_yaml.PlanYaml) error } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index 7c7ed253b5..615c637db2 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -1,5 +1,9 @@ package plan_yaml +import ( + "github.com/go-yaml/yaml" +) + const ( HTTP ApplicationProtocol = "HTTP" UDP TransportProtocol = "UDP" @@ -110,3 +114,11 @@ func CreateEmptyPlan(packageId string) *PlanYaml { Tasks: nil, } } + +func (pyg PlanYaml) GenerateYaml() (string, error) { + yamlBytes, err := yaml.Marshal(pyg) + if err != nil { + return "", err + } + return string(yamlBytes), nil +} From f842cfa8d2025a63038cfc14342d04cb8a8706ea Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 5 Mar 2024 18:24:02 -0500 Subject: [PATCH 50/75] continue refactor --- .../startosis_engine/instructions_plan/instructions_plan.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go index 8950bf5c8c..d0ee5e422f 100644 --- a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go +++ b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go @@ -76,6 +76,7 @@ func (plan *InstructionsPlan) GeneratePlan() ([]*ScheduledInstruction, *startosi return generatedPlan, nil } +// GenerateYaml func (plan *InstructionsPlan) GenerateYaml(planYaml *plan_yaml.PlanYaml) (string, error) { for _, instructionUuid := range plan.instructionsSequence { instruction, found := plan.scheduledInstructionsIndex[instructionUuid] From d661d5fa18a2bc226232c58d51a4b8142c8851b8 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 5 Mar 2024 19:58:59 -0500 Subject: [PATCH 51/75] checkpoint --- .../kurtosis_instruction/add_service/add_service.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go index 5a10e1e47d..8553b6616b 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go @@ -12,6 +12,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" @@ -248,6 +249,11 @@ func (builtin *AddServiceCapabilities) FillPersistableAttributes(builder *enclav ) } +func UpdatePlan(planYaml *plan_yaml.PlanYaml) error { + + return nil +} + func (builtin *AddServiceCapabilities) Description() string { return builtin.description } From 3998b570246ce828bf0597b38191469aaeb24a73 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 7 Mar 2024 11:16:54 -0500 Subject: [PATCH 52/75] create private plan yaml --- .../server/api_container_service.go | 12 +++--- .../instructions_plan/instructions_plan.go | 2 +- .../kurtosis_instruction.go | 1 + .../server/startosis_engine/plan.yml | 33 --------------- .../startosis_engine/plan_yaml/plan_yaml.go | 40 +++++++++++-------- 5 files changed, 31 insertions(+), 57 deletions(-) delete mode 100644 core/server/api_container/server/startosis_engine/plan.yml diff --git a/core/server/api_container/server/api_container_service.go b/core/server/api_container/server/api_container_service.go index eed9eec258..c33e4bd833 100644 --- a/core/server/api_container/server/api_container_service.go +++ b/core/server/api_container/server/api_container_service.go @@ -619,7 +619,7 @@ func (apicService *ApiContainerService) GetStarlarkPackagePlanYaml(ctx context.C } var apiInterpretationError *kurtosis_core_rpc_api_bindings.StarlarkInterpretationError - _, instructionsPlan, apiInterpretationError := apicService.startosisInterpreter.Interpret( // tedi: why interpret return an api interpretation error instead of a starlark one? + _, instructionsPlan, apiInterpretationError := apicService.startosisInterpreter.Interpret( ctx, detectedPackageId, mainFuncName, @@ -634,12 +634,12 @@ func (apicService *ApiContainerService) GetStarlarkPackagePlanYaml(ctx context.C interpretationError = startosis_errors.NewInterpretationError(apiInterpretationError.GetErrorMessage()) return nil, interpretationError } - planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(packageIdFromArgs)) + planYamlStr, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(packageIdFromArgs)) if err != nil { return nil, err } - return &kurtosis_core_rpc_api_bindings.PlanYaml{PlanYaml: planYaml}, nil + return &kurtosis_core_rpc_api_bindings.PlanYaml{PlanYaml: planYamlStr}, nil } func (apicService *ApiContainerService) GetStarlarkScriptPlanYaml(ctx context.Context, args *kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) { @@ -649,7 +649,7 @@ func (apicService *ApiContainerService) GetStarlarkScriptPlanYaml(ctx context.Co noPackageReplaceOptions := map[string]string{} var apiInterpretationError *kurtosis_core_rpc_api_bindings.StarlarkInterpretationError - _, instructionsPlan, apiInterpretationError := apicService.startosisInterpreter.Interpret( // tedi: why interpret return an api interpretation error instead of a starlark one? + _, instructionsPlan, apiInterpretationError := apicService.startosisInterpreter.Interpret( ctx, startosis_constants.PackageIdPlaceholderForStandaloneScript, mainFuncName, @@ -663,12 +663,12 @@ func (apicService *ApiContainerService) GetStarlarkScriptPlanYaml(ctx context.Co if apiInterpretationError != nil { return nil, startosis_errors.NewInterpretationError(apiInterpretationError.GetErrorMessage()) } - planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) + planYamlStr, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) if err != nil { return nil, err } - return &kurtosis_core_rpc_api_bindings.PlanYaml{PlanYaml: planYaml}, nil + return &kurtosis_core_rpc_api_bindings.PlanYaml{PlanYaml: planYamlStr}, nil } // ==================================================================================================== diff --git a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go index d0ee5e422f..3b64644f6c 100644 --- a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go +++ b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go @@ -76,7 +76,7 @@ func (plan *InstructionsPlan) GeneratePlan() ([]*ScheduledInstruction, *startosi return generatedPlan, nil } -// GenerateYaml +// GenerateYaml takes in an existing planYaml (usually empty) and returns a yaml string containing the effects of the plan func (plan *InstructionsPlan) GenerateYaml(planYaml *plan_yaml.PlanYaml) (string, error) { for _, instructionUuid := range plan.instructionsSequence { instruction, found := plan.scheduledInstructionsIndex[instructionUuid] diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go index e043b59651..f273aa8fdc 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go @@ -39,5 +39,6 @@ type KurtosisInstruction interface { // GetArguments returns arguments set on an instruction. These arguments are Starlark values that can be extracted. GetArguments() *builtin_argument.ArgumentValuesSet + // UpdatePlan updates the plan with the effects of running this instruction. UpdatePlan(plan *plan_yaml.PlanYaml) error } diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml deleted file mode 100644 index 79e6271ad8..0000000000 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ /dev/null @@ -1,33 +0,0 @@ -packageId: github.com/kurtosis-tech/plan-yaml-prac -services: -- uuid: "1" - name: db - image: - name: postgres:latest - envVars: - - key: POSTGRES_PASSWORD - value: tedi - - key: POSTGRES_DB - value: tedi - - key: POSTGRES_USER - value: tedi -- uuid: "3" - name: db2 - image: - name: postgres:latest - envVars: - - key: POSTGRES_DB - value: '{{ kurtosis.2.code }}' - - key: POSTGRES_USER - value: '{{ kurtosis.2.output }}' - - key: POSTGRES_PASSWORD - value: tedi -tasks: -- uuid: "2" - taskType: exec - command: - - echo - - Hello, world - serviceName: db - acceptableCodes: - - 0 diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index 615c637db2..610b8e85f4 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -15,7 +15,13 @@ const ( ) // TODO: there's really no point in making any of these references, consider just making them copies +// PlanYaml is a representation of the state of an enclave. + type PlanYaml struct { + privatePlanYaml *privatePlanYaml +} + +type privatePlanYaml struct { PackageId string `yaml:"packageId,omitempty"` Services []*Service `yaml:"services,omitempty"` FilesArtifacts []*FilesArtifact `yaml:"filesArtifacts,omitempty"` @@ -24,16 +30,14 @@ type PlanYaml struct { // Service represents a service in the system. type Service struct { - Uuid string `yaml:"uuid,omitempty"` // done - Name string `yaml:"name,omitempty"` // done - Image *ImageSpec `yaml:"image,omitempty"` // done - Cmd []string `yaml:"command,omitempty"` // done - Entrypoint []string `yaml:"entrypoint,omitempty"` // done - EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` // done - Ports []*Port `yaml:"ports,omitempty"` // done - Files []*FileMount `yaml:"files,omitempty"` // done - - // TODO: support remaining fields in the ServiceConfig + Uuid string `yaml:"uuid,omitempty"` + Name string `yaml:"name,omitempty"` + Image *ImageSpec `yaml:"image,omitempty"` + Cmd []string `yaml:"command,omitempty"` + Entrypoint []string `yaml:"entrypoint,omitempty"` + EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` + Ports []*Port `yaml:"ports,omitempty"` + Files []*FileMount `yaml:"files,omitempty"` } type ImageSpec struct { @@ -88,8 +92,8 @@ type Task struct { TaskType TaskType `yaml:"taskType,omitempty"` // done RunCmd []string `yaml:"command,omitempty"` // done Image string `yaml:"image,omitempty"` // done - Files []*FileMount `yaml:"files,omitempty"` // done - Store []*FilesArtifact `yaml:"store,omitempty"` // done + Files []*FileMount `yaml:"files,omitempty"` + Store []*FilesArtifact `yaml:"store,omitempty"` // only exists on SHELL tasks EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` // done @@ -108,15 +112,17 @@ type TaskType string func CreateEmptyPlan(packageId string) *PlanYaml { return &PlanYaml{ - PackageId: packageId, - Services: nil, - FilesArtifacts: nil, - Tasks: nil, + privatePlanYaml: &privatePlanYaml{ + PackageId: packageId, + Services: []*Service{}, + Tasks: []*Task{}, + FilesArtifacts: []*FilesArtifact{}, + }, } } func (pyg PlanYaml) GenerateYaml() (string, error) { - yamlBytes, err := yaml.Marshal(pyg) + yamlBytes, err := yaml.Marshal(pyg.privatePlanYaml) if err != nil { return "", err } From 5334082a3bc97eb3a99275b3f21c5fea747cd237 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 7 Mar 2024 17:07:42 -0500 Subject: [PATCH 53/75] add update plan to interfaces --- .../instructions_plan/instructions_plan.go | 2 +- .../add_service/add_service.go | 167 +++++++++++++++++- .../add_service/add_services.go | 5 + .../kurtosis_instruction/exec/exec.go | 5 + .../get_service/get_service.go | 5 + .../kurtosis_print/kurtosis_print.go | 5 + .../mock_kurtosis_instruction.go | 44 +++++ .../remove_service/remove_service.go | 5 + .../render_templates/render_templates.go | 5 + .../kurtosis_instruction/request/request.go | 5 + .../start_service/start_service.go | 5 + .../stop_service/stop_service.go | 5 + .../store_service_files.go | 5 + .../kurtosis_instruction/tasks/run_python.go | 5 + .../kurtosis_instruction/tasks/run_sh.go | 5 + .../upload_files/upload_files.go | 5 + .../kurtosis_instruction/verify/verify.go | 5 + .../kurtosis_instruction/wait/wait.go | 5 + .../kurtosis_plan_instruction_capabilities.go | 4 + .../kurtosis_plan_instruction_internal.go | 5 + .../startosis_engine/plan_yaml/plan_yaml.go | 5 +- 21 files changed, 295 insertions(+), 7 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go index 3b64644f6c..6ad8f2dac3 100644 --- a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go +++ b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go @@ -85,7 +85,7 @@ func (plan *InstructionsPlan) GenerateYaml(planYaml *plan_yaml.PlanYaml) (string } err := instruction.kurtosisInstruction.UpdatePlan(planYaml) if err != nil { - return "", startosis_errors.NewInterpretationError("An error occurred updating the plan.") // TODO: log information about the instruction? + return "", startosis_errors.WrapWithInterpretationError(err, "An error occurred updating the plan.") // TODO: log information about the instruction? } } return planYaml.GenerateYaml() diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go index 8553b6616b..b6e79237c8 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go @@ -249,9 +249,170 @@ func (builtin *AddServiceCapabilities) FillPersistableAttributes(builder *enclav ) } -func UpdatePlan(planYaml *plan_yaml.PlanYaml) error { - - return nil +func (builtin *AddServiceCapabilities) UpdatePlan(planYaml *plan_yaml.PlanYaml) error { + //kurtosisInstruction := addServiceInstruction.GetInstruction() + //arguments := kurtosisInstruction.GetArguments() + // + //// start building Service Yaml object + //service := &Service{} //nolint:exhaustruct + //uuid := pyg.generateUuid() + //service.Uuid = strconv.Itoa(uuid) + // + //// store future references of this service + //returnValue := addServiceInstruction.GetReturnedValue() + //returnedService, ok := returnValue.(*kurtosis_types.Service) + //if !ok { + // return stacktrace.NewError("Cast to service didn't work") + //} + //futureRefIPAddress, err := returnedService.GetIpAddress() + //if err != nil { + // return err + //} + //pyg.futureReferenceIndex[futureRefIPAddress] = fmt.Sprintf("{{ kurtosis.%v.ip_address }}", uuid) + //futureRefHostName, err := returnedService.GetHostname() + //if err != nil { + // return err + //} + //pyg.futureReferenceIndex[futureRefHostName] = fmt.Sprintf("{{ kurtosis.%v.hostname }}", uuid) + // + //var regErr error + //serviceName, regErr := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) + //if regErr != nil { + // return startosis_errors.WrapWithInterpretationError(regErr, "Unable to extract value for '%s' argument", add_service.ServiceNameArgName) + //} + //service.Name = pyg.swapFutureReference(serviceName.GoString()) // swap future references in the strings + // + //starlarkServiceConfig, regErr := builtin_argument.ExtractArgumentValue[*service_config.ServiceConfig](arguments, add_service.ServiceConfigArgName) + //if regErr != nil { + // return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", add_service.ServiceConfigArgName) + //} + //serviceConfig, serviceConfigErr := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? // TODO: add this error back in + // pyg.serviceNetwork, + // kurtosisInstruction.GetPositionInOriginalScript().GetFilename(), + // pyg.planYaml.PackageId, + // pyg.packageContentProvider, + // pyg.packageReplaceOptions) + //if serviceConfigErr != nil { + // return serviceConfigErr + //} + // + //// get image info + //rawImageAttrValue, _, interpretationErr := kurtosis_type_constructor.ExtractAttrValue[starlark.Value](starlarkServiceConfig.KurtosisValueTypeDefault, service_config.ImageAttr) + //if interpretationErr != nil { + // return interpretationErr + //} + //image := &ImageSpec{ //nolint:exhaustruct + // ImageName: serviceConfig.GetContainerImageName(), + //} + //imageBuildSpec := serviceConfig.GetImageBuildSpec() + //if imageBuildSpec != nil { + // switch img := rawImageAttrValue.(type) { + // case *service_config.ImageBuildSpec: + // contextLocator, err := img.GetBuildContextLocator() + // if err != nil { + // return err + // } + // image.BuildContextLocator = contextLocator + // } + // image.TargetStage = imageBuildSpec.GetTargetStage() + //} + //imageSpec := serviceConfig.GetImageRegistrySpec() + //if imageSpec != nil { + // image.Registry = imageSpec.GetRegistryAddr() + //} + //service.Image = image + // + //// detect future references + //cmdArgs := []string{} + //for _, cmdArg := range serviceConfig.GetCmdArgs() { + // realCmdArg := pyg.swapFutureReference(cmdArg) + // cmdArgs = append(cmdArgs, realCmdArg) + //} + //service.Cmd = cmdArgs + // + //entryArgs := []string{} + //for _, entryArg := range serviceConfig.GetEntrypointArgs() { + // realEntryArg := pyg.swapFutureReference(entryArg) + // entryArgs = append(entryArgs, realEntryArg) + //} + //service.Entrypoint = entryArgs + // + //// ports + //service.Ports = []*Port{} + //for portName, configPort := range serviceConfig.GetPrivatePorts() { // TODO: support public ports + // + // port := &Port{ //nolint:exhaustruct + // TransportProtocol: TransportProtocol(configPort.GetTransportProtocol().String()), + // Name: portName, + // Number: configPort.GetNumber(), + // } + // if configPort.GetMaybeApplicationProtocol() != nil { + // port.ApplicationProtocol = ApplicationProtocol(*configPort.GetMaybeApplicationProtocol()) + // } + // + // service.Ports = append(service.Ports, port) + //} + // + //// env vars + //service.EnvVars = []*EnvironmentVariable{} + //for key, val := range serviceConfig.GetEnvVars() { + // // detect and future references + // value := pyg.swapFutureReference(val) + // envVar := &EnvironmentVariable{ + // Key: key, + // Value: value, + // } + // service.EnvVars = append(service.EnvVars, envVar) + //} + // + //// file mounts have two cases: + //// 1. the referenced files artifact already exists in the plan, in which case add the referenced files artifact + //// 2. the referenced files artifact does not already exist in the plan, in which case the file MUST have been passed in via a top level arg OR is invalid + //// in this case, + //// - create new files artifact + //// - add it to the service's file mount accordingly + //// - add the files artifact to the plan + //service.Files = []*FileMount{} + //serviceFilesArtifactExpansions := serviceConfig.GetFilesArtifactsExpansion() + //if serviceFilesArtifactExpansions != nil { + // for mountPath, artifactIdentifiers := range serviceFilesArtifactExpansions.ServiceDirpathsToArtifactIdentifiers { + // fileMount := &FileMount{ //nolint:exhaustruct + // MountPath: mountPath, + // } + // + // var serviceFilesArtifacts []*FilesArtifact + // for _, identifier := range artifactIdentifiers { + // var filesArtifact *FilesArtifact + // // if there's already a files artifact that exists with this name from a previous instruction, reference that + // if potentialFilesArtifact, ok := pyg.filesArtifactIndex[identifier]; ok { + // filesArtifact = &FilesArtifact{ //nolint:exhaustruct + // Name: potentialFilesArtifact.Name, + // Uuid: potentialFilesArtifact.Uuid, + // } + // } else { + // // otherwise create a new one + // // the only information we have about a files artifact that didn't already exist is the name + // // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args + // filesArtifact = &FilesArtifact{ //nolint:exhaustruct + // Name: identifier, + // Uuid: strconv.Itoa(pyg.generateUuid()), + // } + // pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) + // pyg.filesArtifactIndex[identifier] = filesArtifact + // } + // serviceFilesArtifacts = append(serviceFilesArtifacts, filesArtifact) + // } + // + // fileMount.FilesArtifacts = serviceFilesArtifacts + // service.Files = append(service.Files, fileMount) + // } + // + //} + // + //pyg.planYaml.Services = append(pyg.planYaml.Services, service) + //pyg.serviceIndex[service.Name] = service + + return stacktrace.NewError("IMPLEMENT ME") } func (builtin *AddServiceCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go index 65cddd2b68..13adb72091 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go @@ -12,6 +12,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" @@ -363,6 +364,10 @@ func (builtin *AddServicesCapabilities) allServicesReadinessCheck( return failedServiceChecksRegularMap } +func (builtin *AddServicesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *AddServicesCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go index 0795e5fbf2..2bfa7b5fa1 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go @@ -11,6 +11,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/recipe" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" @@ -194,6 +195,10 @@ func (builtin *ExecCapabilities) FillPersistableAttributes(builder *enclave_plan builder.SetType(ExecBuiltinName) } +func (builtin *ExecCapabilities) UpdatePlan(planYaml *plan_yaml.PlanYaml) error { + return nil +} + func (builtin *ExecCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/get_service/get_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/get_service/get_service.go index e0fbd26613..cb27678a24 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/get_service/get_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/get_service/get_service.go @@ -10,6 +10,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" "go.starlark.net/starlark" @@ -102,6 +103,10 @@ func (builtin *GetServiceCapabilities) FillPersistableAttributes(builder *enclav builder.SetType(GetServiceBuiltinName).AddServiceName(builtin.serviceName) } +func (builtin *GetServiceCapabilities) UpdatePlan(planYaml *plan_yaml.PlanYaml) error { + return nil +} + func (builtin *GetServiceCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_print/kurtosis_print.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_print/kurtosis_print.go index 88c33b4921..95f8a930ea 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_print/kurtosis_print.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_print/kurtosis_print.go @@ -9,6 +9,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" @@ -105,6 +106,10 @@ func (builtin *PrintCapabilities) FillPersistableAttributes(builder *enclave_pla builder.SetType(PrintBuiltinName) } +func (builitin *PrintCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *PrintCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/mock_instruction/mock_kurtosis_instruction.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/mock_instruction/mock_kurtosis_instruction.go index 8dd95447f0..6d22f66a9c 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/mock_instruction/mock_kurtosis_instruction.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/mock_instruction/mock_kurtosis_instruction.go @@ -17,6 +17,8 @@ import ( mock "github.com/stretchr/testify/mock" + plan_yaml "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" + startosis_validator "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" ) @@ -344,6 +346,48 @@ func (_c *MockKurtosisInstruction_TryResolveWith_Call) RunAndReturn(run func(*en return _c } +// UpdatePlan provides a mock function with given fields: plan +func (_m *MockKurtosisInstruction) UpdatePlan(plan *plan_yaml.PlanYaml) error { + ret := _m.Called(plan) + + var r0 error + if rf, ok := ret.Get(0).(func(*plan_yaml.PlanYaml) error); ok { + r0 = rf(plan) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockKurtosisInstruction_UpdatePlan_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdatePlan' +type MockKurtosisInstruction_UpdatePlan_Call struct { + *mock.Call +} + +// UpdatePlan is a helper method to define mock.On call +// - plan *plan_yaml.PlanYaml +func (_e *MockKurtosisInstruction_Expecter) UpdatePlan(plan interface{}) *MockKurtosisInstruction_UpdatePlan_Call { + return &MockKurtosisInstruction_UpdatePlan_Call{Call: _e.mock.On("UpdatePlan", plan)} +} + +func (_c *MockKurtosisInstruction_UpdatePlan_Call) Run(run func(plan *plan_yaml.PlanYaml)) *MockKurtosisInstruction_UpdatePlan_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*plan_yaml.PlanYaml)) + }) + return _c +} + +func (_c *MockKurtosisInstruction_UpdatePlan_Call) Return(_a0 error) *MockKurtosisInstruction_UpdatePlan_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockKurtosisInstruction_UpdatePlan_Call) RunAndReturn(run func(*plan_yaml.PlanYaml) error) *MockKurtosisInstruction_UpdatePlan_Call { + _c.Call.Return(run) + return _c +} + // ValidateAndUpdateEnvironment provides a mock function with given fields: environment func (_m *MockKurtosisInstruction) ValidateAndUpdateEnvironment(environment *startosis_validator.ValidatorEnvironment) error { ret := _m.Called(environment) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go index 89f9706fe1..3952075ba6 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go @@ -10,6 +10,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" "github.com/kurtosis-tech/stacktrace" @@ -106,6 +107,10 @@ func (builtin *RemoveServiceCapabilities) FillPersistableAttributes(builder *enc ) } +func (builitin *RemoveServiceCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *RemoveServiceCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go index f25fdb7778..b8f268d0f9 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go @@ -12,6 +12,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" @@ -173,6 +174,10 @@ func (builtin *RenderTemplatesCapabilities) FillPersistableAttributes(builder *e ) } +func (builitin *RenderTemplatesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *RenderTemplatesCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go index b4d9994fee..39a2939be6 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go @@ -11,6 +11,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/recipe" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" @@ -207,6 +208,10 @@ func (builtin *RequestCapabilities) FillPersistableAttributes(builder *enclave_p builder.SetType(RequestBuiltinName) } +func (builtin *RequestCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *RequestCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/start_service/start_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/start_service/start_service.go index 63e20730d0..2875f11294 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/start_service/start_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/start_service/start_service.go @@ -10,6 +10,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" "github.com/kurtosis-tech/stacktrace" @@ -106,6 +107,10 @@ func (builtin *StartServiceCapabilities) FillPersistableAttributes(builder *encl ) } +func (builtin *StartServiceCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *StartServiceCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/stop_service/stop_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/stop_service/stop_service.go index e046816ea9..da7fe6cff7 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/stop_service/stop_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/stop_service/stop_service.go @@ -10,6 +10,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" "github.com/kurtosis-tech/stacktrace" @@ -106,6 +107,10 @@ func (builtin *StopServiceCapabilities) FillPersistableAttributes(builder *encla ) } +func (builtin *StopServiceCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *StopServiceCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files/store_service_files.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files/store_service_files.go index 8896c4a650..fb966688c3 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files/store_service_files.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files/store_service_files.go @@ -10,6 +10,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" "github.com/kurtosis-tech/stacktrace" @@ -179,6 +180,10 @@ func (builtin *StoreServiceFilesCapabilities) FillPersistableAttributes(builder ) } +func (builtin *StoreServiceFilesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *StoreServiceFilesCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go index 7669dde41f..50e86d32a9 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go @@ -16,6 +16,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" @@ -333,6 +334,10 @@ func (builtin *RunPythonCapabilities) FillPersistableAttributes(builder *enclave builder.SetType(RunPythonBuiltinName) } +func (builtin *RunPythonCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *RunPythonCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go index 13658e7f4d..d2ef7c2b9f 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go @@ -15,6 +15,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" @@ -282,6 +283,10 @@ func (builtin *RunShCapabilities) FillPersistableAttributes(builder *enclave_pla builder.SetType(RunShBuiltinName) } +func (builtin *RunShCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *RunShCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go index 65a59c8700..dcaccd0b50 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go @@ -10,6 +10,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" @@ -218,6 +219,10 @@ func (builtin *UploadFilesCapabilities) FillPersistableAttributes(builder *encla ) } +func (builtin *UploadFilesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *UploadFilesCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify.go index 36f51c7a83..9aee900744 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify.go @@ -9,6 +9,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" @@ -160,6 +161,10 @@ func (builtin *VerifyCapabilities) FillPersistableAttributes(builder *enclave_pl builder.SetType(VerifyBuiltinName) } +func (builtin *VerifyCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *VerifyCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go index 7cce2e4a83..8c6039d551 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go @@ -12,6 +12,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/recipe" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" @@ -293,6 +294,10 @@ func (builtin *WaitCapabilities) FillPersistableAttributes(builder *enclave_plan builder.SetType(WaitBuiltinName) } +func (builtin *WaitCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return stacktrace.NewError("IMPLEMENT ME") +} + func (builtin *WaitCapabilities) Description() string { return builtin.description } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction/kurtosis_plan_instruction_capabilities.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction/kurtosis_plan_instruction_capabilities.go index 66ca407c64..5037f15fad 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction/kurtosis_plan_instruction_capabilities.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction/kurtosis_plan_instruction_capabilities.go @@ -5,6 +5,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_plan_persistence" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_structure" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" "go.starlark.net/starlark" @@ -25,4 +26,7 @@ type KurtosisPlanInstructionCapabilities interface { // Description Brief description of the instruction based on its contents Description() string + + // UpdatePlan applies the effect of this instruction capabilities onto the yaml representation of the instruction plan. + UpdatePlan(plan *plan_yaml.PlanYaml) error } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction/kurtosis_plan_instruction_internal.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction/kurtosis_plan_instruction_internal.go index e05a718083..968181cb55 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction/kurtosis_plan_instruction_internal.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction/kurtosis_plan_instruction_internal.go @@ -8,6 +8,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_structure" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" "go.starlark.net/starlark" @@ -97,6 +98,10 @@ func (builtin *kurtosisPlanInstructionInternal) GetPersistableAttributes() *encl return enclavePlaneInstructionBuilder.SetStarlarkCode(builtin.String()) } +func (builtin *kurtosisPlanInstructionInternal) UpdatePlan(plan *plan_yaml.PlanYaml) error { + return builtin.capabilities.UpdatePlan(plan) +} + func (builtin *kurtosisPlanInstructionInternal) interpret() (starlark.Value, *startosis_errors.InterpretationError) { result, interpretationErr := builtin.capabilities.Interpret(builtin.GetPosition().GetFilename(), builtin.GetArguments()) if interpretationErr != nil { diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index 610b8e85f4..553e4aef7a 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -14,13 +14,12 @@ const ( EXEC TaskType = "exec" ) -// TODO: there's really no point in making any of these references, consider just making them copies -// PlanYaml is a representation of the state of an enclave. - +// PlanYaml is a yaml representation of the effect of an "plan" or sequence of instructions on the state of the Enclave. type PlanYaml struct { privatePlanYaml *privatePlanYaml } +// TODO: pass by value instead of pass by reference type privatePlanYaml struct { PackageId string `yaml:"packageId,omitempty"` Services []*Service `yaml:"services,omitempty"` From 76da141d09dfaac9cbcb1348bc67342b32375ec2 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 8 Mar 2024 15:33:50 -0500 Subject: [PATCH 54/75] refactor add service --- .../add_service/add_service.go | 183 ++--------------- .../startosis_engine/plan_yaml/plan_yaml.go | 184 +++++++++++++++++- 2 files changed, 199 insertions(+), 168 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go index b6e79237c8..9e7e571822 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go @@ -11,6 +11,8 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_type_constructor" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" @@ -104,10 +106,12 @@ type AddServiceCapabilities struct { packageId string packageContentProvider startosis_packages.PackageContentProvider packageReplaceOptions map[string]string + imageType starlark.Value interpretationTimeValueStore *interpretation_time_value_store.InterpretationTimeValueStore resultUuid string + returnValue *kurtosis_types.Service description string } @@ -121,6 +125,11 @@ func (builtin *AddServiceCapabilities) Interpret(locatorOfModuleInWhichThisBuilt if err != nil { return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", ServiceConfigArgName) } + rawImageVal, _, err := kurtosis_type_constructor.ExtractAttrValue[starlark.Value](serviceConfig.KurtosisValueTypeDefault, service_config.ImageAttr) + if err != nil { + return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract raw image attribute.") + } + builtin.imageType = rawImageVal apiServiceConfig, readyCondition, interpretationErr := validateAndConvertConfigAndReadyCondition( builtin.serviceNetwork, serviceConfig, @@ -143,16 +152,16 @@ func (builtin *AddServiceCapabilities) Interpret(locatorOfModuleInWhichThisBuilt builtin.description = builtin_argument.GetDescriptionOrFallBack(arguments, fmt.Sprintf(addServiceDescriptionFormatStr, builtin.serviceName, builtin.serviceConfig.GetContainerImageName())) - returnValue, interpretationErr := makeAddServiceInterpretationReturnValue(serviceName, builtin.serviceConfig, builtin.resultUuid) + builtin.returnValue, interpretationErr = makeAddServiceInterpretationReturnValue(serviceName, builtin.serviceConfig, builtin.resultUuid) if interpretationErr != nil { return nil, interpretationErr } - err = builtin.interpretationTimeValueStore.PutService(builtin.serviceName, returnValue) + err = builtin.interpretationTimeValueStore.PutService(builtin.serviceName, builtin.returnValue) if err != nil { return nil, startosis_errors.WrapWithInterpretationError(err, "An error occurred while persisting return value for service '%v'", serviceName) } - return returnValue, nil + return builtin.returnValue, nil } func (builtin *AddServiceCapabilities) Validate(_ *builtin_argument.ArgumentValuesSet, validatorEnvironment *startosis_validator.ValidatorEnvironment) *startosis_errors.ValidationError { @@ -250,169 +259,11 @@ func (builtin *AddServiceCapabilities) FillPersistableAttributes(builder *enclav } func (builtin *AddServiceCapabilities) UpdatePlan(planYaml *plan_yaml.PlanYaml) error { - //kurtosisInstruction := addServiceInstruction.GetInstruction() - //arguments := kurtosisInstruction.GetArguments() - // - //// start building Service Yaml object - //service := &Service{} //nolint:exhaustruct - //uuid := pyg.generateUuid() - //service.Uuid = strconv.Itoa(uuid) - // - //// store future references of this service - //returnValue := addServiceInstruction.GetReturnedValue() - //returnedService, ok := returnValue.(*kurtosis_types.Service) - //if !ok { - // return stacktrace.NewError("Cast to service didn't work") - //} - //futureRefIPAddress, err := returnedService.GetIpAddress() - //if err != nil { - // return err - //} - //pyg.futureReferenceIndex[futureRefIPAddress] = fmt.Sprintf("{{ kurtosis.%v.ip_address }}", uuid) - //futureRefHostName, err := returnedService.GetHostname() - //if err != nil { - // return err - //} - //pyg.futureReferenceIndex[futureRefHostName] = fmt.Sprintf("{{ kurtosis.%v.hostname }}", uuid) - // - //var regErr error - //serviceName, regErr := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) - //if regErr != nil { - // return startosis_errors.WrapWithInterpretationError(regErr, "Unable to extract value for '%s' argument", add_service.ServiceNameArgName) - //} - //service.Name = pyg.swapFutureReference(serviceName.GoString()) // swap future references in the strings - // - //starlarkServiceConfig, regErr := builtin_argument.ExtractArgumentValue[*service_config.ServiceConfig](arguments, add_service.ServiceConfigArgName) - //if regErr != nil { - // return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", add_service.ServiceConfigArgName) - //} - //serviceConfig, serviceConfigErr := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? // TODO: add this error back in - // pyg.serviceNetwork, - // kurtosisInstruction.GetPositionInOriginalScript().GetFilename(), - // pyg.planYaml.PackageId, - // pyg.packageContentProvider, - // pyg.packageReplaceOptions) - //if serviceConfigErr != nil { - // return serviceConfigErr - //} - // - //// get image info - //rawImageAttrValue, _, interpretationErr := kurtosis_type_constructor.ExtractAttrValue[starlark.Value](starlarkServiceConfig.KurtosisValueTypeDefault, service_config.ImageAttr) - //if interpretationErr != nil { - // return interpretationErr - //} - //image := &ImageSpec{ //nolint:exhaustruct - // ImageName: serviceConfig.GetContainerImageName(), - //} - //imageBuildSpec := serviceConfig.GetImageBuildSpec() - //if imageBuildSpec != nil { - // switch img := rawImageAttrValue.(type) { - // case *service_config.ImageBuildSpec: - // contextLocator, err := img.GetBuildContextLocator() - // if err != nil { - // return err - // } - // image.BuildContextLocator = contextLocator - // } - // image.TargetStage = imageBuildSpec.GetTargetStage() - //} - //imageSpec := serviceConfig.GetImageRegistrySpec() - //if imageSpec != nil { - // image.Registry = imageSpec.GetRegistryAddr() - //} - //service.Image = image - // - //// detect future references - //cmdArgs := []string{} - //for _, cmdArg := range serviceConfig.GetCmdArgs() { - // realCmdArg := pyg.swapFutureReference(cmdArg) - // cmdArgs = append(cmdArgs, realCmdArg) - //} - //service.Cmd = cmdArgs - // - //entryArgs := []string{} - //for _, entryArg := range serviceConfig.GetEntrypointArgs() { - // realEntryArg := pyg.swapFutureReference(entryArg) - // entryArgs = append(entryArgs, realEntryArg) - //} - //service.Entrypoint = entryArgs - // - //// ports - //service.Ports = []*Port{} - //for portName, configPort := range serviceConfig.GetPrivatePorts() { // TODO: support public ports - // - // port := &Port{ //nolint:exhaustruct - // TransportProtocol: TransportProtocol(configPort.GetTransportProtocol().String()), - // Name: portName, - // Number: configPort.GetNumber(), - // } - // if configPort.GetMaybeApplicationProtocol() != nil { - // port.ApplicationProtocol = ApplicationProtocol(*configPort.GetMaybeApplicationProtocol()) - // } - // - // service.Ports = append(service.Ports, port) - //} - // - //// env vars - //service.EnvVars = []*EnvironmentVariable{} - //for key, val := range serviceConfig.GetEnvVars() { - // // detect and future references - // value := pyg.swapFutureReference(val) - // envVar := &EnvironmentVariable{ - // Key: key, - // Value: value, - // } - // service.EnvVars = append(service.EnvVars, envVar) - //} - // - //// file mounts have two cases: - //// 1. the referenced files artifact already exists in the plan, in which case add the referenced files artifact - //// 2. the referenced files artifact does not already exist in the plan, in which case the file MUST have been passed in via a top level arg OR is invalid - //// in this case, - //// - create new files artifact - //// - add it to the service's file mount accordingly - //// - add the files artifact to the plan - //service.Files = []*FileMount{} - //serviceFilesArtifactExpansions := serviceConfig.GetFilesArtifactsExpansion() - //if serviceFilesArtifactExpansions != nil { - // for mountPath, artifactIdentifiers := range serviceFilesArtifactExpansions.ServiceDirpathsToArtifactIdentifiers { - // fileMount := &FileMount{ //nolint:exhaustruct - // MountPath: mountPath, - // } - // - // var serviceFilesArtifacts []*FilesArtifact - // for _, identifier := range artifactIdentifiers { - // var filesArtifact *FilesArtifact - // // if there's already a files artifact that exists with this name from a previous instruction, reference that - // if potentialFilesArtifact, ok := pyg.filesArtifactIndex[identifier]; ok { - // filesArtifact = &FilesArtifact{ //nolint:exhaustruct - // Name: potentialFilesArtifact.Name, - // Uuid: potentialFilesArtifact.Uuid, - // } - // } else { - // // otherwise create a new one - // // the only information we have about a files artifact that didn't already exist is the name - // // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - // filesArtifact = &FilesArtifact{ //nolint:exhaustruct - // Name: identifier, - // Uuid: strconv.Itoa(pyg.generateUuid()), - // } - // pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) - // pyg.filesArtifactIndex[identifier] = filesArtifact - // } - // serviceFilesArtifacts = append(serviceFilesArtifacts, filesArtifact) - // } - // - // fileMount.FilesArtifacts = serviceFilesArtifacts - // service.Files = append(service.Files, fileMount) - // } - // - //} - // - //pyg.planYaml.Services = append(pyg.planYaml.Services, service) - //pyg.serviceIndex[service.Name] = service - - return stacktrace.NewError("IMPLEMENT ME") + err := planYaml.AddService(builtin.serviceName, builtin.returnValue, builtin.serviceConfig, builtin.imageType) + if err != nil { + return stacktrace.NewError("An error occurred updating the plan with service: %v", builtin.serviceName) + } + return nil } func (builtin *AddServiceCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index 553e4aef7a..55e553cc5c 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -1,7 +1,15 @@ package plan_yaml import ( + "fmt" "github.com/go-yaml/yaml" + "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" + "github.com/kurtosis-tech/stacktrace" + "go.starlark.net/starlark" + "strconv" + "strings" ) const ( @@ -17,6 +25,11 @@ const ( // PlanYaml is a yaml representation of the effect of an "plan" or sequence of instructions on the state of the Enclave. type PlanYaml struct { privatePlanYaml *privatePlanYaml + + futureReferenceIndex map[string]string + filesArtifactIndex map[string]*FilesArtifact + serviceIndex map[string]*Service + latestUuid int } // TODO: pass by value instead of pass by reference @@ -120,10 +133,177 @@ func CreateEmptyPlan(packageId string) *PlanYaml { } } -func (pyg PlanYaml) GenerateYaml() (string, error) { - yamlBytes, err := yaml.Marshal(pyg.privatePlanYaml) +func (planYaml *PlanYaml) GenerateYaml() (string, error) { + yamlBytes, err := yaml.Marshal(planYaml.privatePlanYaml) if err != nil { return "", err } return string(yamlBytes), nil } + +func (planYaml *PlanYaml) AddService( + serviceName service.ServiceName, + serviceInfo *kurtosis_types.Service, + serviceConfig *service.ServiceConfig, + imageValue starlark.Value, +) error { + uuid := planYaml.generateUuid() + + // store future references of this service + ipAddrFutureRef, err := serviceInfo.GetIpAddress() + if err != nil { + return err + } + hostnameFutureRef, err := serviceInfo.GetHostname() + if err != nil { + return err + } + planYaml.storeFutureReference(uuid, ipAddrFutureRef, "ip_address") + planYaml.storeFutureReference(uuid, hostnameFutureRef, "hostname") + + // construct service yaml object for plan + serviceYaml := &Service{} + serviceYaml.Uuid = uuid + + serviceYaml.Name = planYaml.swapFutureReference(string(serviceName)) + + image := &ImageSpec{ //nolint:exhaustruct + ImageName: serviceConfig.GetContainerImageName(), + } + imageBuildSpec := serviceConfig.GetImageBuildSpec() + if imageBuildSpec != nil { + // Need the raw imageValue to get the build context locator + switch starlarkImgVal := imageValue.(type) { + case *service_config.ImageBuildSpec: + contextLocator, err := starlarkImgVal.GetBuildContextLocator() + if err != nil { + return err + } + image.BuildContextLocator = contextLocator + default: + return stacktrace.NewError("An image build spec was detected on the kurtosis type service config but the starlark image value was not an ImageBuildSpec type.") + } + image.TargetStage = imageBuildSpec.GetTargetStage() + } + imageSpec := serviceConfig.GetImageRegistrySpec() + if imageSpec != nil { + image.Registry = imageSpec.GetRegistryAddr() + } + serviceYaml.Image = image + + cmdArgs := []string{} + for _, cmdArg := range serviceConfig.GetCmdArgs() { + realCmdArg := planYaml.swapFutureReference(cmdArg) + cmdArgs = append(cmdArgs, realCmdArg) + } + serviceYaml.Cmd = cmdArgs + + entryArgs := []string{} + for _, entryArg := range serviceConfig.GetEntrypointArgs() { + realEntryArg := planYaml.swapFutureReference(entryArg) + entryArgs = append(entryArgs, realEntryArg) + } + serviceYaml.Entrypoint = entryArgs + + serviceYaml.Ports = []*Port{} + for portName, configPort := range serviceConfig.GetPrivatePorts() { // TODO: support public ports + var applicationProtocolStr string + if configPort.GetMaybeApplicationProtocol() != nil { + applicationProtocolStr = *configPort.GetMaybeApplicationProtocol() + } + port := &Port{ + TransportProtocol: TransportProtocol(configPort.GetTransportProtocol().String()), + ApplicationProtocol: ApplicationProtocol(applicationProtocolStr), // TODO: write a test for this, dereferencing config port is not a good idea + Name: portName, + Number: configPort.GetNumber(), + } + serviceYaml.Ports = append(serviceYaml.Ports, port) + } + + serviceYaml.EnvVars = []*EnvironmentVariable{} + for key, val := range serviceConfig.GetEnvVars() { + // detect and future references + envVar := &EnvironmentVariable{ + Key: key, + Value: planYaml.swapFutureReference(val), + } + serviceYaml.EnvVars = append(serviceYaml.EnvVars, envVar) + } + + // file mounts have two cases: + // 1. the referenced files artifact already exists in the plan, in which case add the referenced files artifact + // 2. the referenced files artifact does not already exist in the plan, in which case the file MUST have been passed in via a top level arg OR is invalid + // for this case, + // - create new files artifact + // - add it to the service's file mount accordingly + // - add the files artifact to the plan + serviceYaml.Files = []*FileMount{} + serviceFilesArtifactExpansions := serviceConfig.GetFilesArtifactsExpansion() + if serviceFilesArtifactExpansions != nil { + for mountPath, artifactIdentifiers := range serviceFilesArtifactExpansions.ServiceDirpathsToArtifactIdentifiers { + var serviceFilesArtifacts []*FilesArtifact + for _, identifier := range artifactIdentifiers { + var filesArtifact *FilesArtifact + // if there's already a files artifact that exists with this name from a previous instruction, reference that + if filesArtifactToReference, ok := planYaml.filesArtifactIndex[identifier]; ok { + filesArtifact = &FilesArtifact{ + Name: filesArtifactToReference.Name, + Uuid: filesArtifactToReference.Uuid, + Files: []string{}, // leave empty because this is a copy + } + } else { + // otherwise create a new one + // the only information we have about a files artifact that didn't already exist is the name + // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args of run function + filesArtifact = &FilesArtifact{ + Name: identifier, + Uuid: planYaml.generateUuid(), + Files: []string{}, // don't know what files are on the artifact if passed in via args + } + planYaml.addFilesArtifactYaml(filesArtifact) + } + serviceFilesArtifacts = append(serviceFilesArtifacts, filesArtifact) + } + + serviceYaml.Files = append(serviceYaml.Files, &FileMount{ + MountPath: mountPath, + FilesArtifacts: serviceFilesArtifacts, + }) + } + + } + + planYaml.addServiceYaml(serviceYaml) + return nil +} + +func (planYaml *PlanYaml) addServiceYaml(service *Service) { + planYaml.serviceIndex[service.Name] = service + planYaml.privatePlanYaml.Services = append(planYaml.privatePlanYaml.Services, service) +} + +func (planYaml *PlanYaml) addFilesArtifactYaml(filesArtifact *FilesArtifact) { + planYaml.filesArtifactIndex[] = filesArtifact + // do we need both map and list structures? what about just map then resolve at the end? + planYaml.privatePlanYaml.FilesArtifacts = append(planYaml.privatePlanYaml.FilesArtifacts, filesArtifact) +} + +func (planYaml *PlanYaml) storeFutureReference(uuid, futureReference, futureReferenceType string) { + planYaml.futureReferenceIndex[futureReference] = fmt.Sprintf("{{ kurtosis.%v.%v }}", uuid, futureReferenceType) +} + +// swapFutureReference replaces all future references in s, if any exist, with the value required for the yaml format +func (pyg *PlanYaml) swapFutureReference(s string) string { + swappedString := s + for futureRef, yamlFutureRef := range pyg.futureReferenceIndex { + if strings.Contains(s, futureRef) { + swappedString = strings.Replace(s, futureRef, yamlFutureRef, -1) // -1 to swap all instances of [futureRef] + } + } + return swappedString +} + +func (planYaml *PlanYaml) generateUuid() string { + planYaml.latestUuid++ + return strconv.Itoa(planYaml.latestUuid) +} From 6e1388bca33b662af2addbbc1b84a831a4b1e828 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Fri, 8 Mar 2024 18:01:24 -0500 Subject: [PATCH 55/75] add test --- .../startosis_engine/plan_yaml/plan_yaml.go | 42 +++++++------ .../plan_yaml_generator_test.go | 6 +- .../startosis_interpreter_plan_yaml_test.go | 60 +++++++++++++++---- 3 files changed, 71 insertions(+), 37 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index 55e553cc5c..e77a2979fd 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -5,8 +5,6 @@ import ( "github.com/go-yaml/yaml" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" - "github.com/kurtosis-tech/stacktrace" "go.starlark.net/starlark" "strconv" "strings" @@ -170,25 +168,25 @@ func (planYaml *PlanYaml) AddService( image := &ImageSpec{ //nolint:exhaustruct ImageName: serviceConfig.GetContainerImageName(), } - imageBuildSpec := serviceConfig.GetImageBuildSpec() - if imageBuildSpec != nil { - // Need the raw imageValue to get the build context locator - switch starlarkImgVal := imageValue.(type) { - case *service_config.ImageBuildSpec: - contextLocator, err := starlarkImgVal.GetBuildContextLocator() - if err != nil { - return err - } - image.BuildContextLocator = contextLocator - default: - return stacktrace.NewError("An image build spec was detected on the kurtosis type service config but the starlark image value was not an ImageBuildSpec type.") - } - image.TargetStage = imageBuildSpec.GetTargetStage() - } - imageSpec := serviceConfig.GetImageRegistrySpec() - if imageSpec != nil { - image.Registry = imageSpec.GetRegistryAddr() - } + //imageBuildSpec := serviceConfig.GetImageBuildSpec() + //if imageBuildSpec != nil { + // // Need the raw imageValue to get the build context locator + // switch starlarkImgVal := imageValue.(type) { + // case *service_config.ImageBuildSpec: // importing service_config.ImageBuildSpec causes a dependency issue figure that out later + // contextLocator, err := starlarkImgVal.GetBuildContextLocator() + // if err != nil { + // return err + // } + // image.BuildContextLocator = contextLocator + // default: + // return stacktrace.NewError("An image build spec was detected on the kurtosis type service config but the starlark image value was not an ImageBuildSpec type.") + // } + // image.TargetStage = imageBuildSpec.GetTargetStage() + //} + //imageSpec := serviceConfig.GetImageRegistrySpec() + //if imageSpec != nil { + // image.Registry = imageSpec.GetRegistryAddr() + //} serviceYaml.Image = image cmdArgs := []string{} @@ -283,7 +281,7 @@ func (planYaml *PlanYaml) addServiceYaml(service *Service) { } func (planYaml *PlanYaml) addFilesArtifactYaml(filesArtifact *FilesArtifact) { - planYaml.filesArtifactIndex[] = filesArtifact + planYaml.filesArtifactIndex[filesArtifact.Name] = filesArtifact // do we need both map and list structures? what about just map then resolve at the end? planYaml.privatePlanYaml.FilesArtifacts = append(planYaml.privatePlanYaml.FilesArtifacts, filesArtifact) } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 2f4ee3645a..fd9b2d7b2a 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -100,9 +100,9 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.runner = NewStartosisRunner(suite.interpreter, suite.validator, suite.executor) } -//func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { -// suite.Run(t, new(PlanYamlGeneratorTestSuite)) -//} +func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { + suite.Run(t, new(PlanYamlGeneratorTestSuite)) +} func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go index 4af4d5c5ee..da9bf5cee1 100644 --- a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go @@ -14,6 +14,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "testing" ) type StartosisIntepreterPlanYamlTestSuite struct { @@ -27,23 +28,24 @@ type StartosisIntepreterPlanYamlTestSuite struct { } func (suite *StartosisIntepreterPlanYamlTestSuite) SetupTest() { + // mock package content provider suite.packageContentProvider = mock_package_content_provider.NewMockPackageContentProvider() enclaveDb := getEnclaveDBForTest(suite.T()) dummySerde := shared_helpers.NewDummyStarlarkValueSerDeForTest() + // mock runtime value store runtimeValueStore, err := runtime_value_store.CreateRuntimeValueStore(dummySerde, enclaveDb) require.NoError(suite.T(), err) suite.runtimeValueStore = runtimeValueStore - suite.serviceNetwork = service_network.NewMockServiceNetwork(suite.T()) + // moc kinterpretation time value store interpretationTimeValueStore, err := interpretation_time_value_store.CreateInterpretationTimeValueStore(enclaveDb, dummySerde) require.NoError(suite.T(), err) suite.interpretationTimeValueStore = interpretationTimeValueStore - require.NotNil(suite.T(), interpretationTimeValueStore) - - suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "", suite.interpretationTimeValueStore) + // mock service network + suite.serviceNetwork = service_network.NewMockServiceNetwork(suite.T()) service.NewServiceRegistration( testServiceName, service.ServiceUUID(fmt.Sprintf("%s-%s", testServiceName, serviceUuidSuffix)), @@ -54,19 +56,20 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) SetupTest() { suite.serviceNetwork.EXPECT().GetUniqueNameForFileArtifact().Maybe().Return(mockFileArtifactName, nil) suite.serviceNetwork.EXPECT().GetEnclaveUuid().Maybe().Return(enclave.EnclaveUUID(mockEnclaveUuid)) suite.serviceNetwork.EXPECT().ExistServiceRegistration(testServiceName).Maybe().Return(true, nil) + + suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "", suite.interpretationTimeValueStore) } -//func TestRunStartosisIntepreterPlanYamlTestSuite(t *testing.T) { -// suite.Run(t, new(StartosisIntepreterPlanYamlTestSuite)) -//} +func TestRunStartosisIntepreterPlanYamlTestSuite(t *testing.T) { + suite.Run(t, new(StartosisIntepreterPlanYamlTestSuite)) +} func (suite *StartosisIntepreterPlanYamlTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() } func (suite *StartosisIntepreterPlanYamlTestSuite) TestAddService() { - script := ` -def run(plan): + script := `def run(plan, args): service_name = "serviceA" config = ServiceConfig( image = "` + testContainerImageName + `", @@ -77,12 +80,20 @@ def run(plan): datastore_service = plan.add_service(name = service_name, config = config) ` - _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, useDefaultMainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, script, startosis_constants.EmptyInputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) + _, instructionsPlan, interpretationError := suite.interpreter.Interpret( + context.Background(), + startosis_constants.PackageIdPlaceholderForStandaloneScript, + useDefaultMainFunctionName, + noPackageReplaceOptions, + startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, + script, startosis_constants.EmptyInputArgs, + defaultNonBlockingMode, + emptyEnclaveComponents, + emptyInstructionsPlanMask) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 1, instructionsPlan.Size()) - emptyPlanYaml := plan_yaml.CreateEmptyPlan(startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript) - planYaml, err := instructionsPlan.GenerateYaml(emptyPlanYaml) + planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript)) require.NoError(suite.T(), err) expectedYaml := @@ -98,3 +109,28 @@ services: ` require.Equal(suite.T(), expectedYaml, planYaml) } + +func (suite *StartosisIntepreterPlanYamlTestSuite) TestStartosisInterpreterPlanYaml_AddService() { + serializedScript := `def run(plan, args): + plan.add_service(name="tedi", config=ServiceConfig(image="postgres:latest")) +` + _, instructionsPlan, interpretationError := suite.interpreter.Interpret( + context.Background(), + startosis_constants.PackageIdPlaceholderForStandaloneScript, + useDefaultMainFunctionName, + noPackageReplaceOptions, + startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, + serializedScript, + startosis_constants.EmptyInputArgs, + defaultNonBlockingMode, + emptyEnclaveComponents, + emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 1, instructionsPlan.Size()) + + planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript)) + require.NoError(suite.T(), err) + + expectedOutput := "" + require.Equal(suite.T(), planYaml, expectedOutput) +} From 306f625e939ed6645b2486149d01c03f206a24cb Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Sat, 9 Mar 2024 13:31:16 -0500 Subject: [PATCH 56/75] test add service --- .../add_service/add_service.go | 11 +- .../startosis_engine/plan_yaml/plan_yaml.go | 12 +- .../plan_yaml_generator_test.go | 4 +- .../startosis_interpreter_plan_yaml_test.go | 104 +++++++++++++++--- 4 files changed, 102 insertions(+), 29 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go index 9e7e571822..d743241228 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go @@ -11,7 +11,6 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_type_constructor" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" @@ -125,11 +124,11 @@ func (builtin *AddServiceCapabilities) Interpret(locatorOfModuleInWhichThisBuilt if err != nil { return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", ServiceConfigArgName) } - rawImageVal, _, err := kurtosis_type_constructor.ExtractAttrValue[starlark.Value](serviceConfig.KurtosisValueTypeDefault, service_config.ImageAttr) - if err != nil { - return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract raw image attribute.") - } - builtin.imageType = rawImageVal + ////rawImageVal, _, err := kurtosis_type_constructor.ExtractAttrValue[starlark.Value](serviceConfig.KurtosisValueTypeDefault, service_config.ImageAttr) + ////if err != nil { + //// return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract raw image attribute.") + ////} + //builtin.imageType = rawImageVal apiServiceConfig, readyCondition, interpretationErr := validateAndConvertConfigAndReadyCondition( builtin.serviceNetwork, serviceConfig, diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index e77a2979fd..09e0db1a35 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -128,6 +128,9 @@ func CreateEmptyPlan(packageId string) *PlanYaml { Tasks: []*Task{}, FilesArtifacts: []*FilesArtifact{}, }, + serviceIndex: map[string]*Service{}, + futureReferenceIndex: map[string]string{}, + filesArtifactIndex: map[string]*FilesArtifact{}, } } @@ -220,7 +223,6 @@ func (planYaml *PlanYaml) AddService( serviceYaml.EnvVars = []*EnvironmentVariable{} for key, val := range serviceConfig.GetEnvVars() { - // detect and future references envVar := &EnvironmentVariable{ Key: key, Value: planYaml.swapFutureReference(val), @@ -247,7 +249,7 @@ func (planYaml *PlanYaml) AddService( filesArtifact = &FilesArtifact{ Name: filesArtifactToReference.Name, Uuid: filesArtifactToReference.Uuid, - Files: []string{}, // leave empty because this is a copy + Files: []string{}, // leave empty because this is referencing an existing files artifact } } else { // otherwise create a new one @@ -256,7 +258,7 @@ func (planYaml *PlanYaml) AddService( filesArtifact = &FilesArtifact{ Name: identifier, Uuid: planYaml.generateUuid(), - Files: []string{}, // don't know what files are on the artifact if passed in via args + Files: []string{}, // don't know at interpretation what files are on the artifact when passed in via args } planYaml.addFilesArtifactYaml(filesArtifact) } @@ -291,9 +293,9 @@ func (planYaml *PlanYaml) storeFutureReference(uuid, futureReference, futureRefe } // swapFutureReference replaces all future references in s, if any exist, with the value required for the yaml format -func (pyg *PlanYaml) swapFutureReference(s string) string { +func (planYaml *PlanYaml) swapFutureReference(s string) string { swappedString := s - for futureRef, yamlFutureRef := range pyg.futureReferenceIndex { + for futureRef, yamlFutureRef := range planYaml.futureReferenceIndex { if strings.Contains(s, futureRef) { swappedString = strings.Replace(s, futureRef, yamlFutureRef, -1) // -1 to swap all instances of [futureRef] } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index fd9b2d7b2a..efe39a9d29 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -68,8 +68,8 @@ func (suite *PlanYamlGeneratorTestSuite) SetupTest() { suite.serviceNetwork.EXPECT().ExistServiceRegistration(testServiceName).Maybe().Return(true, nil) apiContainerInfo := service_network.NewApiContainerInfo( net.IP{}, - 51243, - "134123") + mockApicPortNum, + mockApicVersion) suite.serviceNetwork.EXPECT().GetApiContainerInfo().Return(apiContainerInfo) suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "", suite.interpretationTimeValueStore) diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go index da9bf5cee1..654fd65760 100644 --- a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go @@ -14,9 +14,15 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "net" "testing" ) +const ( + mockApicPortNum = 1234 + mockApicVersion = "1234" +) + type StartosisIntepreterPlanYamlTestSuite struct { suite.Suite serviceNetwork *service_network.MockServiceNetwork @@ -39,7 +45,7 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) SetupTest() { require.NoError(suite.T(), err) suite.runtimeValueStore = runtimeValueStore - // moc kinterpretation time value store + // mock interpretation time value store interpretationTimeValueStore, err := interpretation_time_value_store.CreateInterpretationTimeValueStore(enclaveDb, dummySerde) require.NoError(suite.T(), err) suite.interpretationTimeValueStore = interpretationTimeValueStore @@ -56,6 +62,11 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) SetupTest() { suite.serviceNetwork.EXPECT().GetUniqueNameForFileArtifact().Maybe().Return(mockFileArtifactName, nil) suite.serviceNetwork.EXPECT().GetEnclaveUuid().Maybe().Return(enclave.EnclaveUUID(mockEnclaveUuid)) suite.serviceNetwork.EXPECT().ExistServiceRegistration(testServiceName).Maybe().Return(true, nil) + apiContainerInfo := service_network.NewApiContainerInfo( + net.IP{}, + mockApicPortNum, + mockApicVersion) + suite.serviceNetwork.EXPECT().GetApiContainerInfo().Return(apiContainerInfo) suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "", suite.interpretationTimeValueStore) } @@ -68,69 +79,130 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() } -func (suite *StartosisIntepreterPlanYamlTestSuite) TestAddService() { - script := `def run(plan, args): +func (suite *StartosisIntepreterPlanYamlTestSuite) TestAddServiceWithFilesArtifact() { + script := `def run(plan, hi_files_artifact): service_name = "serviceA" config = ServiceConfig( image = "` + testContainerImageName + `", + cmd = ["echo", "Hi"], + entrypoint = ["sudo", "something"], + env_vars = { + "USERNAME": "KURTOSIS" + }, ports = { "grpc": PortSpec(number = 1234, transport_protocol = "TCP", application_protocol = "http") }, + files = { + "hi.txt": hi_files_artifact, + }, ) datastore_service = plan.add_service(name = service_name, config = config) ` - + inputArgs := `{"hi_files_artifact": "hi-file"}` _, instructionsPlan, interpretationError := suite.interpreter.Interpret( context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, useDefaultMainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, - script, startosis_constants.EmptyInputArgs, + script, + inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 1, instructionsPlan.Size()) - planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript)) + planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) require.NoError(suite.T(), err) expectedYaml := `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT services: -- name: serviceA - image: ` + testContainerImageName + ` +- uuid: "1" + name: serviceA + image: + name: ` + testContainerImageName + ` + command: + - echo + - Hi + entrypoint: + - sudo + - something + envVars: + - key: USERNAME + value: KURTOSIS ports: - name: grpc number: 1234 transportProtocol: TCP applicationProtocol: http + files: + - mountPath: hi.txt + filesArtifacts: + - uuid: "2" + name: hi-file +filesArtifacts: +- uuid: "2" + name: hi-file ` require.Equal(suite.T(), expectedYaml, planYaml) } -func (suite *StartosisIntepreterPlanYamlTestSuite) TestStartosisInterpreterPlanYaml_AddService() { - serializedScript := `def run(plan, args): - plan.add_service(name="tedi", config=ServiceConfig(image="postgres:latest")) +func (suite *StartosisIntepreterPlanYamlTestSuite) TestRunShWithFilesArtifacts() { + script := `def run(plan, hi_files_artifact): + plan.run_sh( + run="echo bye > /bye.txt", + env_vars = { + "HELLO": "Hello!" + }, + files = { + "/hi.txt": hi_files_artifact, + }, + store=[ + StoreSpec(src="/bye.txt", name="bye-file") + ] + ) ` + inputArgs := `{"hi_files_artifact": "hi-file"}` _, instructionsPlan, interpretationError := suite.interpreter.Interpret( context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, useDefaultMainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, - serializedScript, - startosis_constants.EmptyInputArgs, + script, + inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 1, instructionsPlan.Size()) - planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript)) + planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) require.NoError(suite.T(), err) - expectedOutput := "" - require.Equal(suite.T(), planYaml, expectedOutput) + expectedYaml := + `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT +tasks: +- uuid: "1" + run: echo bye > /bye.txt + image: bq/jcurl + envVars: + - key: HELLO + value: Hello! + files: + - mountPath: /hi.txt + filesArtifacts: + - uuid: "2" + name: hi-file +filesArtifacts: +- uuid: "2" + name: hi-file +- uuid: "3" + name: bye-file + files: + - bye.txt +` + require.Equal(suite.T(), expectedYaml, planYaml) } From 3c0c5783217ff1a3eb2bd1ecb91ddc7886155289 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Sat, 9 Mar 2024 14:04:53 -0500 Subject: [PATCH 57/75] add run sh --- .../kurtosis_instruction/tasks/run_sh.go | 12 +- .../startosis_engine/plan_yaml/plan_yaml.go | 106 ++++++++++++++++++ 2 files changed, 115 insertions(+), 3 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go index d2ef7c2b9f..272124baaa 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go @@ -22,6 +22,7 @@ import ( "github.com/kurtosis-tech/stacktrace" "github.com/xtgo/uuid" "go.starlark.net/starlark" + "go.starlark.net/starlarkstruct" ) const ( @@ -117,6 +118,7 @@ type RunShCapabilities struct { serviceConfig *service.ServiceConfig storeSpecList []*store_spec.StoreSpec + returnValue *starlarkstruct.Struct wait string description string } @@ -202,8 +204,8 @@ func (builtin *RunShCapabilities) Interpret(_ string, arguments *builtin_argumen } builtin.description = builtin_argument.GetDescriptionOrFallBack(arguments, defaultDescription) - result := createInterpretationResult(resultUuid, builtin.storeSpecList) - return result, nil + builtin.returnValue = createInterpretationResult(resultUuid, builtin.storeSpecList) + return builtin.returnValue, nil } func (builtin *RunShCapabilities) Validate(_ *builtin_argument.ArgumentValuesSet, validatorEnvironment *startosis_validator.ValidatorEnvironment) *startosis_errors.ValidationError { @@ -284,7 +286,11 @@ func (builtin *RunShCapabilities) FillPersistableAttributes(builder *enclave_pla } func (builtin *RunShCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") + err := plan.AddRunSh(builtin.run, builtin.returnValue, builtin.serviceConfig, builtin.storeSpecList) + if err != nil { + return stacktrace.Propagate(err, "An error occurred adding run sh task to the plan") + } + return nil } func (builtin *RunShCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index 09e0db1a35..81f96d3d12 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -4,8 +4,10 @@ import ( "fmt" "github.com/go-yaml/yaml" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service" + store_spec2 "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/store_spec" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "go.starlark.net/starlark" + "go.starlark.net/starlarkstruct" "strconv" "strings" ) @@ -277,6 +279,106 @@ func (planYaml *PlanYaml) AddService( return nil } +func (planYaml *PlanYaml) AddRunSh( + runCommand string, + returnValue *starlarkstruct.Struct, + serviceConfig *service.ServiceConfig, + storeSpecList []*store_spec2.StoreSpec, +) error { + uuid := planYaml.generateUuid() + + // store run sh future references + starlarkCodeVal, err := returnValue.Attr("code") + if err != nil { + return err + } + starlarkCodeFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkCodeVal, "run sh code") + if interpErr != nil { + return interpErr + } + planYaml.storeFutureReference(uuid, starlarkCodeFutureRefStr, "code") + starlarkOutputVal, err := returnValue.Attr("output") + if err != nil { + return err + } + starlarkOutputFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkOutputVal, "run sh code") + if interpErr != nil { + return interpErr + } + planYaml.storeFutureReference(uuid, starlarkOutputFutureRefStr, "output") + + // create task yaml object + taskYaml := &Task{} + taskYaml.Uuid = uuid + + taskYaml.RunCmd = []string{runCommand} + taskYaml.Image = serviceConfig.GetContainerImageName() + + var envVars []*EnvironmentVariable + for key, val := range serviceConfig.GetEnvVars() { + envVars = append(envVars, &EnvironmentVariable{ + Key: key, + Value: planYaml.swapFutureReference(val), + }) + } + taskYaml.EnvVars = envVars + + // for files: + // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid + // 2. the referenced files artifact is new, in which case we add it to the plan + for mountPath, fileArtifactName := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { + var filesArtifact *FilesArtifact + // if there's already a files artifact that exists with this name from a previous instruction, reference that + if potentialFilesArtifact, ok := planYaml.filesArtifactIndex[fileArtifactName]; ok { + filesArtifact = &FilesArtifact{ //nolint:exhaustruct + Name: potentialFilesArtifact.Name, + Uuid: potentialFilesArtifact.Uuid, + } + } else { + // otherwise create a new one + // the only information we have about a files artifact that didn't already exist is the name + // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args + filesArtifact = &FilesArtifact{ //nolint:exhaustruct + Name: fileArtifactName, + Uuid: planYaml.generateUuid(), + } + // add to the index and append to the plan yaml + planYaml.addFilesArtifactYaml(filesArtifact) + } + + taskYaml.Files = append(taskYaml.Files, &FileMount{ + MountPath: mountPath, + FilesArtifacts: []*FilesArtifact{filesArtifact}, + }) + } + + // for store + // - all files artifacts product from store are new files artifact that are added to the plan + // - add them to files artifacts list + // - add them to the store section of run sh + var store []*FilesArtifact + for _, storeSpec := range storeSpecList { + // add the FilesArtifact to list of all files artifacts and index + uuid := planYaml.generateUuid() + var newFilesArtifactFromStoreSpec = &FilesArtifact{ + Uuid: uuid, + Name: storeSpec.GetName(), + Files: []string{storeSpec.GetSrc()}, + } + planYaml.addFilesArtifactYaml(newFilesArtifactFromStoreSpec) + store = append(store, &FilesArtifact{ + Uuid: uuid, + Name: storeSpec.GetName(), + Files: []string{}, // don't want to repeat the files on a referenced files artifact + }) + } + taskYaml.Store = store + + // add task to index, do we even need a tasks index? + planYaml.addTaskYaml(taskYaml) + return nil +} + func (planYaml *PlanYaml) addServiceYaml(service *Service) { planYaml.serviceIndex[service.Name] = service planYaml.privatePlanYaml.Services = append(planYaml.privatePlanYaml.Services, service) @@ -288,6 +390,10 @@ func (planYaml *PlanYaml) addFilesArtifactYaml(filesArtifact *FilesArtifact) { planYaml.privatePlanYaml.FilesArtifacts = append(planYaml.privatePlanYaml.FilesArtifacts, filesArtifact) } +func (planYaml *PlanYaml) addTaskYaml(task *Task) { + planYaml.privatePlanYaml.Tasks = append(planYaml.privatePlanYaml.Tasks, task) +} + func (planYaml *PlanYaml) storeFutureReference(uuid, futureReference, futureReferenceType string) { planYaml.futureReferenceIndex[futureReference] = fmt.Sprintf("{{ kurtosis.%v.%v }}", uuid, futureReferenceType) } From 9095f7ad6f1fb130674e0a8f903fe8445013e7a3 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Sat, 9 Mar 2024 14:47:28 -0500 Subject: [PATCH 58/75] run sh --- .../startosis_engine/plan_yaml/plan_yaml.go | 61 ++++++++++--------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index 81f96d3d12..2623c89273 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -288,24 +288,24 @@ func (planYaml *PlanYaml) AddRunSh( uuid := planYaml.generateUuid() // store run sh future references - starlarkCodeVal, err := returnValue.Attr("code") + codeVal, err := returnValue.Attr("code") if err != nil { return err } - starlarkCodeFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkCodeVal, "run sh code") + codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "run sh code") if interpErr != nil { return interpErr } - planYaml.storeFutureReference(uuid, starlarkCodeFutureRefStr, "code") - starlarkOutputVal, err := returnValue.Attr("output") + planYaml.storeFutureReference(uuid, codeFutureRef, "code") + outputVal, err := returnValue.Attr("output") if err != nil { return err } - starlarkOutputFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkOutputVal, "run sh code") + outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "run sh code") if interpErr != nil { return interpErr } - planYaml.storeFutureReference(uuid, starlarkOutputFutureRefStr, "output") + planYaml.storeFutureReference(uuid, outputFutureRef, "output") // create task yaml object taskYaml := &Task{} @@ -326,29 +326,35 @@ func (planYaml *PlanYaml) AddRunSh( // for files: // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid // 2. the referenced files artifact is new, in which case we add it to the plan - for mountPath, fileArtifactName := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if potentialFilesArtifact, ok := planYaml.filesArtifactIndex[fileArtifactName]; ok { - filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Name: potentialFilesArtifact.Name, - Uuid: potentialFilesArtifact.Uuid, - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Name: fileArtifactName, - Uuid: planYaml.generateUuid(), + for mountPath, fileArtifactNames := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { + var filesArtifacts []*FilesArtifact + for _, filesArtifactName := range fileArtifactNames { + var filesArtifact *FilesArtifact + // if there's already a files artifact that exists with this name from a previous instruction, reference that + if filesArtifactToReference, ok := planYaml.filesArtifactIndex[filesArtifactName]; ok { + filesArtifact = &FilesArtifact{ + Name: filesArtifactToReference.Name, + Uuid: filesArtifactToReference.Uuid, + Files: []string{}, + } + } else { + // otherwise create a new one + // the only information we have about a files artifact that didn't already exist is the name + // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args + filesArtifact = &FilesArtifact{ + Name: filesArtifactName, + Uuid: planYaml.generateUuid(), + Files: []string{}, + } + // add to the index and append to the plan yaml + planYaml.addFilesArtifactYaml(filesArtifact) } - // add to the index and append to the plan yaml - planYaml.addFilesArtifactYaml(filesArtifact) + filesArtifacts = append(filesArtifacts, filesArtifact) } taskYaml.Files = append(taskYaml.Files, &FileMount{ MountPath: mountPath, - FilesArtifacts: []*FilesArtifact{filesArtifact}, + FilesArtifacts: filesArtifacts, }) } @@ -359,16 +365,15 @@ func (planYaml *PlanYaml) AddRunSh( var store []*FilesArtifact for _, storeSpec := range storeSpecList { // add the FilesArtifact to list of all files artifacts and index - uuid := planYaml.generateUuid() var newFilesArtifactFromStoreSpec = &FilesArtifact{ - Uuid: uuid, + Uuid: planYaml.generateUuid(), Name: storeSpec.GetName(), Files: []string{storeSpec.GetSrc()}, } planYaml.addFilesArtifactYaml(newFilesArtifactFromStoreSpec) store = append(store, &FilesArtifact{ - Uuid: uuid, - Name: storeSpec.GetName(), + Uuid: newFilesArtifactFromStoreSpec.Uuid, + Name: newFilesArtifactFromStoreSpec.Name, Files: []string{}, // don't want to repeat the files on a referenced files artifact }) } From d190067a2fcecd097828729ebf0e1c1688ef86f1 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Sun, 10 Mar 2024 14:16:20 -0400 Subject: [PATCH 59/75] refactor run python --- .../kurtosis_instruction/tasks/run_python.go | 12 +- .../server/startosis_engine/plan.yml | 33 +++++ .../startosis_engine/plan_yaml/plan_yaml.go | 113 +++++++++++++++++- .../startosis_interpreter_plan_yaml_test.go | 91 ++++++++++++-- 4 files changed, 237 insertions(+), 12 deletions(-) create mode 100644 core/server/api_container/server/startosis_engine/plan.yml diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go index 50e86d32a9..976ad8ea89 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go @@ -23,6 +23,7 @@ import ( "github.com/kurtosis-tech/stacktrace" "github.com/xtgo/uuid" "go.starlark.net/starlark" + "go.starlark.net/starlarkstruct" "strings" ) @@ -137,6 +138,7 @@ type RunPythonCapabilities struct { pythonArguments []string packages []string + returnValue *starlarkstruct.Struct serviceConfig *service.ServiceConfig storeSpecList []*store_spec.StoreSpec wait string @@ -245,8 +247,8 @@ func (builtin *RunPythonCapabilities) Interpret(_ string, arguments *builtin_arg builtin.description = builtin_argument.GetDescriptionOrFallBack(arguments, runPythonDefaultDescription) - result := createInterpretationResult(resultUuid, builtin.storeSpecList) - return result, nil + builtin.returnValue = createInterpretationResult(resultUuid, builtin.storeSpecList) + return builtin.returnValue, nil } func (builtin *RunPythonCapabilities) Validate(_ *builtin_argument.ArgumentValuesSet, validatorEnvironment *startosis_validator.ValidatorEnvironment) *startosis_errors.ValidationError { @@ -335,7 +337,11 @@ func (builtin *RunPythonCapabilities) FillPersistableAttributes(builder *enclave } func (builtin *RunPythonCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") + err := plan.AddRunPython(builtin.run, builtin.returnValue, builtin.serviceConfig, builtin.storeSpecList, builtin.pythonArguments, builtin.packages) + if err != nil { + return stacktrace.Propagate(err, "An error occurred updating plan with run python") + } + return nil } func (builtin *RunPythonCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml new file mode 100644 index 0000000000..c54ff8a8a5 --- /dev/null +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -0,0 +1,33 @@ +packageId: github.com/kurtosis-tech/plan-yaml-prac +services: +- uuid: "1" + name: db + image: + name: postgres:latest + envVars: + - key: POSTGRES_USER + value: tedi + - key: POSTGRES_PASSWORD + value: tedi + - key: POSTGRES_DB + value: tedi +- uuid: "3" + name: db2 + image: + name: postgres:latest + envVars: + - key: POSTGRES_DB + value: '{{ kurtosis.2.code }}' + - key: POSTGRES_USER + value: '{{ kurtosis.2.output }}' + - key: POSTGRES_PASSWORD + value: tedi +tasks: +- uuid: "2" + taskType: exec + command: + - echo + - Hello, world + serviceName: db + acceptableCodes: + - 0 diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index 2623c89273..7850063dab 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -310,6 +310,7 @@ func (planYaml *PlanYaml) AddRunSh( // create task yaml object taskYaml := &Task{} taskYaml.Uuid = uuid + taskYaml.TaskType = SHELL taskYaml.RunCmd = []string{runCommand} taskYaml.Image = serviceConfig.GetContainerImageName() @@ -346,7 +347,6 @@ func (planYaml *PlanYaml) AddRunSh( Uuid: planYaml.generateUuid(), Files: []string{}, } - // add to the index and append to the plan yaml planYaml.addFilesArtifactYaml(filesArtifact) } filesArtifacts = append(filesArtifacts, filesArtifact) @@ -364,13 +364,122 @@ func (planYaml *PlanYaml) AddRunSh( // - add them to the store section of run sh var store []*FilesArtifact for _, storeSpec := range storeSpecList { - // add the FilesArtifact to list of all files artifacts and index var newFilesArtifactFromStoreSpec = &FilesArtifact{ Uuid: planYaml.generateUuid(), Name: storeSpec.GetName(), Files: []string{storeSpec.GetSrc()}, } planYaml.addFilesArtifactYaml(newFilesArtifactFromStoreSpec) + + store = append(store, &FilesArtifact{ + Uuid: newFilesArtifactFromStoreSpec.Uuid, + Name: newFilesArtifactFromStoreSpec.Name, + Files: []string{}, // don't want to repeat the files on a referenced files artifact + }) + } + taskYaml.Store = store + + planYaml.addTaskYaml(taskYaml) + return nil +} + +func (planYaml *PlanYaml) AddRunPython( + runCommand string, + returnValue *starlarkstruct.Struct, + serviceConfig *service.ServiceConfig, + storeSpecList []*store_spec2.StoreSpec, + pythonArgs []string, + pythonPackages []string) error { + uuid := planYaml.generateUuid() + + // store future references + codeVal, err := returnValue.Attr("code") + if err != nil { + return err + } + codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "run python code") + if interpErr != nil { + return interpErr + } + planYaml.storeFutureReference(uuid, codeFutureRef, "code") + outputVal, err := returnValue.Attr("output") + if err != nil { + return err + } + outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "run python output") + if interpErr != nil { + return interpErr + } + planYaml.storeFutureReference(uuid, outputFutureRef, "output") + + // create task yaml arg + taskYaml := &Task{} + taskYaml.Uuid = uuid + taskYaml.TaskType = PYTHON + + taskYaml.RunCmd = []string{runCommand} + taskYaml.Image = serviceConfig.GetContainerImageName() + + var envVars []*EnvironmentVariable + for key, val := range serviceConfig.GetEnvVars() { + envVars = append(envVars, &EnvironmentVariable{ + Key: key, + Value: planYaml.swapFutureReference(val), + }) + } + taskYaml.EnvVars = envVars + + // python args and python packages + taskYaml.PythonArgs = append(taskYaml.PythonArgs, pythonArgs...) + taskYaml.PythonPackages = append(taskYaml.PythonPackages, pythonPackages...) + + // for files: + // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid + // 2. the referenced files artifact is new, in which case we add it to the plan + for mountPath, fileArtifactNames := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { + var filesArtifacts []*FilesArtifact + for _, filesArtifactName := range fileArtifactNames { + var filesArtifact *FilesArtifact + // if there's already a files artifact that exists with this name from a previous instruction, reference that + if filesArtifactToReference, ok := planYaml.filesArtifactIndex[filesArtifactName]; ok { + filesArtifact = &FilesArtifact{ + Name: filesArtifactToReference.Name, + Uuid: filesArtifactToReference.Uuid, + Files: []string{}, + } + } else { + // otherwise create a new one + // the only information we have about a files artifact that didn't already exist is the name + // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args + filesArtifact = &FilesArtifact{ + Name: filesArtifactName, + Uuid: planYaml.generateUuid(), + Files: []string{}, + } + planYaml.addFilesArtifactYaml(filesArtifact) + } + filesArtifacts = append(filesArtifacts, filesArtifact) + } + + taskYaml.Files = append(taskYaml.Files, &FileMount{ + MountPath: mountPath, + FilesArtifacts: filesArtifacts, + }) + } + + // for store + // - all files artifacts product from store are new files artifact that are added to the plan + // - add them to files artifacts list + // - add them to the store section of run sh + var store []*FilesArtifact + for _, storeSpec := range storeSpecList { + var newFilesArtifactFromStoreSpec = &FilesArtifact{ + Uuid: planYaml.generateUuid(), + Name: storeSpec.GetName(), + Files: []string{storeSpec.GetSrc()}, + } + planYaml.addFilesArtifactYaml(newFilesArtifactFromStoreSpec) + store = append(store, &FilesArtifact{ Uuid: newFilesArtifactFromStoreSpec.Uuid, Name: newFilesArtifactFromStoreSpec.Name, diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go index 654fd65760..8723a360a4 100644 --- a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go @@ -182,20 +182,77 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRunShWithFilesArtifacts() planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) require.NoError(suite.T(), err) - expectedYaml := - `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT + expectedYaml := `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT +filesArtifacts: +- uuid: "2" + name: hi-file +- uuid: "3" + name: bye-file + files: + - /bye.txt tasks: - uuid: "1" - run: echo bye > /bye.txt - image: bq/jcurl - envVars: - - key: HELLO - value: Hello! + taskType: sh + command: + - echo bye > /bye.txt + image: badouralix/curl-jq files: - mountPath: /hi.txt filesArtifacts: - uuid: "2" name: hi-file + store: + - uuid: "3" + name: bye-file + envVar: + - key: HELLO + value: Hello! +` + require.Equal(suite.T(), expectedYaml, planYaml) +} + +func (suite *StartosisIntepreterPlanYamlTestSuite) TestRunPython() { + script := `def run(plan, hi_files_artifact): + plan.run_python( + run = """ + import requests + response = requests.get("docs.kurtosis.com") + print(response.status_code) + """, + args = [ + "something" + ], + packages = [ + "selenium", + "requests", + ], + files = { + "/hi.txt": hi_files_artifact, + }, + store = [ + StoreSpec(src = "bye.txt", name = "bye-file"), + ], +) +` + inputArgs := `{"hi_files_artifact": "hi-file"}` + _, instructionsPlan, interpretationError := suite.interpreter.Interpret( + context.Background(), + startosis_constants.PackageIdPlaceholderForStandaloneScript, + useDefaultMainFunctionName, + noPackageReplaceOptions, + startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, + script, + inputArgs, + defaultNonBlockingMode, + emptyEnclaveComponents, + emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 1, instructionsPlan.Size()) + + planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) + require.NoError(suite.T(), err) + + expectedYaml := `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT filesArtifacts: - uuid: "2" name: hi-file @@ -203,6 +260,26 @@ filesArtifacts: name: bye-file files: - bye.txt +tasks: +- uuid: "1" + taskType: python + command: + - "\n import requests\n response = requests.get(\"docs.kurtosis.com\")\n print(response.status_code) + \ \n " + image: python:3.11-alpine + files: + - mountPath: /hi.txt + filesArtifacts: + - uuid: "2" + name: hi-file + store: + - uuid: "3" + name: bye-file + pythonPackages: + - selenium + - requests + pythonArgs: + - something ` require.Equal(suite.T(), expectedYaml, planYaml) } From ec3cf48f56303f5780c344ac46b0680020f7d2bd Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 11 Mar 2024 10:29:02 -0400 Subject: [PATCH 60/75] add exec --- .../kurtosis_instruction/exec/exec.go | 25 +- .../startosis_engine/plan_yaml/plan_yaml.go | 63 +++++ .../startosis_interpreter_plan_yaml_test.go | 232 ++++++++++++++++++ 3 files changed, 318 insertions(+), 2 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go index 2bfa7b5fa1..d82e983f01 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go @@ -7,9 +7,11 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_plan_persistence" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_structure" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_type_constructor" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/recipe" @@ -100,10 +102,13 @@ type ExecCapabilities struct { serviceName service.ServiceName execRecipe *recipe.ExecRecipe + cmdList []string resultUuid string acceptableCodes []int64 skipCodeCheck bool description string + + returnValue *starlark.Dict } func (builtin *ExecCapabilities) Interpret(_ string, arguments *builtin_argument.ArgumentValuesSet) (starlark.Value, *startosis_errors.InterpretationError) { @@ -118,6 +123,17 @@ func (builtin *ExecCapabilities) Interpret(_ string, arguments *builtin_argument if err != nil { return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", RecipeArgName) } + starlarkCmdList, ok, interpretationErr := kurtosis_type_constructor.ExtractAttrValue[*starlark.List](execRecipe.KurtosisValueTypeDefault, recipe.CommandAttr) + if interpretationErr != nil { + return nil, interpretationErr + } + if !ok { + return nil, startosis_errors.NewInterpretationError("Unable to extract attribute %v off of exec recipe.", recipe.CommandAttr) + } + cmdList, interpretationErr := kurtosis_types.SafeCastToStringSlice(starlarkCmdList, tasks.PythonArgumentsArgName) + if interpretationErr != nil { + return nil, startosis_errors.WrapWithInterpretationError(err, "An error occurred converting Starlark list of passed arguments to Go string slice") + } acceptableCodes := defaultAcceptableCodes if arguments.IsSet(AcceptableCodesArgName) { @@ -147,17 +163,18 @@ func (builtin *ExecCapabilities) Interpret(_ string, arguments *builtin_argument builtin.serviceName = serviceName builtin.execRecipe = execRecipe + builtin.cmdList = cmdList builtin.resultUuid = resultUuid builtin.acceptableCodes = acceptableCodes builtin.skipCodeCheck = skipCodeCheck builtin.description = builtin_argument.GetDescriptionOrFallBack(arguments, fmt.Sprintf(descriptionFormatStr, builtin.serviceName)) - returnValue, interpretationErr := builtin.execRecipe.CreateStarlarkReturnValue(builtin.resultUuid) + builtin.returnValue, interpretationErr = builtin.execRecipe.CreateStarlarkReturnValue(builtin.resultUuid) if interpretationErr != nil { return nil, startosis_errors.WrapWithInterpretationError(err, "An error occurred while generating return value for %v instruction", ExecBuiltinName) } - return returnValue, nil + return builtin.returnValue, nil } func (builtin *ExecCapabilities) Validate(_ *builtin_argument.ArgumentValuesSet, _ *startosis_validator.ValidatorEnvironment) *startosis_errors.ValidationError { @@ -196,6 +213,10 @@ func (builtin *ExecCapabilities) FillPersistableAttributes(builder *enclave_plan } func (builtin *ExecCapabilities) UpdatePlan(planYaml *plan_yaml.PlanYaml) error { + err := planYaml.AddExec(string(builtin.serviceName), builtin.returnValue, builtin.cmdList, builtin.acceptableCodes) + if err != nil { + return stacktrace.Propagate(err, "An error occurred updating plan with exec.") + } return nil } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index 7850063dab..d24b68db31 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -6,6 +6,7 @@ import ( "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service" store_spec2 "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/store_spec" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" + "github.com/kurtosis-tech/stacktrace" "go.starlark.net/starlark" "go.starlark.net/starlarkstruct" "strconv" @@ -493,6 +494,67 @@ func (planYaml *PlanYaml) AddRunPython( return nil } +func (planYaml *PlanYaml) AddExec( + serviceName string, + returnValue *starlark.Dict, + cmdList []string, + acceptableCodes []int64) error { + uuid := planYaml.generateUuid() + + // store future references + codeVal, found, err := returnValue.Get(starlark.String("code")) + if err != nil { + return err + } + if !found { + return stacktrace.NewError("No code value found on exec dict") + } + codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "exec code") + if interpErr != nil { + return interpErr + } + planYaml.storeFutureReference(uuid, codeFutureRef, "code") + outputVal, found, err := returnValue.Get(starlark.String("output")) + if err != nil { + return err + } + if !found { + return stacktrace.NewError("No code value found on exec dict") + } + outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "exec output") + if interpErr != nil { + return interpErr + } + planYaml.storeFutureReference(uuid, outputFutureRef, "output") + + // create task yaml + taskYaml := &Task{} + taskYaml.Uuid = uuid + taskYaml.TaskType = EXEC + taskYaml.ServiceName = serviceName + taskYaml.RunCmd = cmdList + taskYaml.AcceptableCodes = acceptableCodes + + planYaml.privatePlanYaml.Tasks = append(planYaml.privatePlanYaml.Tasks, taskYaml) + return nil +} + +func (planYaml *PlanYaml) AddRenderTemplates() error { + return nil +} + +func (planYaml *PlanYaml) AddUploadFiles() error { + return nil +} + +func (planYaml *PlanYaml) AddStoreServiceFiles() error { + return nil +} + +func (planYaml *PlanYaml) RemoveService() error { + return nil +} + func (planYaml *PlanYaml) addServiceYaml(service *Service) { planYaml.serviceIndex[service.Name] = service planYaml.privatePlanYaml.Services = append(planYaml.privatePlanYaml.Services, service) @@ -508,6 +570,7 @@ func (planYaml *PlanYaml) addTaskYaml(task *Task) { planYaml.privatePlanYaml.Tasks = append(planYaml.privatePlanYaml.Tasks, task) } +// yaml future reference format: {{ kurtosis.. Date: Mon, 11 Mar 2024 11:03:57 -0400 Subject: [PATCH 61/75] refactor remaining instructions --- .../remove_service/remove_service.go | 8 +- .../render_templates/render_templates.go | 12 +- .../store_service_files.go | 6 +- .../upload_files/upload_files.go | 6 +- .../startosis_engine/plan_yaml/plan_yaml.go | 34 +++++- .../startosis_interpreter_plan_yaml_test.go | 104 +++++++++++++++--- 6 files changed, 142 insertions(+), 28 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go index 3952075ba6..1213bd544c 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go @@ -107,8 +107,12 @@ func (builtin *RemoveServiceCapabilities) FillPersistableAttributes(builder *enc ) } -func (builitin *RemoveServiceCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") +func (builtin *RemoveServiceCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + err := plan.RemoveService(string(builtin.serviceName)) + if err != nil { + return stacktrace.Propagate(err, "An error occurred updating plan with remove service.") + } + return nil } func (builtin *RemoveServiceCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go index b8f268d0f9..588cae2bee 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go @@ -174,8 +174,16 @@ func (builtin *RenderTemplatesCapabilities) FillPersistableAttributes(builder *e ) } -func (builitin *RenderTemplatesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") +func (builtin *RenderTemplatesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + filepaths := []string{} + for filepath, _ := range builtin.templatesAndDataByDestRelFilepath { + filepaths = append(filepaths, filepath) + } + err := plan.AddRenderTemplates(builtin.artifactName, filepaths) + if err != nil { + return stacktrace.Propagate(err, "An error occurred updating plan with render template instruction.") + } + return nil } func (builtin *RenderTemplatesCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files/store_service_files.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files/store_service_files.go index fb966688c3..ab17ad1b5b 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files/store_service_files.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files/store_service_files.go @@ -181,7 +181,11 @@ func (builtin *StoreServiceFilesCapabilities) FillPersistableAttributes(builder } func (builtin *StoreServiceFilesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") + err := plan.AddStoreServiceFiles(builtin.artifactName, builtin.src) + if err != nil { + return stacktrace.Propagate(err, "An error occurred updating plan with store service files") + } + return nil } func (builtin *StoreServiceFilesCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go index dcaccd0b50..f9a7e79331 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files/upload_files.go @@ -220,7 +220,11 @@ func (builtin *UploadFilesCapabilities) FillPersistableAttributes(builder *encla } func (builtin *UploadFilesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") + err := plan.AddUploadFiles(builtin.artifactName, builtin.src) + if err != nil { + return stacktrace.Propagate(err, "An error occurred updating plan with upload files.") + } + return nil } func (builtin *UploadFilesCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index d24b68db31..debb5e89b1 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -539,19 +539,45 @@ func (planYaml *PlanYaml) AddExec( return nil } -func (planYaml *PlanYaml) AddRenderTemplates() error { +func (planYaml *PlanYaml) AddRenderTemplates(filesArtifactName string, filepaths []string) error { + uuid := planYaml.generateUuid() + filesArtifactYaml := &FilesArtifact{} + filesArtifactYaml.Uuid = uuid + filesArtifactYaml.Name = filesArtifactName + filesArtifactYaml.Files = filepaths + planYaml.addFilesArtifactYaml(filesArtifactYaml) return nil } -func (planYaml *PlanYaml) AddUploadFiles() error { +func (planYaml *PlanYaml) AddUploadFiles(filesArtifactName, locator string) error { + uuid := planYaml.generateUuid() + filesArtifactYaml := &FilesArtifact{} + filesArtifactYaml.Uuid = uuid + filesArtifactYaml.Name = filesArtifactName + filesArtifactYaml.Files = []string{locator} + planYaml.addFilesArtifactYaml(filesArtifactYaml) return nil } -func (planYaml *PlanYaml) AddStoreServiceFiles() error { +func (planYaml *PlanYaml) AddStoreServiceFiles(filesArtifactName, locator string) error { + uuid := planYaml.generateUuid() + filesArtifactYaml := &FilesArtifact{} + filesArtifactYaml.Uuid = uuid + filesArtifactYaml.Name = filesArtifactName + filesArtifactYaml.Files = []string{locator} + planYaml.addFilesArtifactYaml(filesArtifactYaml) return nil } -func (planYaml *PlanYaml) RemoveService() error { +func (planYaml *PlanYaml) RemoveService(serviceName string) error { + delete(planYaml.serviceIndex, serviceName) + for idx, service := range planYaml.privatePlanYaml.Services { + if service.Name == serviceName { + planYaml.privatePlanYaml.Services[idx] = planYaml.privatePlanYaml.Services[len(planYaml.privatePlanYaml.Services)-1] + planYaml.privatePlanYaml.Services = planYaml.privatePlanYaml.Services[:len(planYaml.privatePlanYaml.Services)-1] + return nil + } + } return nil } diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go index 5c45e719a0..843a01dc50 100644 --- a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go @@ -366,7 +366,11 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRenderTemplate() { "bye.txt": struct( template="Bye bye!", data={} - ) + ), + "fairwell.txt": struct ( + template = "Fair well!", + data = {} + ), } ) @@ -395,7 +399,25 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRenderTemplate() { planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) require.NoError(suite.T(), err) - expectedYaml := `` + expectedYaml := `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT +filesArtifacts: +- uuid: "1" + name: bye-file + files: + - bye.txt + - fairwell.txt +tasks: +- uuid: "2" + taskType: sh + command: + - cat /root/bye.txt + image: badouralix/curl-jq + files: + - mountPath: /root + filesArtifacts: + - uuid: "1" + name: bye-file +` require.Equal(suite.T(), expectedYaml, planYaml) } @@ -432,29 +454,50 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestUploadFiles() { require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 2, instructionsPlan.Size()) - planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) + planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(packageId)) require.NoError(suite.T(), err) - expectedYaml := `` + expectedYaml := `packageId: ` + packageId + ` +filesArtifacts: +- uuid: "1" + name: dockerfile + files: + - ./server/Dockerfile +tasks: +- uuid: "2" + taskType: sh + command: + - cat /root/Dockerfile + image: badouralix/curl-jq + files: + - mountPath: /root + filesArtifacts: + - uuid: "1" + name: dockerfile +` require.Equal(suite.T(), expectedYaml, planYaml) } func (suite *StartosisIntepreterPlanYamlTestSuite) TestStoreServiceFiles() { - script := `def run(plan, args): + script := `def run(plan, hi_files_artifact): plan.add_service( - name="tedi", + name="db", config=ServiceConfig( - image="postgres:alpine", - cmd=["touch", "hi.txt"], - ) + image="postgres:latest", + cmd=["touch", "bye.txt"], + files = { + "/root": hi_files_artifact + } + ), ) - hi_files_artifact = plan.store_service_files( - name="hi-file", - src="hi.txt", - service_name="tedi", + bye_files_artifact = plan.store_service_files( + name="bye-file", + src="bye.txt", + service_name="db", ) ` + inputArgs := `{"hi_files_artifact": "hi-file"}` _, instructionsPlan, interpretationError := suite.interpreter.Interpret( context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, @@ -462,7 +505,7 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestStoreServiceFiles() { noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, script, - startosis_constants.EmptyInputArgs, + inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) @@ -472,7 +515,28 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestStoreServiceFiles() { planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) require.NoError(suite.T(), err) - expectedYaml := `` + expectedYaml := `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT +services: +- uuid: "1" + name: db + image: + name: postgres:latest + command: + - touch + - bye.txt + files: + - mountPath: /root + filesArtifacts: + - uuid: "2" + name: hi-file +filesArtifacts: +- uuid: "2" + name: hi-file +- uuid: "3" + name: bye-file + files: + - bye.txt +` require.Equal(suite.T(), expectedYaml, planYaml) } @@ -489,10 +553,10 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRemoveService() { }, files = { "/root": hi_files_artifact, - }, + } ) ) - plan.remove_service(name="db") + plan.remove_service(name="db") ` inputArgs := `{"hi_files_artifact": "hi-file"}` _, instructionsPlan, interpretationError := suite.interpreter.Interpret( @@ -512,6 +576,10 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRemoveService() { planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) require.NoError(suite.T(), err) - expectedYaml := `` + expectedYaml := `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT +filesArtifacts: +- uuid: "2" + name: hi-file +` require.Equal(suite.T(), expectedYaml, planYaml) } From 13a5cba751d05c88ce59fdb893f87b9b2611cf65 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 11 Mar 2024 11:05:24 -0400 Subject: [PATCH 62/75] remove old files --- .../server/startosis_engine/plan.yml | 33 - .../server/startosis_engine/plan_yaml.go | 103 -- .../startosis_engine/plan_yaml_generator.go | 892 ------------------ .../plan_yaml_generator_test.go | 612 ------------ 4 files changed, 1640 deletions(-) delete mode 100644 core/server/api_container/server/startosis_engine/plan.yml delete mode 100644 core/server/api_container/server/startosis_engine/plan_yaml.go delete mode 100644 core/server/api_container/server/startosis_engine/plan_yaml_generator.go delete mode 100644 core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml deleted file mode 100644 index c54ff8a8a5..0000000000 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ /dev/null @@ -1,33 +0,0 @@ -packageId: github.com/kurtosis-tech/plan-yaml-prac -services: -- uuid: "1" - name: db - image: - name: postgres:latest - envVars: - - key: POSTGRES_USER - value: tedi - - key: POSTGRES_PASSWORD - value: tedi - - key: POSTGRES_DB - value: tedi -- uuid: "3" - name: db2 - image: - name: postgres:latest - envVars: - - key: POSTGRES_DB - value: '{{ kurtosis.2.code }}' - - key: POSTGRES_USER - value: '{{ kurtosis.2.output }}' - - key: POSTGRES_PASSWORD - value: tedi -tasks: -- uuid: "2" - taskType: exec - command: - - echo - - Hello, world - serviceName: db - acceptableCodes: - - 0 diff --git a/core/server/api_container/server/startosis_engine/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml.go deleted file mode 100644 index 4d307acdd3..0000000000 --- a/core/server/api_container/server/startosis_engine/plan_yaml.go +++ /dev/null @@ -1,103 +0,0 @@ -package startosis_engine - -const ( - HTTP ApplicationProtocol = "HTTP" - UDP TransportProtocol = "UDP" - TCP TransportProtocol = "TCP" - - SHELL TaskType = "sh" - PYTHON TaskType = "python" - EXEC TaskType = "exec" -) - -// TODO: there's really no point in making any of these references, consider just making them copies -type PlanYaml struct { - PackageId string `yaml:"packageId,omitempty"` - Services []*Service `yaml:"services,omitempty"` - FilesArtifacts []*FilesArtifact `yaml:"filesArtifacts,omitempty"` - Tasks []*Task `yaml:"tasks,omitempty"` -} - -// Service represents a service in the system. -type Service struct { - Uuid string `yaml:"uuid,omitempty"` // done - Name string `yaml:"name,omitempty"` // done - Image *ImageSpec `yaml:"image,omitempty"` // done - Cmd []string `yaml:"command,omitempty"` // done - Entrypoint []string `yaml:"entrypoint,omitempty"` // done - EnvVars []*EnvironmentVariable `yaml:"envVars,omitempty"` // done - Ports []*Port `yaml:"ports,omitempty"` // done - Files []*FileMount `yaml:"files,omitempty"` // done - - // TODO: support remaining fields in the ServiceConfig -} - -type ImageSpec struct { - ImageName string `yaml:"name,omitempty"` - - // for built images - BuildContextLocator string `yaml:"buildContextLocator,omitempty"` - TargetStage string `yaml:"targetStage,omitempty"` - - // for images from registry - Registry string `yaml:"registry,omitempty"` -} - -// FilesArtifact represents a collection of files. -type FilesArtifact struct { - Uuid string `yaml:"uuid,omitempty"` - Name string `yaml:"name,omitempty"` - Files []string `yaml:"files,omitempty"` -} - -// EnvironmentVariable represents an environment variable. -type EnvironmentVariable struct { - Key string `yaml:"key,omitempty"` - Value string `yaml:"value,omitempty"` -} - -// Port represents a port. -type Port struct { - Name string `yaml:"name,omitempty"` - Number uint16 `yaml:"number,omitempty"` - - TransportProtocol TransportProtocol `yaml:"transportProtocol,omitempty"` - ApplicationProtocol ApplicationProtocol `yaml:"applicationProtocol,omitempty"` -} - -// ApplicationProtocol represents the application protocol used. -type ApplicationProtocol string - -// TransportProtocol represents transport protocol used. -type TransportProtocol string - -// FileMount represents a mount point for files. -type FileMount struct { - MountPath string `yaml:"mountPath,omitempty"` - FilesArtifacts []*FilesArtifact `yaml:"filesArtifacts,omitempty"` // TODO: support persistent directories -} - -// Task represents a task to be executed. -type Task struct { - Uuid string `yaml:"uuid,omitempty"` // done - Name string `yaml:"name,omitempty"` // done - TaskType TaskType `yaml:"taskType,omitempty"` // done - RunCmd []string `yaml:"command,omitempty"` // done - Image string `yaml:"image,omitempty"` // done - Files []*FileMount `yaml:"files,omitempty"` // done - Store []*FilesArtifact `yaml:"store,omitempty"` // done - - // only exists on SHELL tasks - EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` // done - - // only exists on PYTHON tasks - PythonPackages []string `yaml:"pythonPackages,omitempty"` - PythonArgs []string `yaml:"pythonArgs,omitempty"` - - // service name - ServiceName string `yaml:"serviceName,omitempty"` - AcceptableCodes []int64 `yaml:"acceptableCodes,omitempty"` -} - -// TaskType represents the type of task (either PYTHON or SHELL) -type TaskType string diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go deleted file mode 100644 index ccb4b10606..0000000000 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ /dev/null @@ -1,892 +0,0 @@ -package startosis_engine - -import ( - "fmt" - "github.com/go-yaml/yaml" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/instructions_plan" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_type_constructor" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/recipe" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages" - "github.com/kurtosis-tech/stacktrace" - "github.com/sirupsen/logrus" - "go.starlark.net/starlark" - "go.starlark.net/starlarkstruct" - "strconv" - "strings" -) - -// We need the package id and the args, the args need to be filled in -// the instructions likely come with the args filled in already, but what if no args are passed in? are they left as variables? - -// How to represent dependencies within the yaml??? -// say a service config refers to another files artifact - -// some conversions are: -// add_service -> use service config and returned info to create a ServiceObject -// remove_service -> remove that from the plan representation -// upload_files -> FilesArtifact -// render_template -> FilesArtifact -// run_sh -> Task but returns a files artifact so create that -// run_python -> Task but returns a files artifact so create that -// -// go through all the kurtosis builtins and figure out which ones we need to accommodate for and which ones we don't need to accommodate for - -// TODO: refactor this so plan yaml is generated as instructionsPlan is created, otherwise a lot of duplicate operations happen to parse the arguments - -// PlanYamlGenerator generates a yaml representation of a [plan]. -type PlanYamlGenerator interface { - // GenerateYaml converts [plan] into a byte array that represents a yaml with information in the plan. - // The format of the yaml in the byte array is as such: - // - // - // - //packageId: github.com/kurtosis-tech/postgres-package - // - //services: - // - uuid: - // - name: - // service_config: - // image: - // env_var: - // ... - // - // - //files_artifacts: - // - // - // - // - // - // - //tasks: - // - // - - GenerateYaml(plan instructions_plan.InstructionsPlan) ([]byte, error) -} - -type PlanYamlGeneratorImpl struct { - // Plan generated by an interpretation of a Starlark script of package - plan *instructions_plan.InstructionsPlan - - serviceNetwork service_network.ServiceNetwork - - packageContentProvider startosis_packages.PackageContentProvider - - packageReplaceOptions map[string]string - // consider using EnclaveComponents struct to manage services and files artifacts? - // this way we re use a common interface? - // but it doesn't have the - // technically files artifacts are future references but we store them separately bc they are easily identifiable - // and have a distinct structure (FilesArtifact) - filesArtifactIndex map[string]*FilesArtifact - - // Store service index needed to see in case a service is referenced by a remove service, or store service later in the plan - serviceIndex map[string]*Service - - // Representation of plan in yaml the plan is being processed, the yaml gets updated - planYaml *PlanYaml - - uuidGenerator int - - futureReferenceIndex map[string]string -} - -func NewPlanYamlGenerator( - plan *instructions_plan.InstructionsPlan, - serviceNetwork service_network.ServiceNetwork, - packageId string, - packageContentProvider startosis_packages.PackageContentProvider, - packageReplaceOptions map[string]string) *PlanYamlGeneratorImpl { - return &PlanYamlGeneratorImpl{ - plan: plan, - serviceNetwork: serviceNetwork, - packageContentProvider: packageContentProvider, - packageReplaceOptions: packageReplaceOptions, - planYaml: &PlanYaml{ - PackageId: packageId, - Services: []*Service{}, - FilesArtifacts: []*FilesArtifact{}, - Tasks: []*Task{}, - }, - filesArtifactIndex: map[string]*FilesArtifact{}, - serviceIndex: map[string]*Service{}, - uuidGenerator: 0, - futureReferenceIndex: map[string]string{}, - } -} - -func (pyg *PlanYamlGeneratorImpl) GenerateYaml() ([]byte, error) { - instructionsSequence, err := pyg.plan.GeneratePlan() - if err != nil { - return nil, err - } - - // iterate over the sequence of instructions - for _, scheduledInstruction := range instructionsSequence { - var err error - // based on the instruction, update the plan yaml representation accordingly - switch getBuiltinNameFromInstruction(scheduledInstruction) { - case add_service.AddServiceBuiltinName: - err = pyg.updatePlanYamlFromAddService(scheduledInstruction) - case remove_service.RemoveServiceBuiltinName: - err = pyg.updatePlanYamlFromRemoveService(scheduledInstruction) - case tasks.RunShBuiltinName: - err = pyg.updatePlanYamlFromRunSh(scheduledInstruction) - case tasks.RunPythonBuiltinName: - err = pyg.updatePlanYamlFromRunPython(scheduledInstruction) - case render_templates.RenderTemplatesBuiltinName: - err = pyg.updatePlanYamlFromRenderTemplates(scheduledInstruction) - case upload_files.UploadFilesBuiltinName: - err = pyg.updatePlanYamlFromUploadFiles(scheduledInstruction) - case store_service_files.StoreServiceFilesBuiltinName: - err = pyg.updatePlanYamlFromStoreServiceFiles(scheduledInstruction) - case exec.ExecBuiltinName: - err = pyg.updatePlanYamlFromExec(scheduledInstruction) - default: - // skip if this instruction is not one that will update the plan yaml - continue - } - if err != nil { - return nil, err - } - } - - // at the very end, convert the plan yaml representation into a yaml - logrus.Infof("FUTURE REFERENCE INDEX: %v", pyg.futureReferenceIndex) - return convertPlanYamlToYaml(pyg.planYaml) -} - -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromAddService(addServiceInstruction *instructions_plan.ScheduledInstruction) error { // for type safety, it would be great to be more specific than scheduled instruction - kurtosisInstruction := addServiceInstruction.GetInstruction() - arguments := kurtosisInstruction.GetArguments() - - // start building Service Yaml object - service := &Service{} //nolint:exhaustruct - uuid := pyg.generateUuid() - service.Uuid = strconv.Itoa(uuid) - - // store future references of this service - returnValue := addServiceInstruction.GetReturnedValue() - returnedService, ok := returnValue.(*kurtosis_types.Service) - if !ok { - return stacktrace.NewError("Cast to service didn't work") - } - futureRefIPAddress, err := returnedService.GetIpAddress() - if err != nil { - return err - } - pyg.futureReferenceIndex[futureRefIPAddress] = fmt.Sprintf("{{ kurtosis.%v.ip_address }}", uuid) - futureRefHostName, err := returnedService.GetHostname() - if err != nil { - return err - } - pyg.futureReferenceIndex[futureRefHostName] = fmt.Sprintf("{{ kurtosis.%v.hostname }}", uuid) - - var regErr error - serviceName, regErr := builtin_argument.ExtractArgumentValue[starlark.String](arguments, add_service.ServiceNameArgName) - if regErr != nil { - return startosis_errors.WrapWithInterpretationError(regErr, "Unable to extract value for '%s' argument", add_service.ServiceNameArgName) - } - service.Name = pyg.swapFutureReference(serviceName.GoString()) // swap future references in the strings - - starlarkServiceConfig, regErr := builtin_argument.ExtractArgumentValue[*service_config.ServiceConfig](arguments, add_service.ServiceConfigArgName) - if regErr != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", add_service.ServiceConfigArgName) - } - serviceConfig, serviceConfigErr := starlarkServiceConfig.ToKurtosisType( // is this an expensive call? // TODO: add this error back in - pyg.serviceNetwork, - kurtosisInstruction.GetPositionInOriginalScript().GetFilename(), - pyg.planYaml.PackageId, - pyg.packageContentProvider, - pyg.packageReplaceOptions) - if serviceConfigErr != nil { - return serviceConfigErr - } - - // get image info - rawImageAttrValue, _, interpretationErr := kurtosis_type_constructor.ExtractAttrValue[starlark.Value](starlarkServiceConfig.KurtosisValueTypeDefault, service_config.ImageAttr) - if interpretationErr != nil { - return interpretationErr - } - image := &ImageSpec{ //nolint:exhaustruct - ImageName: serviceConfig.GetContainerImageName(), - } - imageBuildSpec := serviceConfig.GetImageBuildSpec() - if imageBuildSpec != nil { - switch img := rawImageAttrValue.(type) { - case *service_config.ImageBuildSpec: - contextLocator, err := img.GetBuildContextLocator() - if err != nil { - return err - } - image.BuildContextLocator = contextLocator - } - image.TargetStage = imageBuildSpec.GetTargetStage() - } - imageSpec := serviceConfig.GetImageRegistrySpec() - if imageSpec != nil { - image.Registry = imageSpec.GetRegistryAddr() - } - service.Image = image - - // detect future references - cmdArgs := []string{} - for _, cmdArg := range serviceConfig.GetCmdArgs() { - realCmdArg := pyg.swapFutureReference(cmdArg) - cmdArgs = append(cmdArgs, realCmdArg) - } - service.Cmd = cmdArgs - - entryArgs := []string{} - for _, entryArg := range serviceConfig.GetEntrypointArgs() { - realEntryArg := pyg.swapFutureReference(entryArg) - entryArgs = append(entryArgs, realEntryArg) - } - service.Entrypoint = entryArgs - - // ports - service.Ports = []*Port{} - for portName, configPort := range serviceConfig.GetPrivatePorts() { // TODO: support public ports - - port := &Port{ //nolint:exhaustruct - TransportProtocol: TransportProtocol(configPort.GetTransportProtocol().String()), - Name: portName, - Number: configPort.GetNumber(), - } - if configPort.GetMaybeApplicationProtocol() != nil { - port.ApplicationProtocol = ApplicationProtocol(*configPort.GetMaybeApplicationProtocol()) - } - - service.Ports = append(service.Ports, port) - } - - // env vars - service.EnvVars = []*EnvironmentVariable{} - for key, val := range serviceConfig.GetEnvVars() { - // detect and future references - value := pyg.swapFutureReference(val) - envVar := &EnvironmentVariable{ - Key: key, - Value: value, - } - service.EnvVars = append(service.EnvVars, envVar) - } - - // file mounts have two cases: - // 1. the referenced files artifact already exists in the plan, in which case add the referenced files artifact - // 2. the referenced files artifact does not already exist in the plan, in which case the file MUST have been passed in via a top level arg OR is invalid - // in this case, - // - create new files artifact - // - add it to the service's file mount accordingly - // - add the files artifact to the plan - service.Files = []*FileMount{} - serviceFilesArtifactExpansions := serviceConfig.GetFilesArtifactsExpansion() - if serviceFilesArtifactExpansions != nil { - for mountPath, artifactIdentifiers := range serviceFilesArtifactExpansions.ServiceDirpathsToArtifactIdentifiers { - fileMount := &FileMount{ //nolint:exhaustruct - MountPath: mountPath, - } - - var serviceFilesArtifacts []*FilesArtifact - for _, identifier := range artifactIdentifiers { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if potentialFilesArtifact, ok := pyg.filesArtifactIndex[identifier]; ok { - filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Name: potentialFilesArtifact.Name, - Uuid: potentialFilesArtifact.Uuid, - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Name: identifier, - Uuid: strconv.Itoa(pyg.generateUuid()), - } - pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) - pyg.filesArtifactIndex[identifier] = filesArtifact - } - serviceFilesArtifacts = append(serviceFilesArtifacts, filesArtifact) - } - - fileMount.FilesArtifacts = serviceFilesArtifacts - service.Files = append(service.Files, fileMount) - } - - } - - pyg.planYaml.Services = append(pyg.planYaml.Services, service) - pyg.serviceIndex[service.Name] = service - return nil -} - -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromUploadFiles(uploadFilesInstruction *instructions_plan.ScheduledInstruction) error { - var filesArtifact *FilesArtifact - - // get the name of returned files artifact - filesArtifactName, castErr := kurtosis_types.SafeCastToString(uploadFilesInstruction.GetReturnedValue(), "files artifact name") - if castErr != nil { - return castErr - } - filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Name: filesArtifactName, - Uuid: strconv.Itoa(pyg.generateUuid()), - } - - // get files of returned files artifact off render templates config - arguments := uploadFilesInstruction.GetInstruction().GetArguments() - src, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, upload_files.SrcArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", upload_files.SrcArgName) - } - filesArtifact.Files = []string{src.GoString()} - - // add the files artifact to the yaml and index - pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) - pyg.filesArtifactIndex[filesArtifactName] = filesArtifact - return nil -} - -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRenderTemplates(renderTemplatesInstruction *instructions_plan.ScheduledInstruction) error { - var filesArtifact *FilesArtifact - - // get the name of returned files artifact - filesArtifactName, castErr := kurtosis_types.SafeCastToString(renderTemplatesInstruction.GetReturnedValue(), "files artifact name") - if castErr != nil { - return castErr - } - filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Uuid: strconv.Itoa(pyg.generateUuid()), - Name: filesArtifactName, - } - - // get files of returned files artifact off render templates config - arguments := renderTemplatesInstruction.GetInstruction().GetArguments() - renderTemplateConfig, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, render_templates.TemplateAndDataByDestinationRelFilepathArg) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to parse '%s'", render_templates.TemplateAndDataByDestinationRelFilepathArg) - } - files := []string{} - for _, filepath := range renderTemplateConfig.Keys() { - filepathStr, castErr := kurtosis_types.SafeCastToString(filepath, "filepath") - if castErr != nil { - return castErr - } - files = append(files, filepathStr) - } - filesArtifact.Files = files - - // add the files artifact to the yaml and index - pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) - pyg.filesArtifactIndex[filesArtifactName] = filesArtifact - - return nil -} - -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunSh(runShInstruction *instructions_plan.ScheduledInstruction) error { - var task *Task - var interpErr *startosis_errors.InterpretationError - taskUuid := pyg.generateUuid() - - // store run sh future references - returnValue := runShInstruction.GetReturnedValue() - runShStruct, ok := returnValue.(*starlarkstruct.Struct) - if !ok { - return stacktrace.NewError("Casting run sh return value to struct didn't work") - } - starlarkCodeVal, err := runShStruct.Attr("code") - if err != nil { - return err - } - starlarkCodeFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkCodeVal, "run sh code") - if interpErr != nil { - return interpErr - } - pyg.futureReferenceIndex[starlarkCodeFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.code }}", taskUuid) - starlarkOutputVal, err := runShStruct.Attr("output") - if err != nil { - return err - } - starlarkOutputFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkOutputVal, "run sh code") - if interpErr != nil { - return interpErr - } - pyg.futureReferenceIndex[starlarkOutputFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.output }}", taskUuid) - - task = &Task{ //nolint:exhaustruct - Uuid: strconv.Itoa(taskUuid), - TaskType: SHELL, - } - - // get runcmd, image, env vars and set them in the yaml - arguments := runShInstruction.GetInstruction().GetArguments() - runCommand, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, tasks.RunArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.RunArgName) - } - task.RunCmd = []string{pyg.swapFutureReference(runCommand.GoString())} - - var image string - if arguments.IsSet(tasks.ImageNameArgName) { - imageStarlark, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, tasks.ImageNameArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.ImageNameArgName) - } - image = imageStarlark.GoString() - } else { - image = tasks.DefaultRunShImageName - } - task.Image = image - - var envVars []*EnvironmentVariable - var envVarsMap map[string]string - if arguments.IsSet(tasks.EnvVarsArgName) { - envVarsStarlark, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, tasks.EnvVarsArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.EnvVarsArgName) - } - if envVarsStarlark != nil && envVarsStarlark.Len() > 0 { - var interpretationErr *startosis_errors.InterpretationError - envVarsMap, interpretationErr = kurtosis_types.SafeCastToMapStringString(envVarsStarlark, tasks.EnvVarsArgName) - if interpretationErr != nil { - return interpretationErr - } - } - } - for key, val := range envVarsMap { - envVars = append(envVars, &EnvironmentVariable{ - Key: key, - Value: val, - }) - } - task.EnvVars = envVars - - // for files: - // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid - // 2. the referenced files artifact is new, in which case we add it to the plan - if arguments.IsSet(tasks.FilesArgName) { - filesStarlark, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, tasks.FilesArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.FilesArgName) - } - if filesStarlark.Len() > 0 { - filesArtifactMountDirPaths, interpretationErr := kurtosis_types.SafeCastToMapStringString(filesStarlark, tasks.FilesArgName) - if interpretationErr != nil { - return interpretationErr - } - for mountPath, fileArtifactName := range filesArtifactMountDirPaths { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if potentialFilesArtifact, ok := pyg.filesArtifactIndex[fileArtifactName]; ok { - filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Name: potentialFilesArtifact.Name, - Uuid: potentialFilesArtifact.Uuid, - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Name: fileArtifactName, - Uuid: strconv.Itoa(pyg.generateUuid()), - } - // add to the index and append to the plan yaml - pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) - pyg.filesArtifactIndex[fileArtifactName] = filesArtifact - } - - task.Files = append(task.Files, &FileMount{ - MountPath: mountPath, - FilesArtifacts: []*FilesArtifact{filesArtifact}, - }) - } - } - } - - // for store - // - all files artifacts product from store are new files artifact that are added to the plan - // - add them to files artifacts list - // - add them to the store section of run sh - var store []*FilesArtifact - storeSpecs, _ := tasks.ParseStoreFilesArg(pyg.serviceNetwork, arguments) - // TODO: catch this error - //if err != startosis_errors.WrapWithInterpretationError(nil, "") { catch this error - // return err - //} - for _, storeSpec := range storeSpecs { - // add the FilesArtifact to list of all files artifacts and index - uuid := strconv.Itoa(pyg.generateUuid()) - var newFilesArtifactFromStoreSpec = &FilesArtifact{ - Uuid: uuid, - Name: storeSpec.GetName(), - Files: []string{storeSpec.GetSrc()}, - } - pyg.filesArtifactIndex[storeSpec.GetName()] = newFilesArtifactFromStoreSpec - pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, newFilesArtifactFromStoreSpec) - store = append(store, &FilesArtifact{ //nolint:exhaustruct - Uuid: uuid, - Name: storeSpec.GetName(), - }) - } - task.Store = store // TODO: be consistent about how I'm setting lists in the plan yamls, probably should add wrappers to the plan yaml - - // add task to index, do we even need a tasks index? - pyg.planYaml.Tasks = append(pyg.planYaml.Tasks, task) - return nil -} - -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRunPython(runPythonInstruction *instructions_plan.ScheduledInstruction) error { - var task *Task - taskUuid := pyg.generateUuid() - - // store future references - returnValue := runPythonInstruction.GetReturnedValue() - runPythonStruct, ok := returnValue.(*starlarkstruct.Struct) - if !ok { - return stacktrace.NewError("Casting run python return value to a struct didn't work") - } - starlarkCodeVal, err := runPythonStruct.Attr("code") - if err != nil { - return err - } - starlarkCodeFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkCodeVal, "run python code") - if interpErr != nil { - return interpErr - } - pyg.futureReferenceIndex[starlarkCodeFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.code }}", taskUuid) - starlarkOutputVal, err := runPythonStruct.Attr("output") - if err != nil { - return err - } - starlarkOutputFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkOutputVal, "run python output") - if interpErr != nil { - return interpErr - } - pyg.futureReferenceIndex[starlarkOutputFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.output }}", taskUuid) - - task = &Task{ //nolint:exhaustruct - Uuid: strconv.Itoa(taskUuid), - TaskType: PYTHON, - } - - // get run cmd, image and set them in the yaml - arguments := runPythonInstruction.GetInstruction().GetArguments() - runCommand, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, tasks.RunArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.RunArgName) - } - task.RunCmd = []string{runCommand.GoString()} - - var image string - if arguments.IsSet(tasks.ImageNameArgName) { - imageStarlark, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, tasks.ImageNameArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.ImageNameArgName) - } - image = imageStarlark.GoString() - } else { - image = tasks.DefaultRunShImageName - } - task.Image = image - - var envVars []*EnvironmentVariable - var envVarsMap map[string]string - if arguments.IsSet(tasks.EnvVarsArgName) { - envVarsStarlark, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, tasks.EnvVarsArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.EnvVarsArgName) - } - if envVarsStarlark != nil && envVarsStarlark.Len() > 0 { - var interpretationErr *startosis_errors.InterpretationError - envVarsMap, interpretationErr = kurtosis_types.SafeCastToMapStringString(envVarsStarlark, tasks.EnvVarsArgName) - if interpretationErr != nil { - return interpretationErr - } - } - } - for key, val := range envVarsMap { - envVars = append(envVars, &EnvironmentVariable{ - Key: key, - Value: val, - }) - } - task.EnvVars = envVars - - // python args and python packages - if arguments.IsSet(tasks.PythonArgumentsArgName) { - argsValue, err := builtin_argument.ExtractArgumentValue[*starlark.List](arguments, tasks.PythonArgumentsArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "error occurred while extracting passed argument information") - } - argsList, sliceParsingErr := kurtosis_types.SafeCastToStringSlice(argsValue, tasks.PythonArgumentsArgName) - if sliceParsingErr != nil { - return startosis_errors.WrapWithInterpretationError(err, "error occurred while converting Starlark list of passed arguments to a golang string slice") - } - for idx, arg := range argsList { - argsList[idx] = pyg.swapFutureReference(arg) - } - task.PythonArgs = append(task.PythonArgs, argsList...) - } - - if arguments.IsSet(tasks.PackagesArgName) { - packagesValue, err := builtin_argument.ExtractArgumentValue[*starlark.List](arguments, tasks.PackagesArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "error occurred while extracting packages information") - } - packagesList, sliceParsingErr := kurtosis_types.SafeCastToStringSlice(packagesValue, tasks.PackagesArgName) - if sliceParsingErr != nil { - return startosis_errors.WrapWithInterpretationError(err, "error occurred while converting Starlark list of packages to a golang string slice") - } - task.PythonPackages = append(task.PythonPackages, packagesList...) - } - - // for files: - // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid - // 2. the referenced files artifact is new, in which case we add it to the plan - if arguments.IsSet(tasks.FilesArgName) { - filesStarlark, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, tasks.FilesArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", tasks.FilesArgName) - } - if filesStarlark.Len() > 0 { - filesArtifactMountDirPaths, interpretationErr := kurtosis_types.SafeCastToMapStringString(filesStarlark, tasks.FilesArgName) - if interpretationErr != nil { - return interpretationErr - } - for mountPath, fileArtifactName := range filesArtifactMountDirPaths { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if potentialFilesArtifact, ok := pyg.filesArtifactIndex[fileArtifactName]; ok { - filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Uuid: potentialFilesArtifact.Uuid, - Name: potentialFilesArtifact.Name, - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Name: fileArtifactName, - Uuid: strconv.Itoa(pyg.generateUuid()), - } - // add to the index and append to the plan yaml - pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) - pyg.filesArtifactIndex[fileArtifactName] = filesArtifact - } - - task.Files = append(task.Files, &FileMount{ - MountPath: mountPath, - FilesArtifacts: []*FilesArtifact{filesArtifact}, - }) - } - } - } - - // for store - // - all files artifacts product from store are new files artifact that are added to the plan - // - add them to files artifacts list - // - add them to the store section of run sh - var store []*FilesArtifact - storeSpecs, _ := tasks.ParseStoreFilesArg(pyg.serviceNetwork, arguments) - // TODO: catch this error - //if err != startosis_errors.WrapWithInterpretationError(nil, "") { catch this error - // return err - //} - for _, storeSpec := range storeSpecs { - // add the FilesArtifact to list of all files artifacts and index - uuid := strconv.Itoa(pyg.generateUuid()) - var newFilesArtifactFromStoreSpec = &FilesArtifact{ - Uuid: uuid, - Name: storeSpec.GetName(), - Files: []string{storeSpec.GetSrc()}, - } - pyg.filesArtifactIndex[storeSpec.GetName()] = newFilesArtifactFromStoreSpec - pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, newFilesArtifactFromStoreSpec) - store = append(store, &FilesArtifact{ //nolint:exhaustruct - Uuid: uuid, - Name: storeSpec.GetName(), - }) - } - task.Store = store // TODO: be consistent about how I'm setting lists in the plan yamls, probably should add wrappers to the plan yaml - - // add task to index, do we even need a tasks index? - pyg.planYaml.Tasks = append(pyg.planYaml.Tasks, task) - return nil -} - -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromStoreServiceFiles(storeServiceFilesInstruction *instructions_plan.ScheduledInstruction) error { - var filesArtifact *FilesArtifact - - // get the name of returned files artifact - filesArtifactName, castErr := kurtosis_types.SafeCastToString(storeServiceFilesInstruction.GetReturnedValue(), "files artifact name") - if castErr != nil { - return castErr - } - filesArtifact = &FilesArtifact{ //nolint:exhaustruct - Uuid: strconv.Itoa(pyg.generateUuid()), - Name: filesArtifactName, - } - - arguments := storeServiceFilesInstruction.GetInstruction().GetArguments() - - // parse for files - src, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, store_service_files.SrcArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", store_service_files.SrcArgName) - } - filesArtifact.Files = []string{src.GoString()} - - // add it to the index and the plan yaml - pyg.filesArtifactIndex[filesArtifactName] = filesArtifact - pyg.planYaml.FilesArtifacts = append(pyg.planYaml.FilesArtifacts, filesArtifact) - return nil -} - -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instructions_plan.ScheduledInstruction) error { - // TODO: update the plan yaml based on an add_service - var task *Task - taskUuid := pyg.generateUuid() - - // store future references - returnValue := execInstruction.GetReturnedValue() - execDict, ok := returnValue.(*starlark.Dict) - if !ok { - return stacktrace.NewError("Casting exec return value to a struct didn't work") - } - starlarkCodeVal, found, err := execDict.Get(starlark.String("code")) - if err != nil { - return err - } - if !found { - return stacktrace.NewError("No code value found on exec dict") - } - starlarkCodeFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkCodeVal, "exec code") - if interpErr != nil { - return interpErr - } - pyg.futureReferenceIndex[starlarkCodeFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.code }}", taskUuid) - starlarkOutputVal, found, err := execDict.Get(starlark.String("output")) - if err != nil { - return err - } - if !found { - return stacktrace.NewError("No code value found on exec dict") - } - starlarkOutputFutureRefStr, interpErr := kurtosis_types.SafeCastToString(starlarkOutputVal, "exec output") - if interpErr != nil { - return interpErr - } - pyg.futureReferenceIndex[starlarkOutputFutureRefStr] = fmt.Sprintf("{{ kurtosis.%v.output }}", taskUuid) - - arguments := execInstruction.GetInstruction().GetArguments() - serviceNameArgumentValue, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, exec.ServiceNameArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", exec.ServiceNameArgName) - } - task = &Task{ //nolint:exhaustruct - ServiceName: serviceNameArgumentValue.GoString(), - TaskType: EXEC, - Uuid: strconv.Itoa(taskUuid), - } - - execRecipe, err := builtin_argument.ExtractArgumentValue[*recipe.ExecRecipe](arguments, exec.RecipeArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", exec.RecipeArgName) - } - commandStarlarkList, _, interpretationErr := kurtosis_type_constructor.ExtractAttrValue[*starlark.List](execRecipe.KurtosisValueTypeDefault, recipe.CommandAttr) - if interpretationErr != nil { - return interpretationErr - } - // Convert Starlark list to Go slice - cmdList, sliceParsingErr := kurtosis_types.SafeCastToStringSlice(commandStarlarkList, tasks.PythonArgumentsArgName) - if sliceParsingErr != nil { - return startosis_errors.WrapWithInterpretationError(err, "error occurred while converting Starlark list of passed arguments to a golang string slice") - } - for idx, cmd := range cmdList { - cmdList[idx] = pyg.swapFutureReference(cmd) - } - task.RunCmd = cmdList - - acceptableCodes := []int64{0} - if arguments.IsSet(exec.AcceptableCodesArgName) { - acceptableCodesValue, err := builtin_argument.ExtractArgumentValue[*starlark.List](arguments, exec.AcceptableCodesArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%v' argument", acceptableCodes) - } - acceptableCodes, err = kurtosis_types.SafeCastToIntegerSlice(acceptableCodesValue) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to parse '%v' argument", acceptableCodes) - } - } - task.AcceptableCodes = acceptableCodes - - pyg.planYaml.Tasks = append(pyg.planYaml.Tasks, task) - return nil -} - -func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromRemoveService(removeServiceInstruction *instructions_plan.ScheduledInstruction) error { - arguments := removeServiceInstruction.GetInstruction().GetArguments() - - serviceName, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, remove_service.ServiceNameArgName) - if err != nil { - return startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", remove_service.ServiceNameArgName) - } - - delete(pyg.serviceIndex, serviceName.GoString()) - - for idx, service := range pyg.planYaml.Services { - if service.Name == serviceName.GoString() { - pyg.planYaml.Services[idx] = pyg.planYaml.Services[len(pyg.planYaml.Services)-1] - pyg.planYaml.Services = pyg.planYaml.Services[:len(pyg.planYaml.Services)-1] - return nil - } - } - - return nil -} - -func convertPlanYamlToYaml(planYaml *PlanYaml) ([]byte, error) { - // unravel all the indices and add them to the plan - // add some sort of tie breaking so yaml's are deterministic - - yamlBytes, err := yaml.Marshal(planYaml) - if err != nil { - return []byte{}, err - } - return yamlBytes, nil -} - -func getBuiltinNameFromInstruction(instruction *instructions_plan.ScheduledInstruction) string { - return instruction.GetInstruction().GetCanonicalInstruction(false).GetInstructionName() -} - -func (pyg *PlanYamlGeneratorImpl) generateUuid() int { - pyg.uuidGenerator++ - return pyg.uuidGenerator -} - -// if the string is a future reference, it swaps it out with what it should be -// else the string s is the same -func (pyg *PlanYamlGeneratorImpl) swapFutureReference(s string) string { - newString := s - for futureRef, swappedValue := range pyg.futureReferenceIndex { - if strings.Contains(s, futureRef) { - newString = strings.Replace(s, futureRef, swappedValue, -1) - } - } - return newString -} diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go deleted file mode 100644 index efe39a9d29..0000000000 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ /dev/null @@ -1,612 +0,0 @@ -package startosis_engine - -import ( - "context" - "fmt" - "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/service" - "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/database_accessors/enclave_db/file_artifacts_db" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_plan_persistence" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/interpretation_time_value_store" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/shared_helpers" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_constants" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_packages/mock_package_content_provider" - "github.com/kurtosis-tech/kurtosis/core/server/commons/enclave_data_directory" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - "net" - "os" - "testing" -) - -type PlanYamlGeneratorTestSuite struct { - suite.Suite - serviceNetwork *service_network.MockServiceNetwork - packageContentProvider *mock_package_content_provider.MockPackageContentProvider - runtimeValueStore *runtime_value_store.RuntimeValueStore - kurtosisBackend *backend_interface.KurtosisBackend - filesArtifactStore *enclave_data_directory.FilesArtifactStore - interpretationTimeValueStore *interpretation_time_value_store.InterpretationTimeValueStore - - interpreter *StartosisInterpreter - validator *StartosisValidator - executor *StartosisExecutor - runner *StartosisRunner -} - -func (suite *PlanYamlGeneratorTestSuite) SetupTest() { - // mock package content provider - suite.packageContentProvider = mock_package_content_provider.NewMockPackageContentProvider() - enclaveDb := getEnclaveDBForTest(suite.T()) - - dummySerde := shared_helpers.NewDummyStarlarkValueSerDeForTest() - - // mock runtime value store - runtimeValueStore, err := runtime_value_store.CreateRuntimeValueStore(dummySerde, enclaveDb) - require.NoError(suite.T(), err) - suite.runtimeValueStore = runtimeValueStore - - // mock interpretation time value store - interpretationTimeValueStore, err := interpretation_time_value_store.CreateInterpretationTimeValueStore(enclaveDb, dummySerde) - require.NoError(suite.T(), err) - suite.interpretationTimeValueStore = interpretationTimeValueStore - // mock service network - suite.serviceNetwork = service_network.NewMockServiceNetwork(suite.T()) - - service.NewServiceRegistration( - testServiceName, - service.ServiceUUID(fmt.Sprintf("%s-%s", testServiceName, serviceUuidSuffix)), - mockEnclaveUuid, - testServiceIpAddress, - string(testServiceName), - ) - suite.serviceNetwork.EXPECT().GetUniqueNameForFileArtifact().Maybe().Return(mockFileArtifactName, nil) - suite.serviceNetwork.EXPECT().GetEnclaveUuid().Maybe().Return(enclave.EnclaveUUID(mockEnclaveUuid)) - suite.serviceNetwork.EXPECT().ExistServiceRegistration(testServiceName).Maybe().Return(true, nil) - apiContainerInfo := service_network.NewApiContainerInfo( - net.IP{}, - mockApicPortNum, - mockApicVersion) - suite.serviceNetwork.EXPECT().GetApiContainerInfo().Return(apiContainerInfo) - - suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "", suite.interpretationTimeValueStore) - - // mock kurtosis backend? - - // mock files artifact for testing - timesCalled := 0 - mockedGenerateNameMethod := func() string { - timesCalled = timesCalled + 1 - if timesCalled == 4 { - return "last-noun" - } - return "adjective-noun" - } - - artifactIdToUUIDMap := map[string]string{} - - fileArtifactDb, err := file_artifacts_db.GetFileArtifactsDbForTesting(enclaveDb, artifactIdToUUIDMap) - require.Nil(suite.T(), err) - - suite.filesArtifactStore = enclave_data_directory.NewFilesArtifactStoreForTesting("/", "/", fileArtifactDb, 3, mockedGenerateNameMethod) - suite.validator = NewStartosisValidator(suite.kurtosisBackend, suite.serviceNetwork, suite.filesArtifactStore) - - // mock the starlark value serde? - suite.executor = NewStartosisExecutor(nil, suite.runtimeValueStore, enclave_plan_persistence.NewEnclavePlan(), enclaveDb) - - suite.runner = NewStartosisRunner(suite.interpreter, suite.validator, suite.executor) -} - -func TestRunPlanYamlGeneratorTestSuite(t *testing.T) { - suite.Run(t, new(PlanYamlGeneratorTestSuite)) -} - -func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { - suite.packageContentProvider.RemoveAll() -} - -func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { - dockerfileModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server/Dockerfile" - serverModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server" - dockerfileContents := `` - - require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(dockerfileModulePath, dockerfileContents)) - require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(serverModulePath, "")) - - packageId := "github.com/kurtosis-tech/plan-yaml-prac" - mainFunctionName := "" - relativePathToMainFile := "main.star" - - serializedScript := `def run(plan, args): - plan.add_service( - name="db", - config=ServiceConfig( - image="postgres:latest", - env_vars={ - "POSTGRES_DB": "tedi", - "POSTGRES_USER": "tedi", - "POSTGRES_PASSWORD": "tedi", - } - ) - ) - result = plan.exec( - service_name="db", - recipe=ExecRecipe(command=["echo", "Hello, world"]), - acceptable_codes=[0], - ) - plan.print(result) - plan.add_service( - name="db2", - config=ServiceConfig( - image="postgres:latest", - env_vars={ - "POSTGRES_DB": result["code"], - "POSTGRES_USER": result["output"], - "POSTGRES_PASSWORD": "tedi", - } - ) - ) -` - serializedJsonParams := "{}" - _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) - require.Nil(suite.T(), interpretationError) - - pyg := NewPlanYamlGenerator( - instructionsPlan, - suite.serviceNetwork, - packageId, - suite.packageContentProvider, - noPackageReplaceOptions, - ) - yamlBytes, err := pyg.GenerateYaml() - require.NoError(suite.T(), err) - - err = os.WriteFile("./plan.yml", yamlBytes, 0644) - require.NoError(suite.T(), err) -} - -func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorVerySimpleScript() { - script := ` -def run(plan): - service_name = "partyService" - config = ServiceConfig( - image = "` + testContainerImageName + `", - ports = { - "grpc": PortSpec(number = 1323, transport_protocol = "TCP", application_protocol = "http") - }, - ) - datastore_service = plan.add_service(name = service_name, config = config) -` - - _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, useDefaultMainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, script, startosis_constants.EmptyInputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) - require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 1, instructionsPlan.Size()) - - pyg := NewPlanYamlGenerator( - instructionsPlan, - suite.serviceNetwork, - startosis_constants.PackageIdPlaceholderForStandaloneScript, - suite.packageContentProvider, - noPackageReplaceOptions) - yamlBytes, err := pyg.GenerateYaml() - require.NoError(suite.T(), err) - - expectedYamlString := - `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT -services: -- name: partyService - image: kurtosistech/example-datastore-server - ports: - - name: grpc - number: 1323 - transportProtocol: TCP - applicationProtocol: http -` - require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) -} - -func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorSimplerScripButNotSoSimple() { - script := ` -def run(plan): - - service_name = "partyService" - - config = ServiceConfig( - image = "` + testContainerImageName + `", - cmd=["echo", "Hello"], - ports = { - "grpc": PortSpec(number = 1323, transport_protocol = "TCP", application_protocol = "http") - }, - env_vars = { - "POSTGRES_DB": "tedi", - "POSTGRES_USERNAME": "dag", - }, - files = { - "/usr/": "", # TODO: how do you model a files artifact - "/bin/": "", # TODO: how do you model a files artifact - } - ) - datastore_service = plan.add_service(name = service_name, config = config) -` - - _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, useDefaultMainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, script, startosis_constants.EmptyInputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) - require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 1, instructionsPlan.Size()) - - pyg := NewPlanYamlGenerator( - instructionsPlan, - suite.serviceNetwork, - startosis_constants.PackageIdPlaceholderForStandaloneScript, - suite.packageContentProvider, - noPackageReplaceOptions) - yamlBytes, err := pyg.GenerateYaml() - require.NoError(suite.T(), err) - - expectedYamlString := - `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT -services: -- name: partyService - image: kurtosistech/example-datastore-server - ports: - - name: grpc - number: 1323 - transportProtocol: TCP - applicationProtocol: http -` - require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) -} - -func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorSimpleScript() { - script := ` -service_name = "example-datastore-server" -ports = [1323, 1324, 1325] - -def deploy_datastore_services(plan): - for i in range(len(ports)): - unique_service_name = service_name + "-" + str(i) - plan.print("Adding service " + unique_service_name) - config = ServiceConfig( - image = "` + testContainerImageName + `", - ports = { - "grpc": PortSpec( - number = ports[i], - transport_protocol = "TCP" - ) - } - ) - - plan.add_service(name = unique_service_name, config = config) - -def run(plan): - plan.print("Starting Startosis script!") - deploy_datastore_services(plan) - plan.print("Done!") -` - - _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, useDefaultMainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, script, startosis_constants.EmptyInputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) - require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 8, instructionsPlan.Size()) - - pyg := NewPlanYamlGenerator( - instructionsPlan, - suite.serviceNetwork, - startosis_constants.PackageIdPlaceholderForStandaloneScript, - suite.packageContentProvider, - noPackageReplaceOptions) - yamlBytes, err := pyg.GenerateYaml() - require.NoError(suite.T(), err) - - expectedYamlString := `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT -services: -- name: partyService - image: kurtosistech/example-datastore-server - ports: - - name: grpc - number: 1323 - transportProtocol: TCP - applicationProtocol: http -` - require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) -} - -func (suite *PlanYamlGeneratorTestSuite) TestConvertPlanYamlToYamlBytes(t *testing.T) { - PackageId := "github.com/kurtosis-tech/postgres-package" - - services := []*Service{ - { - Name: "tedi", - Uuid: "1", - Image: &ImageSpec{ - ImageName: "postgres", - BuildContextLocator: "", - TargetStage: "", - Registry: "", - }, - EnvVars: []*EnvironmentVariable{ - { - Key: "kevin", - Value: "dag", - }, - }, - }, - { - Name: "kaleb", - Uuid: "1", - Image: &ImageSpec{ - ImageName: "something", - BuildContextLocator: "", - TargetStage: "", - Registry: "", - }, - EnvVars: []*EnvironmentVariable{ - { - Key: "kevin", - Value: "dag", - }, - }, - }, - } - filesArtifacts := []*FilesArtifact{ - { - Uuid: "3", - Name: "something", - Files: nil, - }, - } - tasks := []*Task{ - { - TaskType: PYTHON, - Image: "jqcurl", - EnvVars: []*EnvironmentVariable{}, - }, - } - - planYaml := PlanYaml{ - PackageId: PackageId, - Services: services, - FilesArtifacts: filesArtifacts, - Tasks: tasks, - } - - yamlBytes, err := convertPlanYamlToYaml(&planYaml) - require.NoError(t, err) - - expectedYamlString := `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT -services: -- name: partyService - image: kurtosistech/example-datastore-server - ports: - - name: grpc - number: 1323 - transportProtocol: TCP - applicationProtocol: http -` - require.Equal(t, expectedYamlString, string(yamlBytes)) -} - -func (suite *PlanYamlGeneratorTestSuite) TestPlanYamlGeneratorPostgresPackageSimplified() { - packageId := "github.com/kurtosis-tech/postgres-package" - mainFunctionName := "" - relativePathToMainFile := "main.star" - - serializedPostgresPackageStarlark := `PORT_NAME = "postgresql" -APPLICATION_PROTOCOL = "postgresql" -PG_DRIVER = "pgsql" - -CONFIG_FILE_MOUNT_DIRPATH = "/config" -SEED_FILE_MOUNT_PATH = "/docker-entrypoint-initdb.d" -DATA_DIRECTORY_PATH = "/data/" - -CONFIG_FILENAME = "postgresql.conf" # Expected to be in the artifact - -POSTGRES_MIN_CPU = 10 -POSTGRES_MAX_CPU = 1000 -POSTGRES_MIN_MEMORY = 32 -POSTGRES_MAX_MEMORY = 1024 - -def run( - plan, - image="postgres:alpine", - service_name="postgres", - user="postgres", - password="MyPassword1!", - database="postgres", - config_file_artifact_name="", - seed_file_artifact_name="", - extra_configs=[], - persistent=True, - launch_adminer=False, - min_cpu=POSTGRES_MIN_CPU, - max_cpu=POSTGRES_MAX_CPU, - min_memory=POSTGRES_MIN_MEMORY, - max_memory=POSTGRES_MAX_MEMORY, - node_selectors=None, -): - cmd = [] # 34 - files = {} - env_vars = { - "POSTGRES_DB": database, - "POSTGRES_USER": user, - "POSTGRES_PASSWORD": password, - } - - if persistent: - files[DATA_DIRECTORY_PATH] = Directory( - persistent_key= "data-{0}".format(service_name), - ) - env_vars["PGDATA"] = DATA_DIRECTORY_PATH + "/pgdata" - if node_selectors == None: - node_selectors = {} - if config_file_artifact_name != "": - config_filepath = CONFIG_FILE_MOUNT_DIRPATH + "/" + CONFIG_FILENAME - cmd += ["-c", "config_file=" + config_filepath] - files[CONFIG_FILE_MOUNT_DIRPATH] = config_file_artifact_name - - # append cmd with postgres config overrides passed by users - if len(extra_configs) > 0: - for config in extra_configs: - cmd += ["-c", config] - - if seed_file_artifact_name != "": - files[SEED_FILE_MOUNT_PATH] = seed_file_artifact_name - - postgres_service = plan.add_service( - name=service_name, - config=ServiceConfig( - image=image, - ports={ - PORT_NAME: PortSpec( - number=5432, - application_protocol=APPLICATION_PROTOCOL, - ) - }, - cmd=cmd, - files=files, - env_vars=env_vars, - min_cpu=min_cpu, - max_cpu=max_cpu, - min_memory=min_memory, - max_memory=max_memory, - node_selectors=node_selectors, - ), - ) - - url = "{protocol}://{user}:{password}@{hostname}/{database}".format( - protocol=APPLICATION_PROTOCOL, - user=user, - password=password, - hostname=postgres_service.hostname, - database=database, - ) - - return struct( - url=url, - service=postgres_service, - port=postgres_service.ports[PORT_NAME], - user=user, - password=password, - database=database, - min_cpu=min_cpu, - max_cpu=max_cpu, - min_memory=min_memory, - max_memory=max_memory, - node_selectors=node_selectors, - ) -` - serializedJsonParams := "{}" - _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedPostgresPackageStarlark, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) - require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 1, instructionsPlan.Size()) - - pyg := NewPlanYamlGenerator( - instructionsPlan, - suite.serviceNetwork, - packageId, - suite.packageContentProvider, - noPackageReplaceOptions, - ) - yamlBytes, err := pyg.GenerateYaml() - require.NoError(suite.T(), err) - - expectedYamlString := `packageId: github.com/kurtosis-tech/postgres-package -services: -- name: postgres - image: postgres:alpine - envVars: - - key: POSTGRES_USER - value: postgres - - key: POSTGRES_PASSWORD - value: MyPassword1! - - key: PGDATA - value: /data//pgdata - - key: POSTGRES_DB - value: postgres - ports: - - name: postgresql - number: 5432 - transportProtocol: TCP - applicationProtocol: postgresql - files: - -` - require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) -} - -func (suite *PlanYamlGeneratorTestSuite) TestSimpleScriptWithFilesArtifact() { - packageId := "github.com/kurtosis-tech/plan-yaml-prac" - mainFunctionName := "" - relativePathToMainFile := "main.star" - - serializedScript := `def run(plan, args): - hi_files_artifact = plan.render_templates( - config={ - "hi.txt":struct( - template="hello world!", - data={} - ) - }, - name="hi-file" - ) - - plan.add_service( - name="tedi", - config=ServiceConfig( - image="ubuntu:latest", - cmd=["cat", "/root/hi.txt"], - ports={ - "dashboard":PortSpec( - number=1234, - application_protocol="http", - transport_protocol="TCP" - ) - }, - env_vars={ - "PASSWORD": "tedi" - }, - files={ - "/root": hi_files_artifact, - } - ) - ) -` - serializedJsonParams := "{}" - _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) - require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 2, instructionsPlan.Size()) - - pyg := NewPlanYamlGenerator( - instructionsPlan, - suite.serviceNetwork, - packageId, - suite.packageContentProvider, - noPackageReplaceOptions, - ) - yamlBytes, err := pyg.GenerateYaml() - require.NoError(suite.T(), err) - - expectedYamlString := `packageId: github.com/kurtosis-tech/postgres-package -services: -- name: postgres - image: postgres:alpine - envVars: - - key: POSTGRES_USER - value: postgres - - key: POSTGRES_PASSWORD - value: MyPassword1! - - key: PGDATA - value: /data//pgdata - - key: POSTGRES_DB - value: postgres - ports: - - name: postgresql - number: 5432 - transportProtocol: TCP - applicationProtocol: postgresql - files: - -` - require.Equal(suite.T(), expectedYamlString, string(yamlBytes)) -} From 4857aed36a43b45cd6b693b825bf2914629aa8ef Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 11 Mar 2024 12:48:03 -0400 Subject: [PATCH 63/75] separate into a file --- .../startosis_engine/plan_yaml/plan_yaml.go | 510 +----------------- .../plan_yaml/plan_yaml_generator.go | 502 +++++++++++++++++ .../startosis_interpreter_plan_yaml_test.go | 7 +- 3 files changed, 506 insertions(+), 513 deletions(-) create mode 100644 core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index debb5e89b1..eed087e8f5 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -1,18 +1,5 @@ package plan_yaml -import ( - "fmt" - "github.com/go-yaml/yaml" - "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service" - store_spec2 "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/store_spec" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" - "github.com/kurtosis-tech/stacktrace" - "go.starlark.net/starlark" - "go.starlark.net/starlarkstruct" - "strconv" - "strings" -) - const ( HTTP ApplicationProtocol = "HTTP" UDP TransportProtocol = "UDP" @@ -23,13 +10,12 @@ const ( EXEC TaskType = "exec" ) -// PlanYaml is a yaml representation of the effect of an "plan" or sequence of instructions on the state of the Enclave. +// PlanYaml is a yaml representation of the effect of an Instructions Plan or sequence of instructions on the state of the Enclave. type PlanYaml struct { privatePlanYaml *privatePlanYaml futureReferenceIndex map[string]string filesArtifactIndex map[string]*FilesArtifact - serviceIndex map[string]*Service latestUuid int } @@ -122,497 +108,3 @@ type Task struct { // TaskType represents the type of task (either PYTHON or SHELL) type TaskType string - -func CreateEmptyPlan(packageId string) *PlanYaml { - return &PlanYaml{ - privatePlanYaml: &privatePlanYaml{ - PackageId: packageId, - Services: []*Service{}, - Tasks: []*Task{}, - FilesArtifacts: []*FilesArtifact{}, - }, - serviceIndex: map[string]*Service{}, - futureReferenceIndex: map[string]string{}, - filesArtifactIndex: map[string]*FilesArtifact{}, - } -} - -func (planYaml *PlanYaml) GenerateYaml() (string, error) { - yamlBytes, err := yaml.Marshal(planYaml.privatePlanYaml) - if err != nil { - return "", err - } - return string(yamlBytes), nil -} - -func (planYaml *PlanYaml) AddService( - serviceName service.ServiceName, - serviceInfo *kurtosis_types.Service, - serviceConfig *service.ServiceConfig, - imageValue starlark.Value, -) error { - uuid := planYaml.generateUuid() - - // store future references of this service - ipAddrFutureRef, err := serviceInfo.GetIpAddress() - if err != nil { - return err - } - hostnameFutureRef, err := serviceInfo.GetHostname() - if err != nil { - return err - } - planYaml.storeFutureReference(uuid, ipAddrFutureRef, "ip_address") - planYaml.storeFutureReference(uuid, hostnameFutureRef, "hostname") - - // construct service yaml object for plan - serviceYaml := &Service{} - serviceYaml.Uuid = uuid - - serviceYaml.Name = planYaml.swapFutureReference(string(serviceName)) - - image := &ImageSpec{ //nolint:exhaustruct - ImageName: serviceConfig.GetContainerImageName(), - } - //imageBuildSpec := serviceConfig.GetImageBuildSpec() - //if imageBuildSpec != nil { - // // Need the raw imageValue to get the build context locator - // switch starlarkImgVal := imageValue.(type) { - // case *service_config.ImageBuildSpec: // importing service_config.ImageBuildSpec causes a dependency issue figure that out later - // contextLocator, err := starlarkImgVal.GetBuildContextLocator() - // if err != nil { - // return err - // } - // image.BuildContextLocator = contextLocator - // default: - // return stacktrace.NewError("An image build spec was detected on the kurtosis type service config but the starlark image value was not an ImageBuildSpec type.") - // } - // image.TargetStage = imageBuildSpec.GetTargetStage() - //} - //imageSpec := serviceConfig.GetImageRegistrySpec() - //if imageSpec != nil { - // image.Registry = imageSpec.GetRegistryAddr() - //} - serviceYaml.Image = image - - cmdArgs := []string{} - for _, cmdArg := range serviceConfig.GetCmdArgs() { - realCmdArg := planYaml.swapFutureReference(cmdArg) - cmdArgs = append(cmdArgs, realCmdArg) - } - serviceYaml.Cmd = cmdArgs - - entryArgs := []string{} - for _, entryArg := range serviceConfig.GetEntrypointArgs() { - realEntryArg := planYaml.swapFutureReference(entryArg) - entryArgs = append(entryArgs, realEntryArg) - } - serviceYaml.Entrypoint = entryArgs - - serviceYaml.Ports = []*Port{} - for portName, configPort := range serviceConfig.GetPrivatePorts() { // TODO: support public ports - var applicationProtocolStr string - if configPort.GetMaybeApplicationProtocol() != nil { - applicationProtocolStr = *configPort.GetMaybeApplicationProtocol() - } - port := &Port{ - TransportProtocol: TransportProtocol(configPort.GetTransportProtocol().String()), - ApplicationProtocol: ApplicationProtocol(applicationProtocolStr), // TODO: write a test for this, dereferencing config port is not a good idea - Name: portName, - Number: configPort.GetNumber(), - } - serviceYaml.Ports = append(serviceYaml.Ports, port) - } - - serviceYaml.EnvVars = []*EnvironmentVariable{} - for key, val := range serviceConfig.GetEnvVars() { - envVar := &EnvironmentVariable{ - Key: key, - Value: planYaml.swapFutureReference(val), - } - serviceYaml.EnvVars = append(serviceYaml.EnvVars, envVar) - } - - // file mounts have two cases: - // 1. the referenced files artifact already exists in the plan, in which case add the referenced files artifact - // 2. the referenced files artifact does not already exist in the plan, in which case the file MUST have been passed in via a top level arg OR is invalid - // for this case, - // - create new files artifact - // - add it to the service's file mount accordingly - // - add the files artifact to the plan - serviceYaml.Files = []*FileMount{} - serviceFilesArtifactExpansions := serviceConfig.GetFilesArtifactsExpansion() - if serviceFilesArtifactExpansions != nil { - for mountPath, artifactIdentifiers := range serviceFilesArtifactExpansions.ServiceDirpathsToArtifactIdentifiers { - var serviceFilesArtifacts []*FilesArtifact - for _, identifier := range artifactIdentifiers { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if filesArtifactToReference, ok := planYaml.filesArtifactIndex[identifier]; ok { - filesArtifact = &FilesArtifact{ - Name: filesArtifactToReference.Name, - Uuid: filesArtifactToReference.Uuid, - Files: []string{}, // leave empty because this is referencing an existing files artifact - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args of run function - filesArtifact = &FilesArtifact{ - Name: identifier, - Uuid: planYaml.generateUuid(), - Files: []string{}, // don't know at interpretation what files are on the artifact when passed in via args - } - planYaml.addFilesArtifactYaml(filesArtifact) - } - serviceFilesArtifacts = append(serviceFilesArtifacts, filesArtifact) - } - - serviceYaml.Files = append(serviceYaml.Files, &FileMount{ - MountPath: mountPath, - FilesArtifacts: serviceFilesArtifacts, - }) - } - - } - - planYaml.addServiceYaml(serviceYaml) - return nil -} - -func (planYaml *PlanYaml) AddRunSh( - runCommand string, - returnValue *starlarkstruct.Struct, - serviceConfig *service.ServiceConfig, - storeSpecList []*store_spec2.StoreSpec, -) error { - uuid := planYaml.generateUuid() - - // store run sh future references - codeVal, err := returnValue.Attr("code") - if err != nil { - return err - } - codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "run sh code") - if interpErr != nil { - return interpErr - } - planYaml.storeFutureReference(uuid, codeFutureRef, "code") - outputVal, err := returnValue.Attr("output") - if err != nil { - return err - } - outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "run sh code") - if interpErr != nil { - return interpErr - } - planYaml.storeFutureReference(uuid, outputFutureRef, "output") - - // create task yaml object - taskYaml := &Task{} - taskYaml.Uuid = uuid - taskYaml.TaskType = SHELL - - taskYaml.RunCmd = []string{runCommand} - taskYaml.Image = serviceConfig.GetContainerImageName() - - var envVars []*EnvironmentVariable - for key, val := range serviceConfig.GetEnvVars() { - envVars = append(envVars, &EnvironmentVariable{ - Key: key, - Value: planYaml.swapFutureReference(val), - }) - } - taskYaml.EnvVars = envVars - - // for files: - // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid - // 2. the referenced files artifact is new, in which case we add it to the plan - for mountPath, fileArtifactNames := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { - var filesArtifacts []*FilesArtifact - for _, filesArtifactName := range fileArtifactNames { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if filesArtifactToReference, ok := planYaml.filesArtifactIndex[filesArtifactName]; ok { - filesArtifact = &FilesArtifact{ - Name: filesArtifactToReference.Name, - Uuid: filesArtifactToReference.Uuid, - Files: []string{}, - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ - Name: filesArtifactName, - Uuid: planYaml.generateUuid(), - Files: []string{}, - } - planYaml.addFilesArtifactYaml(filesArtifact) - } - filesArtifacts = append(filesArtifacts, filesArtifact) - } - - taskYaml.Files = append(taskYaml.Files, &FileMount{ - MountPath: mountPath, - FilesArtifacts: filesArtifacts, - }) - } - - // for store - // - all files artifacts product from store are new files artifact that are added to the plan - // - add them to files artifacts list - // - add them to the store section of run sh - var store []*FilesArtifact - for _, storeSpec := range storeSpecList { - var newFilesArtifactFromStoreSpec = &FilesArtifact{ - Uuid: planYaml.generateUuid(), - Name: storeSpec.GetName(), - Files: []string{storeSpec.GetSrc()}, - } - planYaml.addFilesArtifactYaml(newFilesArtifactFromStoreSpec) - - store = append(store, &FilesArtifact{ - Uuid: newFilesArtifactFromStoreSpec.Uuid, - Name: newFilesArtifactFromStoreSpec.Name, - Files: []string{}, // don't want to repeat the files on a referenced files artifact - }) - } - taskYaml.Store = store - - planYaml.addTaskYaml(taskYaml) - return nil -} - -func (planYaml *PlanYaml) AddRunPython( - runCommand string, - returnValue *starlarkstruct.Struct, - serviceConfig *service.ServiceConfig, - storeSpecList []*store_spec2.StoreSpec, - pythonArgs []string, - pythonPackages []string) error { - uuid := planYaml.generateUuid() - - // store future references - codeVal, err := returnValue.Attr("code") - if err != nil { - return err - } - codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "run python code") - if interpErr != nil { - return interpErr - } - planYaml.storeFutureReference(uuid, codeFutureRef, "code") - outputVal, err := returnValue.Attr("output") - if err != nil { - return err - } - outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "run python output") - if interpErr != nil { - return interpErr - } - planYaml.storeFutureReference(uuid, outputFutureRef, "output") - - // create task yaml arg - taskYaml := &Task{} - taskYaml.Uuid = uuid - taskYaml.TaskType = PYTHON - - taskYaml.RunCmd = []string{runCommand} - taskYaml.Image = serviceConfig.GetContainerImageName() - - var envVars []*EnvironmentVariable - for key, val := range serviceConfig.GetEnvVars() { - envVars = append(envVars, &EnvironmentVariable{ - Key: key, - Value: planYaml.swapFutureReference(val), - }) - } - taskYaml.EnvVars = envVars - - // python args and python packages - taskYaml.PythonArgs = append(taskYaml.PythonArgs, pythonArgs...) - taskYaml.PythonPackages = append(taskYaml.PythonPackages, pythonPackages...) - - // for files: - // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid - // 2. the referenced files artifact is new, in which case we add it to the plan - for mountPath, fileArtifactNames := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { - var filesArtifacts []*FilesArtifact - for _, filesArtifactName := range fileArtifactNames { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if filesArtifactToReference, ok := planYaml.filesArtifactIndex[filesArtifactName]; ok { - filesArtifact = &FilesArtifact{ - Name: filesArtifactToReference.Name, - Uuid: filesArtifactToReference.Uuid, - Files: []string{}, - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ - Name: filesArtifactName, - Uuid: planYaml.generateUuid(), - Files: []string{}, - } - planYaml.addFilesArtifactYaml(filesArtifact) - } - filesArtifacts = append(filesArtifacts, filesArtifact) - } - - taskYaml.Files = append(taskYaml.Files, &FileMount{ - MountPath: mountPath, - FilesArtifacts: filesArtifacts, - }) - } - - // for store - // - all files artifacts product from store are new files artifact that are added to the plan - // - add them to files artifacts list - // - add them to the store section of run sh - var store []*FilesArtifact - for _, storeSpec := range storeSpecList { - var newFilesArtifactFromStoreSpec = &FilesArtifact{ - Uuid: planYaml.generateUuid(), - Name: storeSpec.GetName(), - Files: []string{storeSpec.GetSrc()}, - } - planYaml.addFilesArtifactYaml(newFilesArtifactFromStoreSpec) - - store = append(store, &FilesArtifact{ - Uuid: newFilesArtifactFromStoreSpec.Uuid, - Name: newFilesArtifactFromStoreSpec.Name, - Files: []string{}, // don't want to repeat the files on a referenced files artifact - }) - } - taskYaml.Store = store - - // add task to index, do we even need a tasks index? - planYaml.addTaskYaml(taskYaml) - return nil -} - -func (planYaml *PlanYaml) AddExec( - serviceName string, - returnValue *starlark.Dict, - cmdList []string, - acceptableCodes []int64) error { - uuid := planYaml.generateUuid() - - // store future references - codeVal, found, err := returnValue.Get(starlark.String("code")) - if err != nil { - return err - } - if !found { - return stacktrace.NewError("No code value found on exec dict") - } - codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "exec code") - if interpErr != nil { - return interpErr - } - planYaml.storeFutureReference(uuid, codeFutureRef, "code") - outputVal, found, err := returnValue.Get(starlark.String("output")) - if err != nil { - return err - } - if !found { - return stacktrace.NewError("No code value found on exec dict") - } - outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "exec output") - if interpErr != nil { - return interpErr - } - planYaml.storeFutureReference(uuid, outputFutureRef, "output") - - // create task yaml - taskYaml := &Task{} - taskYaml.Uuid = uuid - taskYaml.TaskType = EXEC - taskYaml.ServiceName = serviceName - taskYaml.RunCmd = cmdList - taskYaml.AcceptableCodes = acceptableCodes - - planYaml.privatePlanYaml.Tasks = append(planYaml.privatePlanYaml.Tasks, taskYaml) - return nil -} - -func (planYaml *PlanYaml) AddRenderTemplates(filesArtifactName string, filepaths []string) error { - uuid := planYaml.generateUuid() - filesArtifactYaml := &FilesArtifact{} - filesArtifactYaml.Uuid = uuid - filesArtifactYaml.Name = filesArtifactName - filesArtifactYaml.Files = filepaths - planYaml.addFilesArtifactYaml(filesArtifactYaml) - return nil -} - -func (planYaml *PlanYaml) AddUploadFiles(filesArtifactName, locator string) error { - uuid := planYaml.generateUuid() - filesArtifactYaml := &FilesArtifact{} - filesArtifactYaml.Uuid = uuid - filesArtifactYaml.Name = filesArtifactName - filesArtifactYaml.Files = []string{locator} - planYaml.addFilesArtifactYaml(filesArtifactYaml) - return nil -} - -func (planYaml *PlanYaml) AddStoreServiceFiles(filesArtifactName, locator string) error { - uuid := planYaml.generateUuid() - filesArtifactYaml := &FilesArtifact{} - filesArtifactYaml.Uuid = uuid - filesArtifactYaml.Name = filesArtifactName - filesArtifactYaml.Files = []string{locator} - planYaml.addFilesArtifactYaml(filesArtifactYaml) - return nil -} - -func (planYaml *PlanYaml) RemoveService(serviceName string) error { - delete(planYaml.serviceIndex, serviceName) - for idx, service := range planYaml.privatePlanYaml.Services { - if service.Name == serviceName { - planYaml.privatePlanYaml.Services[idx] = planYaml.privatePlanYaml.Services[len(planYaml.privatePlanYaml.Services)-1] - planYaml.privatePlanYaml.Services = planYaml.privatePlanYaml.Services[:len(planYaml.privatePlanYaml.Services)-1] - return nil - } - } - return nil -} - -func (planYaml *PlanYaml) addServiceYaml(service *Service) { - planYaml.serviceIndex[service.Name] = service - planYaml.privatePlanYaml.Services = append(planYaml.privatePlanYaml.Services, service) -} - -func (planYaml *PlanYaml) addFilesArtifactYaml(filesArtifact *FilesArtifact) { - planYaml.filesArtifactIndex[filesArtifact.Name] = filesArtifact - // do we need both map and list structures? what about just map then resolve at the end? - planYaml.privatePlanYaml.FilesArtifacts = append(planYaml.privatePlanYaml.FilesArtifacts, filesArtifact) -} - -func (planYaml *PlanYaml) addTaskYaml(task *Task) { - planYaml.privatePlanYaml.Tasks = append(planYaml.privatePlanYaml.Tasks, task) -} - -// yaml future reference format: {{ kurtosis... Date: Mon, 11 Mar 2024 15:08:52 -0400 Subject: [PATCH 64/75] deterministically sort env vars --- .../startosis_engine/plan_yaml/plan_yaml.go | 20 +++++++++++++++---- .../startosis_interpreter_plan_yaml_test.go | 11 +++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index eed087e8f5..3dd9280781 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -1,10 +1,8 @@ package plan_yaml -const ( - HTTP ApplicationProtocol = "HTTP" - UDP TransportProtocol = "UDP" - TCP TransportProtocol = "TCP" +import "sort" +const ( SHELL TaskType = "sh" PYTHON TaskType = "python" EXEC TaskType = "exec" @@ -39,6 +37,13 @@ type Service struct { Files []*FileMount `yaml:"files,omitempty"` } +func (s *Service) MarshalYAML() (interface{}, error) { + sort.Slice(s.EnvVars, func(i, j int) bool { + return s.EnvVars[i].Key < s.EnvVars[j].Key + }) + return s, nil +} + type ImageSpec struct { ImageName string `yaml:"name,omitempty"` @@ -57,6 +62,13 @@ type FilesArtifact struct { Files []string `yaml:"files,omitempty"` } +func (f *FilesArtifact) MarshalYAML() (interface{}, error) { + sort.Slice(f.Files, func(i, j int) bool { + return f.Files[i] < f.Files[j] + }) + return f, nil +} + // EnvironmentVariable represents an environment variable. type EnvironmentVariable struct { Key string `yaml:"key,omitempty"` diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go index 6fc9ea3b9e..bb6288f7cf 100644 --- a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go @@ -15,6 +15,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "net" + "testing" ) const ( @@ -70,9 +71,9 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) SetupTest() { suite.interpreter = NewStartosisInterpreter(suite.serviceNetwork, suite.packageContentProvider, suite.runtimeValueStore, nil, "", suite.interpretationTimeValueStore) } -//func TestRunStartosisIntepreterPlanYamlTestSuite(t *testing.T) { -// suite.Run(t, new(StartosisIntepreterPlanYamlTestSuite)) -//} +func TestRunStartosisIntepreterPlanYamlTestSuite(t *testing.T) { + suite.Run(t, new(StartosisIntepreterPlanYamlTestSuite)) +} func (suite *StartosisIntepreterPlanYamlTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() @@ -332,10 +333,10 @@ services: envVars: - key: POSTGRES_DB value: kurtosis - - key: POSTGRES_USER - value: kurtosis - key: POSTGRES_PASSWORD value: kurtosis + - key: POSTGRES_USER + value: kurtosis files: - mountPath: /root filesArtifacts: From 5f6ca5d2f9e0686571c852b9373f91c5ee925e1f Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 11 Mar 2024 15:12:22 -0400 Subject: [PATCH 65/75] move plan yaml object --- .../server/startosis_engine/plan_yaml/plan_yaml.go | 9 --------- .../startosis_engine/plan_yaml/plan_yaml_generator.go | 10 ++++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index 3dd9280781..0bcf9c3924 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -8,15 +8,6 @@ const ( EXEC TaskType = "exec" ) -// PlanYaml is a yaml representation of the effect of an Instructions Plan or sequence of instructions on the state of the Enclave. -type PlanYaml struct { - privatePlanYaml *privatePlanYaml - - futureReferenceIndex map[string]string - filesArtifactIndex map[string]*FilesArtifact - latestUuid int -} - // TODO: pass by value instead of pass by reference type privatePlanYaml struct { PackageId string `yaml:"packageId,omitempty"` diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go index 243a5920e0..de7c4bec56 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go @@ -13,6 +13,15 @@ import ( "strings" ) +// PlanYaml is a yaml representation of the effect of an Instructions Plan or sequence of instructions on the state of the Enclave. +type PlanYaml struct { + privatePlanYaml *privatePlanYaml + + futureReferenceIndex map[string]string + filesArtifactIndex map[string]*FilesArtifact + latestUuid int +} + func CreateEmptyPlan(packageId string) *PlanYaml { return &PlanYaml{ privatePlanYaml: &privatePlanYaml{ @@ -23,6 +32,7 @@ func CreateEmptyPlan(packageId string) *PlanYaml { }, futureReferenceIndex: map[string]string{}, filesArtifactIndex: map[string]*FilesArtifact{}, + latestUuid: 0, } } From 6d5d8cc53de9aead473ccf8f7ccf94532c9633e1 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 11 Mar 2024 15:16:10 -0400 Subject: [PATCH 66/75] adjust remove service --- .../kurtosis_instruction/remove_service/remove_service.go | 5 +---- .../startosis_engine/plan_yaml/plan_yaml_generator.go | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go index 1213bd544c..e7dc571fda 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service/remove_service.go @@ -108,10 +108,7 @@ func (builtin *RemoveServiceCapabilities) FillPersistableAttributes(builder *enc } func (builtin *RemoveServiceCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - err := plan.RemoveService(string(builtin.serviceName)) - if err != nil { - return stacktrace.Propagate(err, "An error occurred updating plan with remove service.") - } + plan.RemoveService(string(builtin.serviceName)) return nil } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go index de7c4bec56..1848b2e6ef 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go @@ -465,16 +465,14 @@ func (planYaml *PlanYaml) AddStoreServiceFiles(filesArtifactName, locator string return nil } -func (planYaml *PlanYaml) RemoveService(serviceName string) error { - // is there a better way to do this? +func (planYaml *PlanYaml) RemoveService(serviceName string) { for idx, service := range planYaml.privatePlanYaml.Services { if service.Name == serviceName { planYaml.privatePlanYaml.Services[idx] = planYaml.privatePlanYaml.Services[len(planYaml.privatePlanYaml.Services)-1] planYaml.privatePlanYaml.Services = planYaml.privatePlanYaml.Services[:len(planYaml.privatePlanYaml.Services)-1] - return nil + return } } - return nil } func (planYaml *PlanYaml) addServiceYaml(service *Service) { From 2ed077409bb7f4b7b2371cca7131312156cad09f Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 11 Mar 2024 15:28:23 -0400 Subject: [PATCH 67/75] lint --- .../add_service/add_service.go | 4 +++- .../kurtosis_instruction/exec/exec.go | 14 ++++++++------ .../render_templates/render_templates.go | 2 +- .../kurtosis_instruction/tasks/run_python.go | 3 ++- .../kurtosis_instruction/tasks/run_sh.go | 3 ++- .../plan_yaml/plan_yaml_generator.go | 14 +++++++------- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go index d743241228..710608dbe2 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go @@ -82,7 +82,9 @@ func NewAddService( readyCondition: nil, // populated at interpretation time interpretationTimeValueStore: interpretationTimeValueStore, - description: "", // populated at interpretation time + description: "", // populated at interpretation time + returnValue: nil, // populated at interpretation time + imageType: nil, // populated at interpretation time } }, diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go index d82e983f01..4959d1162e 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec/exec.go @@ -80,12 +80,14 @@ func NewExec(serviceNetwork service_network.ServiceNetwork, runtimeValueStore *r serviceNetwork: serviceNetwork, runtimeValueStore: runtimeValueStore, - serviceName: "", // will be populated at interpretation time - execRecipe: nil, // will be populated at interpretation time - resultUuid: "", // will be populated at interpretation time - acceptableCodes: nil, // will be populated at interpretation time - skipCodeCheck: false, // will be populated at interpretation time - description: "", // populated at interpretation time + serviceName: "", // will be populated at interpretation time + execRecipe: nil, // will be populated at interpretation time + resultUuid: "", // will be populated at interpretation time + acceptableCodes: nil, // will be populated at interpretation time + skipCodeCheck: false, // will be populated at interpretation time + description: "", // populated at interpretation time + cmdList: []string{}, // populated at interpretation time + returnValue: nil, // populated at interpretation time } }, diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go index 588cae2bee..40e92fbf56 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/render_templates/render_templates.go @@ -176,7 +176,7 @@ func (builtin *RenderTemplatesCapabilities) FillPersistableAttributes(builder *e func (builtin *RenderTemplatesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { filepaths := []string{} - for filepath, _ := range builtin.templatesAndDataByDestRelFilepath { + for filepath := range builtin.templatesAndDataByDestRelFilepath { filepaths = append(filepaths, filepath) } err := plan.AddRenderTemplates(builtin.artifactName, filepaths) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go index 976ad8ea89..da24aec2d0 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go @@ -110,7 +110,8 @@ func NewRunPythonService(serviceNetwork service_network.ServiceNetwork, runtimeV resultUuid: "", // populated at interpretation time storeSpecList: nil, wait: DefaultWaitTimeoutDurationStr, - description: "", // populated at interpretation time + description: "", // populated at interpretation time + returnValue: nil, // populated at interpretation time } }, diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go index 272124baaa..b64100655a 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go @@ -92,7 +92,8 @@ func NewRunShService(serviceNetwork service_network.ServiceNetwork, runtimeValue resultUuid: "", // populated at interpretation time storeSpecList: nil, wait: DefaultWaitTimeoutDurationStr, - description: "", // populated at interpretation time + description: "", // populated at interpretation time + returnValue: nil, // populated at interpretation time } }, diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go index 1848b2e6ef..10ecf47f6c 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go @@ -65,7 +65,7 @@ func (planYaml *PlanYaml) AddService( planYaml.storeFutureReference(uuid, hostnameFutureRef, "hostname") // construct service yaml object for plan - serviceYaml := &Service{} + serviceYaml := &Service{} //nolint exhaustruct serviceYaml.Uuid = uuid serviceYaml.Name = planYaml.swapFutureReference(string(serviceName)) @@ -206,7 +206,7 @@ func (planYaml *PlanYaml) AddRunSh( planYaml.storeFutureReference(uuid, outputFutureRef, "output") // create task yaml object - taskYaml := &Task{} + taskYaml := &Task{} //nolint exhaustruct taskYaml.Uuid = uuid taskYaml.TaskType = SHELL @@ -311,7 +311,7 @@ func (planYaml *PlanYaml) AddRunPython( planYaml.storeFutureReference(uuid, outputFutureRef, "output") // create task yaml object - taskYaml := &Task{} + taskYaml := &Task{} //nolint exhaustruct taskYaml.Uuid = uuid taskYaml.TaskType = PYTHON @@ -424,7 +424,7 @@ func (planYaml *PlanYaml) AddExec( planYaml.storeFutureReference(uuid, outputFutureRef, "output") // create task yaml - taskYaml := &Task{} + taskYaml := &Task{} //nolint exhaustruct taskYaml.Uuid = uuid taskYaml.TaskType = EXEC taskYaml.ServiceName = serviceName @@ -437,7 +437,7 @@ func (planYaml *PlanYaml) AddExec( func (planYaml *PlanYaml) AddRenderTemplates(filesArtifactName string, filepaths []string) error { uuid := planYaml.generateUuid() - filesArtifactYaml := &FilesArtifact{} + filesArtifactYaml := &FilesArtifact{} //nolint exhaustruct filesArtifactYaml.Uuid = uuid filesArtifactYaml.Name = filesArtifactName filesArtifactYaml.Files = filepaths @@ -447,7 +447,7 @@ func (planYaml *PlanYaml) AddRenderTemplates(filesArtifactName string, filepaths func (planYaml *PlanYaml) AddUploadFiles(filesArtifactName, locator string) error { uuid := planYaml.generateUuid() - filesArtifactYaml := &FilesArtifact{} + filesArtifactYaml := &FilesArtifact{} //nolint exhauststruct filesArtifactYaml.Uuid = uuid filesArtifactYaml.Name = filesArtifactName filesArtifactYaml.Files = []string{locator} @@ -457,7 +457,7 @@ func (planYaml *PlanYaml) AddUploadFiles(filesArtifactName, locator string) erro func (planYaml *PlanYaml) AddStoreServiceFiles(filesArtifactName, locator string) error { uuid := planYaml.generateUuid() - filesArtifactYaml := &FilesArtifact{} + filesArtifactYaml := &FilesArtifact{} //nolint exhaustruct filesArtifactYaml.Uuid = uuid filesArtifactYaml.Name = filesArtifactName filesArtifactYaml.Files = []string{locator} From b254a499473ece4c92ac764fc259f201536226df Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 11 Mar 2024 16:10:19 -0400 Subject: [PATCH 68/75] add test for future reference swapping --- .../plan_yaml/plan_yaml_generator.go | 128 ++++++++++-------- .../startosis_interpreter_plan_yaml_test.go | 96 ++++++++++++- 2 files changed, 162 insertions(+), 62 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go index 10ecf47f6c..a1c38e2c29 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go @@ -138,9 +138,8 @@ func (planYaml *PlanYaml) AddService( // - add it to the service's file mount accordingly // - add the files artifact to the plan serviceYaml.Files = []*FileMount{} - serviceFilesArtifactExpansions := serviceConfig.GetFilesArtifactsExpansion() - if serviceFilesArtifactExpansions != nil { - for mountPath, artifactIdentifiers := range serviceFilesArtifactExpansions.ServiceDirpathsToArtifactIdentifiers { + if serviceConfig.GetFilesArtifactsExpansion() != nil { + for mountPath, artifactIdentifiers := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { var serviceFilesArtifacts []*FilesArtifact for _, identifier := range artifactIdentifiers { var filesArtifact *FilesArtifact @@ -210,7 +209,7 @@ func (planYaml *PlanYaml) AddRunSh( taskYaml.Uuid = uuid taskYaml.TaskType = SHELL - taskYaml.RunCmd = []string{runCommand} + taskYaml.RunCmd = []string{planYaml.swapFutureReference(runCommand)} taskYaml.Image = serviceConfig.GetContainerImageName() var envVars []*EnvironmentVariable @@ -225,35 +224,37 @@ func (planYaml *PlanYaml) AddRunSh( // for files: // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid // 2. the referenced files artifact is new, in which case we add it to the plan - for mountPath, fileArtifactNames := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { - var filesArtifacts []*FilesArtifact - for _, filesArtifactName := range fileArtifactNames { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if filesArtifactToReference, ok := planYaml.filesArtifactIndex[filesArtifactName]; ok { - filesArtifact = &FilesArtifact{ - Name: filesArtifactToReference.Name, - Uuid: filesArtifactToReference.Uuid, - Files: []string{}, - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ - Name: filesArtifactName, - Uuid: planYaml.generateUuid(), - Files: []string{}, + if serviceConfig.GetFilesArtifactsExpansion() != nil { + for mountPath, fileArtifactNames := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { + var filesArtifacts []*FilesArtifact + for _, filesArtifactName := range fileArtifactNames { + var filesArtifact *FilesArtifact + // if there's already a files artifact that exists with this name from a previous instruction, reference that + if filesArtifactToReference, ok := planYaml.filesArtifactIndex[filesArtifactName]; ok { + filesArtifact = &FilesArtifact{ + Name: filesArtifactToReference.Name, + Uuid: filesArtifactToReference.Uuid, + Files: []string{}, + } + } else { + // otherwise create a new one + // the only information we have about a files artifact that didn't already exist is the name + // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args + filesArtifact = &FilesArtifact{ + Name: filesArtifactName, + Uuid: planYaml.generateUuid(), + Files: []string{}, + } + planYaml.addFilesArtifactYaml(filesArtifact) } - planYaml.addFilesArtifactYaml(filesArtifact) + filesArtifacts = append(filesArtifacts, filesArtifact) } - filesArtifacts = append(filesArtifacts, filesArtifact) - } - taskYaml.Files = append(taskYaml.Files, &FileMount{ - MountPath: mountPath, - FilesArtifacts: filesArtifacts, - }) + taskYaml.Files = append(taskYaml.Files, &FileMount{ + MountPath: mountPath, + FilesArtifacts: filesArtifacts, + }) + } } // for store @@ -315,7 +316,7 @@ func (planYaml *PlanYaml) AddRunPython( taskYaml.Uuid = uuid taskYaml.TaskType = PYTHON - taskYaml.RunCmd = []string{runCommand} + taskYaml.RunCmd = []string{planYaml.swapFutureReference(runCommand)} taskYaml.Image = serviceConfig.GetContainerImageName() var envVars []*EnvironmentVariable @@ -334,35 +335,37 @@ func (planYaml *PlanYaml) AddRunPython( // for files: // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid // 2. the referenced files artifact is new, in which case we add it to the plan - for mountPath, fileArtifactNames := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { - var filesArtifacts []*FilesArtifact - for _, filesArtifactName := range fileArtifactNames { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if filesArtifactToReference, ok := planYaml.filesArtifactIndex[filesArtifactName]; ok { - filesArtifact = &FilesArtifact{ - Name: filesArtifactToReference.Name, - Uuid: filesArtifactToReference.Uuid, - Files: []string{}, - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ - Name: filesArtifactName, - Uuid: planYaml.generateUuid(), - Files: []string{}, + if serviceConfig.GetFilesArtifactsExpansion() != nil { + for mountPath, fileArtifactNames := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { + var filesArtifacts []*FilesArtifact + for _, filesArtifactName := range fileArtifactNames { + var filesArtifact *FilesArtifact + // if there's already a files artifact that exists with this name from a previous instruction, reference that + if filesArtifactToReference, ok := planYaml.filesArtifactIndex[filesArtifactName]; ok { + filesArtifact = &FilesArtifact{ + Name: filesArtifactToReference.Name, + Uuid: filesArtifactToReference.Uuid, + Files: []string{}, + } + } else { + // otherwise create a new one + // the only information we have about a files artifact that didn't already exist is the name + // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args + filesArtifact = &FilesArtifact{ + Name: filesArtifactName, + Uuid: planYaml.generateUuid(), + Files: []string{}, + } + planYaml.addFilesArtifactYaml(filesArtifact) } - planYaml.addFilesArtifactYaml(filesArtifact) + filesArtifacts = append(filesArtifacts, filesArtifact) } - filesArtifacts = append(filesArtifacts, filesArtifact) - } - taskYaml.Files = append(taskYaml.Files, &FileMount{ - MountPath: mountPath, - FilesArtifacts: filesArtifacts, - }) + taskYaml.Files = append(taskYaml.Files, &FileMount{ + MountPath: mountPath, + FilesArtifacts: filesArtifacts, + }) + } } // for store @@ -428,7 +431,12 @@ func (planYaml *PlanYaml) AddExec( taskYaml.Uuid = uuid taskYaml.TaskType = EXEC taskYaml.ServiceName = serviceName - taskYaml.RunCmd = cmdList + + cmdListWithFutureRefsSwapped := []string{} + for _, cmd := range cmdList { + cmdListWithFutureRefsSwapped = append(cmdListWithFutureRefsSwapped, planYaml.swapFutureReference(cmd)) + } + taskYaml.RunCmd = cmdListWithFutureRefsSwapped taskYaml.AcceptableCodes = acceptableCodes planYaml.privatePlanYaml.Tasks = append(planYaml.privatePlanYaml.Tasks, taskYaml) @@ -497,8 +505,8 @@ func (planYaml *PlanYaml) storeFutureReference(uuid, futureReference, futureRefe func (planYaml *PlanYaml) swapFutureReference(s string) string { swappedString := s for futureRef, yamlFutureRef := range planYaml.futureReferenceIndex { - if strings.Contains(s, futureRef) { - swappedString = strings.Replace(s, futureRef, yamlFutureRef, -1) // -1 to swap all instances of [futureRef] + if strings.Contains(swappedString, futureRef) { + swappedString = strings.Replace(swappedString, futureRef, yamlFutureRef, -1) // -1 to swap all instances of [futureRef] } } return swappedString diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go index bb6288f7cf..5ca72f0d71 100644 --- a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go @@ -157,7 +157,7 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRunShWithFilesArtifacts() "HELLO": "Hello!" }, files = { - "/hi.txt": hi_files_artifact, + "/root": hi_files_artifact, }, store=[ StoreSpec(src="/bye.txt", name="bye-file") @@ -197,7 +197,7 @@ tasks: - echo bye > /bye.txt image: badouralix/curl-jq files: - - mountPath: /hi.txt + - mountPath: /root filesArtifacts: - uuid: "2" name: hi-file @@ -583,3 +583,95 @@ filesArtifacts: ` require.Equal(suite.T(), expectedYaml, planYaml) } + +func (suite *StartosisIntepreterPlanYamlTestSuite) TestFutureReferencesAreSwapped() { + script := `def run(plan, hi_files_artifact): + service = plan.add_service( + name="db", + config=ServiceConfig( + image="postgres:latest", + env_vars={ + "POSTGRES_DB": "kurtosis", + "POSTGRES_USER": "kurtosis", + "POSTGRES_PASSWORD": "kurtosis", + }, + files = { + "/root": hi_files_artifact, + } + ) + ) + execResult = plan.exec( + service_name="db", + recipe=ExecRecipe( + command=["echo", service.ip_address + " " + service.hostname] + ), + acceptable_codes=[0], + ) + runShResult = plan.run_sh( + run="echo " + execResult["code"] + " " + execResult["output"], + ) + plan.run_sh( + run="echo " + runShResult.code + " " + runShResult.output, + ) +` + inputArgs := `{"hi_files_artifact": "hi-file"}` + _, instructionsPlan, interpretationError := suite.interpreter.Interpret( + context.Background(), + startosis_constants.PackageIdPlaceholderForStandaloneScript, + useDefaultMainFunctionName, + noPackageReplaceOptions, + startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, + script, + inputArgs, + defaultNonBlockingMode, + emptyEnclaveComponents, + emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 4, instructionsPlan.Size()) + + planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(startosis_constants.PackageIdPlaceholderForStandaloneScript)) + require.NoError(suite.T(), err) + + expectedYaml := `packageId: DEFAULT_PACKAGE_ID_FOR_SCRIPT +services: +- uuid: "1" + name: db + image: + name: postgres:latest + envVars: + - key: POSTGRES_DB + value: kurtosis + - key: POSTGRES_PASSWORD + value: kurtosis + - key: POSTGRES_USER + value: kurtosis + files: + - mountPath: /root + filesArtifacts: + - uuid: "2" + name: hi-file +filesArtifacts: +- uuid: "2" + name: hi-file +tasks: +- uuid: "3" + taskType: exec + command: + - echo + - '{{ kurtosis.1.ip_address }} {{ kurtosis.1.hostname }}' + serviceName: db + acceptableCodes: + - 0 +- uuid: "4" + taskType: sh + command: + - echo {{ kurtosis.3.code }} {{ kurtosis.3.output }} + image: badouralix/curl-jq +- uuid: "5" + taskType: sh + command: + - echo {{ kurtosis.4.code }} {{ kurtosis.4.output }} + image: badouralix/curl-jq +` + require.Equal(suite.T(), expectedYaml, planYaml) +} From cdd9cebf67ffca1e21b498d0c98119d6c4ee2de6 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 11 Mar 2024 17:15:01 -0400 Subject: [PATCH 69/75] fix images --- .../add_service/add_service.go | 47 +++++-- .../plan_yaml/plan_yaml_generator.go | 36 ++---- .../startosis_interpreter_plan_yaml_test.go | 120 ++++++++++++++++++ 3 files changed, 170 insertions(+), 33 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go index 710608dbe2..9761c93b74 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go @@ -11,6 +11,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_type_constructor" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types/service_config" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" @@ -84,7 +85,7 @@ func NewAddService( interpretationTimeValueStore: interpretationTimeValueStore, description: "", // populated at interpretation time returnValue: nil, // populated at interpretation time - imageType: nil, // populated at interpretation time + imageVal: nil, // populated at interpretation time } }, @@ -107,7 +108,7 @@ type AddServiceCapabilities struct { packageId string packageContentProvider startosis_packages.PackageContentProvider packageReplaceOptions map[string]string - imageType starlark.Value + imageVal starlark.Value interpretationTimeValueStore *interpretation_time_value_store.InterpretationTimeValueStore @@ -126,11 +127,14 @@ func (builtin *AddServiceCapabilities) Interpret(locatorOfModuleInWhichThisBuilt if err != nil { return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", ServiceConfigArgName) } - ////rawImageVal, _, err := kurtosis_type_constructor.ExtractAttrValue[starlark.Value](serviceConfig.KurtosisValueTypeDefault, service_config.ImageAttr) - ////if err != nil { - //// return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract raw image attribute.") - ////} - //builtin.imageType = rawImageVal + rawImageVal, found, interpretationErr := kurtosis_type_constructor.ExtractAttrValue[starlark.Value](serviceConfig.KurtosisValueTypeDefault, service_config.ImageAttr) + if interpretationErr != nil { + return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract raw image attribute.") + } + if !found { + return nil, startosis_errors.NewInterpretationError("Unable to extract image attribute off of service config.") + } + builtin.imageVal = rawImageVal apiServiceConfig, readyCondition, interpretationErr := validateAndConvertConfigAndReadyCondition( builtin.serviceNetwork, serviceConfig, @@ -260,7 +264,34 @@ func (builtin *AddServiceCapabilities) FillPersistableAttributes(builder *enclav } func (builtin *AddServiceCapabilities) UpdatePlan(planYaml *plan_yaml.PlanYaml) error { - err := planYaml.AddService(builtin.serviceName, builtin.returnValue, builtin.serviceConfig, builtin.imageType) + var buildContextLocator string + var targetStage string + var registryAddress string + var interpretationErr *startosis_errors.InterpretationError + + // set image values based on type of image + if builtin.imageVal != nil { + switch starlarkImgVal := builtin.imageVal.(type) { + case *service_config.ImageBuildSpec: + buildContextLocator, interpretationErr = starlarkImgVal.GetBuildContextLocator() + if interpretationErr != nil { + return startosis_errors.WrapWithInterpretationError(interpretationErr, "An error occurred getting build context locator") + } + targetStage, interpretationErr = starlarkImgVal.GetTargetStage() + if interpretationErr != nil { + return startosis_errors.WrapWithInterpretationError(interpretationErr, "An error occurred getting target stage.") + } + case *service_config.ImageSpec: + registryAddress, interpretationErr = starlarkImgVal.GetRegistryAddrIfSet() + if interpretationErr != nil { + return startosis_errors.WrapWithInterpretationError(interpretationErr, "An error occurred getting registry address.") + } + default: + // assume NixBuildSpec or regular image + } + } + + err := planYaml.AddService(builtin.serviceName, builtin.returnValue, builtin.serviceConfig, buildContextLocator, targetStage, registryAddress) if err != nil { return stacktrace.NewError("An error occurred updating the plan with service: %v", builtin.serviceName) } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go index a1c38e2c29..2cfaaccc55 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go @@ -48,7 +48,10 @@ func (planYaml *PlanYaml) AddService( serviceName service.ServiceName, serviceInfo *kurtosis_types.Service, serviceConfig *service.ServiceConfig, - imageValue starlark.Value, + // image values might be empty depending on how the image is buitl + imageBuildContextLocator string, + imageTargetStage string, + imageRegistryAddress string, ) error { uuid := planYaml.generateUuid() @@ -70,29 +73,12 @@ func (planYaml *PlanYaml) AddService( serviceYaml.Name = planYaml.swapFutureReference(string(serviceName)) - image := &ImageSpec{ //nolint:exhaustruct - ImageName: serviceConfig.GetContainerImageName(), - } - //imageBuildSpec := serviceConfig.GetImageBuildSpec() - //if imageBuildSpec != nil { - // // Need the raw imageValue to get the build context locator - // switch starlarkImgVal := imageValue.(type) { - // case *service_config.ImageBuildSpec: // importing service_config.ImageBuildSpec causes a dependency issue figure that out later - // contextLocator, err := starlarkImgVal.GetBuildContextLocator() - // if err != nil { - // return err - // } - // image.BuildContextLocator = contextLocator - // default: - // return stacktrace.NewError("An image build spec was detected on the kurtosis type service config but the starlark image value was not an ImageBuildSpec type.") - // } - // image.TargetStage = imageBuildSpec.GetTargetStage() - //} - //imageSpec := serviceConfig.GetImageRegistrySpec() - //if imageSpec != nil { - // image.Registry = imageSpec.GetRegistryAddr() - //} - serviceYaml.Image = image + imageYaml := &ImageSpec{} //nolint:exhaustruct + imageYaml.ImageName = serviceConfig.GetContainerImageName() + imageYaml.BuildContextLocator = imageBuildContextLocator + imageYaml.TargetStage = imageTargetStage + imageYaml.Registry = imageRegistryAddress + serviceYaml.Image = imageYaml cmdArgs := []string{} for _, cmdArg := range serviceConfig.GetCmdArgs() { @@ -114,7 +100,7 @@ func (planYaml *PlanYaml) AddService( } port := &Port{ TransportProtocol: TransportProtocol(configPort.GetTransportProtocol().String()), - ApplicationProtocol: ApplicationProtocol(applicationProtocolStr), // TODO: write a test for this, dereferencing config port is not a good idea + ApplicationProtocol: ApplicationProtocol(applicationProtocolStr), Name: portName, Number: configPort.GetNumber(), } diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go index 5ca72f0d71..e8b6a9fb08 100644 --- a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go @@ -421,6 +421,126 @@ tasks: require.Equal(suite.T(), expectedYaml, planYaml) } +func (suite *StartosisIntepreterPlanYamlTestSuite) TestAddServiceWithImageBuildSpec() { + dockerfileModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server/Dockerfile" + serverModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server" + dockerfileContents := `RUN ["something"]` + require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(dockerfileModulePath, dockerfileContents)) + require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(serverModulePath, "")) + packageId := "github.com/kurtosis-tech/plan-yaml-prac" + + script := `def run(plan, hi_files_artifact): + plan.add_service( + name="db", + config=ServiceConfig( + image = ImageBuildSpec( + image_name="` + testContainerImageName + `", + build_context_dir="./server", + target_stage="builder", + ), + files = { + "/root": hi_files_artifact, + } + ) + ) +` + inputArgs := `{"hi_files_artifact": "hi-file"}` + _, instructionsPlan, interpretationError := suite.interpreter.Interpret( + context.Background(), + packageId, + useDefaultMainFunctionName, + noPackageReplaceOptions, + startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, + script, + inputArgs, + defaultNonBlockingMode, + emptyEnclaveComponents, + emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 1, instructionsPlan.Size()) + + planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(packageId)) + require.NoError(suite.T(), err) + + expectedYaml := `packageId: ` + packageId + ` +services: +- uuid: "1" + name: db + image: + name: kurtosistech/example-datastore-server + buildContextLocator: ./server + targetStage: builder + files: + - mountPath: /root + filesArtifacts: + - uuid: "2" + name: hi-file +filesArtifacts: +- uuid: "2" + name: hi-file +` + require.Equal(suite.T(), expectedYaml, planYaml) +} + +func (suite *StartosisIntepreterPlanYamlTestSuite) TestAddServiceWithImageSpec() { + dockerfileModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server/Dockerfile" + serverModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server" + dockerfileContents := `RUN ["something"]` + require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(dockerfileModulePath, dockerfileContents)) + require.Nil(suite.T(), suite.packageContentProvider.AddFileContent(serverModulePath, "")) + packageId := "github.com/kurtosis-tech/plan-yaml-prac" + + script := `def run(plan, hi_files_artifact): + plan.add_service( + name="db", + config=ServiceConfig( + image = ImageSpec( + image="` + testContainerImageName + `", + registry = "http://my.registry.io/", + ), + files = { + "/root": hi_files_artifact, + } + ) + ) +` + inputArgs := `{"hi_files_artifact": "hi-file"}` + _, instructionsPlan, interpretationError := suite.interpreter.Interpret( + context.Background(), + packageId, + useDefaultMainFunctionName, + noPackageReplaceOptions, + startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, + script, + inputArgs, + defaultNonBlockingMode, + emptyEnclaveComponents, + emptyInstructionsPlanMask) + require.Nil(suite.T(), interpretationError) + require.Equal(suite.T(), 1, instructionsPlan.Size()) + + planYaml, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(packageId)) + require.NoError(suite.T(), err) + + expectedYaml := `packageId: ` + packageId + ` +services: +- uuid: "1" + name: db + image: + name: kurtosistech/example-datastore-server + registry: http://my.registry.io/ + files: + - mountPath: /root + filesArtifacts: + - uuid: "2" + name: hi-file +filesArtifacts: +- uuid: "2" + name: hi-file +` + require.Equal(suite.T(), expectedYaml, planYaml) +} + func (suite *StartosisIntepreterPlanYamlTestSuite) TestUploadFiles() { dockerfileModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server/Dockerfile" serverModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server" From f9a4985e18c883851f6e567f4cd05ba2e9f096fd Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 11 Mar 2024 17:18:46 -0400 Subject: [PATCH 70/75] remove warnings --- .../kurtosis_instruction/add_service/add_services.go | 3 ++- .../kurtosis_instruction/get_service/get_service.go | 1 + .../kurtosis_instruction/kurtosis_print/kurtosis_print.go | 3 ++- .../startosis_engine/kurtosis_instruction/request/request.go | 4 +++- .../kurtosis_instruction/start_service/start_service.go | 3 ++- .../kurtosis_instruction/stop_service/stop_service.go | 3 ++- .../startosis_engine/kurtosis_instruction/verify/verify.go | 3 ++- .../server/startosis_engine/kurtosis_instruction/wait/wait.go | 3 ++- 8 files changed, 16 insertions(+), 7 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go index 13adb72091..d2a46a00f7 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go @@ -365,7 +365,8 @@ func (builtin *AddServicesCapabilities) allServicesReadinessCheck( } func (builtin *AddServicesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") + logrus.Debugf("ADD SERVICES FOR PLAN YAML IMPLEMENTED YET") + return nil } func (builtin *AddServicesCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/get_service/get_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/get_service/get_service.go index cb27678a24..17b5aa7a2a 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/get_service/get_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/get_service/get_service.go @@ -104,6 +104,7 @@ func (builtin *GetServiceCapabilities) FillPersistableAttributes(builder *enclav } func (builtin *GetServiceCapabilities) UpdatePlan(planYaml *plan_yaml.PlanYaml) error { + // get service does not affect the plan return nil } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_print/kurtosis_print.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_print/kurtosis_print.go index 95f8a930ea..c111b0a098 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_print/kurtosis_print.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_print/kurtosis_print.go @@ -107,7 +107,8 @@ func (builtin *PrintCapabilities) FillPersistableAttributes(builder *enclave_pla } func (builitin *PrintCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") + // print does not affect the plan + return nil } func (builtin *PrintCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go index 39a2939be6..afb9327b9b 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go @@ -17,6 +17,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_errors" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" "github.com/kurtosis-tech/stacktrace" + "github.com/sirupsen/logrus" "go.starlark.net/starlark" "net/http" ) @@ -209,7 +210,8 @@ func (builtin *RequestCapabilities) FillPersistableAttributes(builder *enclave_p } func (builtin *RequestCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") + logrus.Debug("REQUEST NOT IMPLEMENTED YET FOR UPDATING THE PLAn") + return nil } func (builtin *RequestCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/start_service/start_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/start_service/start_service.go index 2875f11294..2856274444 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/start_service/start_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/start_service/start_service.go @@ -108,7 +108,8 @@ func (builtin *StartServiceCapabilities) FillPersistableAttributes(builder *encl } func (builtin *StartServiceCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") + // start services doesn't affect the plan + return nil } func (builtin *StartServiceCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/stop_service/stop_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/stop_service/stop_service.go index da7fe6cff7..82fc1a86c7 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/stop_service/stop_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/stop_service/stop_service.go @@ -108,7 +108,8 @@ func (builtin *StopServiceCapabilities) FillPersistableAttributes(builder *encla } func (builtin *StopServiceCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") + // stop service does not affect the plan + return nil } func (builtin *StopServiceCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify.go index 9aee900744..842f5d0ddf 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify.go @@ -162,7 +162,8 @@ func (builtin *VerifyCapabilities) FillPersistableAttributes(builder *enclave_pl } func (builtin *VerifyCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") + // verify does not affect the plan + return nil } func (builtin *VerifyCapabilities) Description() string { diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go index 8c6039d551..ee89af066e 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go @@ -295,7 +295,8 @@ func (builtin *WaitCapabilities) FillPersistableAttributes(builder *enclave_plan } func (builtin *WaitCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - return stacktrace.NewError("IMPLEMENT ME") + // wait does not affect the plan + return nil } func (builtin *WaitCapabilities) Description() string { From aad10f96c5a311089efe4df4dfa81a25b0fd2ff8 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 11 Mar 2024 17:20:54 -0400 Subject: [PATCH 71/75] lint --- .../server/startosis_engine/plan_yaml/plan_yaml_generator.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go index 2cfaaccc55..14ae489005 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go @@ -491,9 +491,7 @@ func (planYaml *PlanYaml) storeFutureReference(uuid, futureReference, futureRefe func (planYaml *PlanYaml) swapFutureReference(s string) string { swappedString := s for futureRef, yamlFutureRef := range planYaml.futureReferenceIndex { - if strings.Contains(swappedString, futureRef) { - swappedString = strings.Replace(swappedString, futureRef, yamlFutureRef, -1) // -1 to swap all instances of [futureRef] - } + swappedString = strings.Replace(swappedString, futureRef, yamlFutureRef, -1) // -1 to swap all instances of [futureRef] } return swappedString } From 321ad2f70970fa910c26baac254d9d21c64a715f Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 11 Mar 2024 18:14:53 -0400 Subject: [PATCH 72/75] touch up --- .../startosis_engine/instructions_plan/instructions_plan.go | 2 +- .../kurtosis_instruction/add_service/add_services.go | 2 +- .../kurtosis_instruction/kurtosis_instruction.go | 4 ---- .../kurtosis_instruction/request/request.go | 2 +- .../kurtosis_instruction/tasks/run_python.go | 2 +- .../startosis_engine/kurtosis_instruction/tasks/run_sh.go | 6 +++--- .../kurtosis_instruction/tasks/tasks_shared.go | 2 +- .../server/startosis_engine/plan_yaml/plan_yaml.go | 1 - 8 files changed, 8 insertions(+), 13 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go index 6ad8f2dac3..38e42655d4 100644 --- a/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go +++ b/core/server/api_container/server/startosis_engine/instructions_plan/instructions_plan.go @@ -85,7 +85,7 @@ func (plan *InstructionsPlan) GenerateYaml(planYaml *plan_yaml.PlanYaml) (string } err := instruction.kurtosisInstruction.UpdatePlan(planYaml) if err != nil { - return "", startosis_errors.WrapWithInterpretationError(err, "An error occurred updating the plan.") // TODO: log information about the instruction? + return "", startosis_errors.WrapWithInterpretationError(err, "An error occurred updating the plan with instruction: %v.", instructionUuid) } } return planYaml.GenerateYaml() diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go index d2a46a00f7..0c8dc4250f 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go @@ -365,7 +365,7 @@ func (builtin *AddServicesCapabilities) allServicesReadinessCheck( } func (builtin *AddServicesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - logrus.Debugf("ADD SERVICES FOR PLAN YAML IMPLEMENTED YET") + logrus.Warn("ADD SERVICES NOT IMPLEMENTED YET FOR UPDATING PLAN YAML.") return nil } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go index f273aa8fdc..97c2fd1749 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_instruction.go @@ -6,7 +6,6 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_plan_persistence" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_structure" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/plan_yaml" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/startosis_validator" ) @@ -36,9 +35,6 @@ type KurtosisInstruction interface { // itself. In the current case, this is called in the executor, and it sets the UUID and the returned value. GetPersistableAttributes() *enclave_plan_persistence.EnclavePlanInstructionBuilder - // GetArguments returns arguments set on an instruction. These arguments are Starlark values that can be extracted. - GetArguments() *builtin_argument.ArgumentValuesSet - // UpdatePlan updates the plan with the effects of running this instruction. UpdatePlan(plan *plan_yaml.PlanYaml) error } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go index afb9327b9b..cc3e441a38 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go @@ -210,7 +210,7 @@ func (builtin *RequestCapabilities) FillPersistableAttributes(builder *enclave_p } func (builtin *RequestCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { - logrus.Debug("REQUEST NOT IMPLEMENTED YET FOR UPDATING THE PLAn") + logrus.Warn("REQUEST NOT IMPLEMENTED YET FOR UPDATING PLAN") return nil } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go index da24aec2d0..2971f953fa 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go @@ -225,7 +225,7 @@ func (builtin *RunPythonCapabilities) Interpret(_ string, arguments *builtin_arg } if arguments.IsSet(StoreFilesArgName) { - storeSpecList, interpretationErr := ParseStoreFilesArg(builtin.serviceNetwork, arguments) + storeSpecList, interpretationErr := parseStoreFilesArg(builtin.serviceNetwork, arguments) if interpretationErr != nil { return nil, interpretationErr } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go index 7fc6b8c849..0765a5b2c0 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_sh.go @@ -28,7 +28,7 @@ import ( const ( RunShBuiltinName = "run_sh" - DefaultRunShImageName = "badouralix/curl-jq" + defaultRunShImageName = "badouralix/curl-jq" shScriptPrintCharLimit = 80 runningShScriptPrefix = "Running sh script" ) @@ -139,7 +139,7 @@ func (builtin *RunShCapabilities) Interpret(_ string, arguments *builtin_argumen } image = imageStarlark.GoString() } else { - image = DefaultRunShImageName + image = defaultRunShImageName } var filesArtifactExpansion *service_directory.FilesArtifactsExpansion @@ -176,7 +176,7 @@ func (builtin *RunShCapabilities) Interpret(_ string, arguments *builtin_argumen } if arguments.IsSet(StoreFilesArgName) { - storeSpecList, interpretationErr := ParseStoreFilesArg(builtin.serviceNetwork, arguments) + storeSpecList, interpretationErr := parseStoreFilesArg(builtin.serviceNetwork, arguments) if interpretationErr != nil { return nil, interpretationErr } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/tasks_shared.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/tasks_shared.go index 1c88b702f4..9e683100bf 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/tasks_shared.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/tasks_shared.go @@ -50,7 +50,7 @@ const ( var runTailCommandToPreventContainerToStopOnCreating = []string{"tail", "-f", "/dev/null"} -func ParseStoreFilesArg(serviceNetwork service_network.ServiceNetwork, arguments *builtin_argument.ArgumentValuesSet) ([]*store_spec.StoreSpec, *startosis_errors.InterpretationError) { +func parseStoreFilesArg(serviceNetwork service_network.ServiceNetwork, arguments *builtin_argument.ArgumentValuesSet) ([]*store_spec.StoreSpec, *startosis_errors.InterpretationError) { var result []*store_spec.StoreSpec storeFilesList, err := builtin_argument.ExtractArgumentValue[*starlark.List](arguments, StoreFilesArgName) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index 0bcf9c3924..f9b96cf005 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -8,7 +8,6 @@ const ( EXEC TaskType = "exec" ) -// TODO: pass by value instead of pass by reference type privatePlanYaml struct { PackageId string `yaml:"packageId,omitempty"` Services []*Service `yaml:"services,omitempty"` From a6a13b33cbac1b8d075af2048fc2747ad45545ea Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Tue, 12 Mar 2024 10:31:10 -0400 Subject: [PATCH 73/75] fix duplicate field --- .../kurtosis_instruction/add_service/add_service.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go index 928e631c69..7db6f39962 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_service.go @@ -88,8 +88,7 @@ func NewAddService( description: "", // populated at interpretation time returnValue: nil, // populated at interpretation time imageVal: nil, // populated at interpretation time - description: "", // populated at interpretation time - imageDownloadMode: imageDownloadMode, + imageDownloadMode: imageDownloadMode, } }, From 5a8a6f2a8593aea2dcc114d1156e5c9b25c5b9e9 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Wed, 13 Mar 2024 10:04:52 -0400 Subject: [PATCH 74/75] address comments and fix merge conflicts --- api/protobuf/core/api_container_service.proto | 2 +- .../server/api_container_service.go | 18 +++--- .../add_service/add_services.go | 1 + .../kurtosis_instruction/request/request.go | 1 + .../startosis_engine/plan_yaml/plan_yaml.go | 12 ++-- .../plan_yaml/plan_yaml_generator.go | 59 +++++++++++-------- .../startosis_interpreter_plan_yaml_test.go | 34 +++++++---- 7 files changed, 76 insertions(+), 51 deletions(-) diff --git a/api/protobuf/core/api_container_service.proto b/api/protobuf/core/api_container_service.proto index da013af583..440c49d9cb 100644 --- a/api/protobuf/core/api_container_service.proto +++ b/api/protobuf/core/api_container_service.proto @@ -600,4 +600,4 @@ message StarlarkPackagePlanYamlArgs { // The name of the main function, the default value is "run" optional string main_function_name = 4; -} \ No newline at end of file +} diff --git a/core/server/api_container/server/api_container_service.go b/core/server/api_container/server/api_container_service.go index c33e4bd833..d496ee4e66 100644 --- a/core/server/api_container/server/api_container_service.go +++ b/core/server/api_container/server/api_container_service.go @@ -615,10 +615,9 @@ func (apicService *ApiContainerService) GetStarlarkPackagePlanYaml(ctx context.C scriptWithRunFunction, actualRelativePathToMainFile, detectedPackageId, detectedPackageReplaceOptions, interpretationError = apicService.runStarlarkPackageSetup(packageIdFromArgs, true, nil, requestedRelativePathToMainFile) if interpretationError != nil { - return nil, interpretationError + return nil, stacktrace.Propagate(interpretationError, "An interpretation error occurred setting up the package for retrieving plan yaml for package: %v", packageIdFromArgs) } - var apiInterpretationError *kurtosis_core_rpc_api_bindings.StarlarkInterpretationError _, instructionsPlan, apiInterpretationError := apicService.startosisInterpreter.Interpret( ctx, detectedPackageId, @@ -629,26 +628,30 @@ func (apicService *ApiContainerService) GetStarlarkPackagePlanYaml(ctx context.C serializedParams, false, enclave_structure.NewEnclaveComponents(), - resolver.NewInstructionsPlanMask(0)) + resolver.NewInstructionsPlanMask(0), + image_download_mode.ImageDownloadMode_Always) if apiInterpretationError != nil { interpretationError = startosis_errors.NewInterpretationError(apiInterpretationError.GetErrorMessage()) - return nil, interpretationError + return nil, stacktrace.Propagate(interpretationError, "An interpretation error occurred interpreting package for retrieving plan yaml for package: %v", packageIdFromArgs) } planYamlStr, err := instructionsPlan.GenerateYaml(plan_yaml.CreateEmptyPlan(packageIdFromArgs)) if err != nil { - return nil, err + return nil, stacktrace.Propagate(err, "An error occurred generating plan yaml for package: %v", packageIdFromArgs) } return &kurtosis_core_rpc_api_bindings.PlanYaml{PlanYaml: planYamlStr}, nil } +// NOTE: GetStarlarkScriptPlanYaml endpoint is only meant to be called by the EM UI, Enclave Builder logic. +// Once the EM UI retrieves the plan yaml, the APIC is removed and not used again. +// It's not ideal that we have to even start an enclave/APIC to simply get the result of interpretation/plan yaml but that would require a larger refactor +// of the startosis_engine to enable the infra for interpretation to be executed as a standalone library, that could be setup by the engine, or even on the client. func (apicService *ApiContainerService) GetStarlarkScriptPlanYaml(ctx context.Context, args *kurtosis_core_rpc_api_bindings.StarlarkScriptPlanYamlArgs) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) { serializedStarlarkScript := args.GetSerializedScript() serializedParams := args.GetSerializedParams() mainFuncName := args.GetMainFunctionName() noPackageReplaceOptions := map[string]string{} - var apiInterpretationError *kurtosis_core_rpc_api_bindings.StarlarkInterpretationError _, instructionsPlan, apiInterpretationError := apicService.startosisInterpreter.Interpret( ctx, startosis_constants.PackageIdPlaceholderForStandaloneScript, @@ -659,7 +662,8 @@ func (apicService *ApiContainerService) GetStarlarkScriptPlanYaml(ctx context.Co serializedParams, false, enclave_structure.NewEnclaveComponents(), - resolver.NewInstructionsPlanMask(0)) + resolver.NewInstructionsPlanMask(0), + image_download_mode.ImageDownloadMode_Always) if apiInterpretationError != nil { return nil, startosis_errors.NewInterpretationError(apiInterpretationError.GetErrorMessage()) } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go index 531e2f9dc6..c221488f85 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service/add_services.go @@ -371,6 +371,7 @@ func (builtin *AddServicesCapabilities) allServicesReadinessCheck( } func (builtin *AddServicesCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + // TOOD: Implement logrus.Warn("ADD SERVICES NOT IMPLEMENTED YET FOR UPDATING PLAN YAML.") return nil } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go index cc3e441a38..2a893d2672 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/request/request.go @@ -210,6 +210,7 @@ func (builtin *RequestCapabilities) FillPersistableAttributes(builder *enclave_p } func (builtin *RequestCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error { + // TODO: Implement logrus.Warn("REQUEST NOT IMPLEMENTED YET FOR UPDATING PLAN") return nil } diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go index f9b96cf005..2ea9bcfd03 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml.go @@ -3,9 +3,9 @@ package plan_yaml import "sort" const ( - SHELL TaskType = "sh" - PYTHON TaskType = "python" - EXEC TaskType = "exec" + shell TaskType = "sh" + python TaskType = "python" + exec TaskType = "exec" ) type privatePlanYaml struct { @@ -96,10 +96,10 @@ type Task struct { Files []*FileMount `yaml:"files,omitempty"` Store []*FilesArtifact `yaml:"store,omitempty"` - // only exists on SHELL tasks + // only exists on shell tasks EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` // done - // only exists on PYTHON tasks + // only exists on python tasks PythonPackages []string `yaml:"pythonPackages,omitempty"` PythonArgs []string `yaml:"pythonArgs,omitempty"` @@ -108,5 +108,5 @@ type Task struct { AcceptableCodes []int64 `yaml:"acceptableCodes,omitempty"` } -// TaskType represents the type of task (either PYTHON or SHELL) +// TaskType represents the type of task (either python or shell) type TaskType string diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go index 14ae489005..33c7b97aa3 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go @@ -9,10 +9,18 @@ import ( "github.com/kurtosis-tech/stacktrace" "go.starlark.net/starlark" "go.starlark.net/starlarkstruct" + "golang.org/x/exp/slices" "strconv" "strings" ) +const ( + ipAddressFutureRefType = "ip_address" + codeFutureRefType = "code" + hostnameFutureRefType = "hostname" + outputFutureRefType = "output" +) + // PlanYaml is a yaml representation of the effect of an Instructions Plan or sequence of instructions on the state of the Enclave. type PlanYaml struct { privatePlanYaml *privatePlanYaml @@ -39,7 +47,7 @@ func CreateEmptyPlan(packageId string) *PlanYaml { func (planYaml *PlanYaml) GenerateYaml() (string, error) { yamlBytes, err := yaml.Marshal(planYaml.privatePlanYaml) if err != nil { - return "", err + return "", stacktrace.Propagate(err, "An error occurred generating plan yaml.") } return string(yamlBytes), nil } @@ -64,8 +72,8 @@ func (planYaml *PlanYaml) AddService( if err != nil { return err } - planYaml.storeFutureReference(uuid, ipAddrFutureRef, "ip_address") - planYaml.storeFutureReference(uuid, hostnameFutureRef, "hostname") + planYaml.storeFutureReference(uuid, ipAddrFutureRef, ipAddressFutureRefType) + planYaml.storeFutureReference(uuid, hostnameFutureRef, hostnameFutureRefType) // construct service yaml object for plan serviceYaml := &Service{} //nolint exhaustruct @@ -171,29 +179,29 @@ func (planYaml *PlanYaml) AddRunSh( uuid := planYaml.generateUuid() // store run sh future references - codeVal, err := returnValue.Attr("code") + codeVal, err := returnValue.Attr(codeFutureRefType) if err != nil { return err } - codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "run sh code") + codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "run sh "+codeFutureRefType) if interpErr != nil { return interpErr } - planYaml.storeFutureReference(uuid, codeFutureRef, "code") - outputVal, err := returnValue.Attr("output") + planYaml.storeFutureReference(uuid, codeFutureRef, codeFutureRefType) + outputVal, err := returnValue.Attr(outputFutureRefType) if err != nil { return err } - outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "run sh code") + outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "run sh "+outputFutureRefType) if interpErr != nil { return interpErr } - planYaml.storeFutureReference(uuid, outputFutureRef, "output") + planYaml.storeFutureReference(uuid, outputFutureRef, outputFutureRefType) // create task yaml object taskYaml := &Task{} //nolint exhaustruct taskYaml.Uuid = uuid - taskYaml.TaskType = SHELL + taskYaml.TaskType = shell taskYaml.RunCmd = []string{planYaml.swapFutureReference(runCommand)} taskYaml.Image = serviceConfig.GetContainerImageName() @@ -278,29 +286,29 @@ func (planYaml *PlanYaml) AddRunPython( uuid := planYaml.generateUuid() // store future references - codeVal, err := returnValue.Attr("code") + codeVal, err := returnValue.Attr(codeFutureRefType) if err != nil { return err } - codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "run python code") + codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "run python "+codeFutureRefType) if interpErr != nil { return interpErr } - planYaml.storeFutureReference(uuid, codeFutureRef, "code") - outputVal, err := returnValue.Attr("output") + planYaml.storeFutureReference(uuid, codeFutureRef, codeFutureRefType) + outputVal, err := returnValue.Attr(outputFutureRefType) if err != nil { return err } - outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "run python output") + outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "run python "+outputFutureRefType) if interpErr != nil { return interpErr } - planYaml.storeFutureReference(uuid, outputFutureRef, "output") + planYaml.storeFutureReference(uuid, outputFutureRef, outputFutureRefType) // create task yaml object taskYaml := &Task{} //nolint exhaustruct taskYaml.Uuid = uuid - taskYaml.TaskType = PYTHON + taskYaml.TaskType = python taskYaml.RunCmd = []string{planYaml.swapFutureReference(runCommand)} taskYaml.Image = serviceConfig.GetContainerImageName() @@ -387,35 +395,35 @@ func (planYaml *PlanYaml) AddExec( uuid := planYaml.generateUuid() // store future references - codeVal, found, err := returnValue.Get(starlark.String("code")) + codeVal, found, err := returnValue.Get(starlark.String(codeFutureRefType)) if err != nil { return err } if !found { return stacktrace.NewError("No code value found on exec dict") } - codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "exec code") + codeFutureRef, interpErr := kurtosis_types.SafeCastToString(codeVal, "exec "+codeFutureRefType) if interpErr != nil { return interpErr } - planYaml.storeFutureReference(uuid, codeFutureRef, "code") - outputVal, found, err := returnValue.Get(starlark.String("output")) + planYaml.storeFutureReference(uuid, codeFutureRef, codeFutureRefType) + outputVal, found, err := returnValue.Get(starlark.String(outputFutureRefType)) if err != nil { return err } if !found { return stacktrace.NewError("No code value found on exec dict") } - outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "exec output") + outputFutureRef, interpErr := kurtosis_types.SafeCastToString(outputVal, "exec "+outputFutureRefType) if interpErr != nil { return interpErr } - planYaml.storeFutureReference(uuid, outputFutureRef, "output") + planYaml.storeFutureReference(uuid, outputFutureRef, outputFutureRefType) // create task yaml taskYaml := &Task{} //nolint exhaustruct taskYaml.Uuid = uuid - taskYaml.TaskType = EXEC + taskYaml.TaskType = exec taskYaml.ServiceName = serviceName cmdListWithFutureRefsSwapped := []string{} @@ -462,8 +470,7 @@ func (planYaml *PlanYaml) AddStoreServiceFiles(filesArtifactName, locator string func (planYaml *PlanYaml) RemoveService(serviceName string) { for idx, service := range planYaml.privatePlanYaml.Services { if service.Name == serviceName { - planYaml.privatePlanYaml.Services[idx] = planYaml.privatePlanYaml.Services[len(planYaml.privatePlanYaml.Services)-1] - planYaml.privatePlanYaml.Services = planYaml.privatePlanYaml.Services[:len(planYaml.privatePlanYaml.Services)-1] + planYaml.privatePlanYaml.Services = slices.Delete(planYaml.privatePlanYaml.Services, idx, idx+1) return } } diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go index e8b6a9fb08..dcff4b5408 100644 --- a/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_plan_yaml_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "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/image_download_mode" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/interpretation_time_value_store" @@ -109,7 +110,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestAddServiceWithFilesArtifa inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, - emptyInstructionsPlanMask) + emptyInstructionsPlanMask, + image_download_mode.ImageDownloadMode_Always) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 1, instructionsPlan.Size()) @@ -175,7 +177,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRunShWithFilesArtifacts() inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, - emptyInstructionsPlanMask) + emptyInstructionsPlanMask, + image_download_mode.ImageDownloadMode_Always) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 1, instructionsPlan.Size()) @@ -245,7 +248,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRunPython() { inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, - emptyInstructionsPlanMask) + emptyInstructionsPlanMask, + image_download_mode.ImageDownloadMode_Always) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 1, instructionsPlan.Size()) @@ -317,7 +321,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestExec() { inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, - emptyInstructionsPlanMask) + emptyInstructionsPlanMask, + image_download_mode.ImageDownloadMode_Always) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 2, instructionsPlan.Size()) @@ -392,7 +397,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRenderTemplate() { inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, - emptyInstructionsPlanMask) + emptyInstructionsPlanMask, + image_download_mode.ImageDownloadMode_Always) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 2, instructionsPlan.Size()) @@ -455,7 +461,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestAddServiceWithImageBuildS inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, - emptyInstructionsPlanMask) + emptyInstructionsPlanMask, + image_download_mode.ImageDownloadMode_Always) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 1, instructionsPlan.Size()) @@ -515,7 +522,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestAddServiceWithImageSpec() inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, - emptyInstructionsPlanMask) + emptyInstructionsPlanMask, + image_download_mode.ImageDownloadMode_Always) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 1, instructionsPlan.Size()) @@ -570,7 +578,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestUploadFiles() { startosis_constants.EmptyInputArgs, defaultNonBlockingMode, emptyEnclaveComponents, - emptyInstructionsPlanMask) + emptyInstructionsPlanMask, + image_download_mode.ImageDownloadMode_Always) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 2, instructionsPlan.Size()) @@ -628,7 +637,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestStoreServiceFiles() { inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, - emptyInstructionsPlanMask) + emptyInstructionsPlanMask, + image_download_mode.ImageDownloadMode_Always) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 2, instructionsPlan.Size()) @@ -689,7 +699,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRemoveService() { inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, - emptyInstructionsPlanMask) + emptyInstructionsPlanMask, + image_download_mode.ImageDownloadMode_Always) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 2, instructionsPlan.Size()) @@ -745,7 +756,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestFutureReferencesAreSwappe inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, - emptyInstructionsPlanMask) + emptyInstructionsPlanMask, + image_download_mode.ImageDownloadMode_Always) require.Nil(suite.T(), interpretationError) require.Equal(suite.T(), 4, instructionsPlan.Size()) From 6cfc87358a4018820aa8509b1577344fe8ddf468 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Wed, 13 Mar 2024 14:16:58 -0400 Subject: [PATCH 75/75] refactor files artifacts expansion to file mount logic --- .../plan_yaml/plan_yaml_generator.go | 160 ++++++------------ 1 file changed, 49 insertions(+), 111 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go index 33c7b97aa3..01b544dec5 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml/plan_yaml_generator.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/go-yaml/yaml" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service" + "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service_directory" store_spec2 "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/store_spec" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "github.com/kurtosis-tech/stacktrace" @@ -124,47 +125,7 @@ func (planYaml *PlanYaml) AddService( serviceYaml.EnvVars = append(serviceYaml.EnvVars, envVar) } - // file mounts have two cases: - // 1. the referenced files artifact already exists in the plan, in which case add the referenced files artifact - // 2. the referenced files artifact does not already exist in the plan, in which case the file MUST have been passed in via a top level arg OR is invalid - // for this case, - // - create new files artifact - // - add it to the service's file mount accordingly - // - add the files artifact to the plan - serviceYaml.Files = []*FileMount{} - if serviceConfig.GetFilesArtifactsExpansion() != nil { - for mountPath, artifactIdentifiers := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { - var serviceFilesArtifacts []*FilesArtifact - for _, identifier := range artifactIdentifiers { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if filesArtifactToReference, ok := planYaml.filesArtifactIndex[identifier]; ok { - filesArtifact = &FilesArtifact{ - Name: filesArtifactToReference.Name, - Uuid: filesArtifactToReference.Uuid, - Files: []string{}, // leave empty because this is referencing an existing files artifact - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args of run function - filesArtifact = &FilesArtifact{ - Name: identifier, - Uuid: planYaml.generateUuid(), - Files: []string{}, // don't know at interpretation what files are on the artifact when passed in via args - } - planYaml.addFilesArtifactYaml(filesArtifact) - } - serviceFilesArtifacts = append(serviceFilesArtifacts, filesArtifact) - } - - serviceYaml.Files = append(serviceYaml.Files, &FileMount{ - MountPath: mountPath, - FilesArtifacts: serviceFilesArtifacts, - }) - } - - } + serviceYaml.Files = planYaml.getFileMountsFromFilesArtifacts(serviceConfig.GetFilesArtifactsExpansion()) planYaml.addServiceYaml(serviceYaml) return nil @@ -215,41 +176,7 @@ func (planYaml *PlanYaml) AddRunSh( } taskYaml.EnvVars = envVars - // for files: - // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid - // 2. the referenced files artifact is new, in which case we add it to the plan - if serviceConfig.GetFilesArtifactsExpansion() != nil { - for mountPath, fileArtifactNames := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { - var filesArtifacts []*FilesArtifact - for _, filesArtifactName := range fileArtifactNames { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if filesArtifactToReference, ok := planYaml.filesArtifactIndex[filesArtifactName]; ok { - filesArtifact = &FilesArtifact{ - Name: filesArtifactToReference.Name, - Uuid: filesArtifactToReference.Uuid, - Files: []string{}, - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ - Name: filesArtifactName, - Uuid: planYaml.generateUuid(), - Files: []string{}, - } - planYaml.addFilesArtifactYaml(filesArtifact) - } - filesArtifacts = append(filesArtifacts, filesArtifact) - } - - taskYaml.Files = append(taskYaml.Files, &FileMount{ - MountPath: mountPath, - FilesArtifacts: filesArtifacts, - }) - } - } + taskYaml.Files = planYaml.getFileMountsFromFilesArtifacts(serviceConfig.GetFilesArtifactsExpansion()) // for store // - all files artifacts product from store are new files artifact that are added to the plan @@ -326,41 +253,7 @@ func (planYaml *PlanYaml) AddRunPython( taskYaml.PythonArgs = append(taskYaml.PythonArgs, pythonArgs...) taskYaml.PythonPackages = append(taskYaml.PythonPackages, pythonPackages...) - // for files: - // 1. either the referenced files artifact already exists in the plan, in which case, look for it and reference it via instruction uuid - // 2. the referenced files artifact is new, in which case we add it to the plan - if serviceConfig.GetFilesArtifactsExpansion() != nil { - for mountPath, fileArtifactNames := range serviceConfig.GetFilesArtifactsExpansion().ServiceDirpathsToArtifactIdentifiers { - var filesArtifacts []*FilesArtifact - for _, filesArtifactName := range fileArtifactNames { - var filesArtifact *FilesArtifact - // if there's already a files artifact that exists with this name from a previous instruction, reference that - if filesArtifactToReference, ok := planYaml.filesArtifactIndex[filesArtifactName]; ok { - filesArtifact = &FilesArtifact{ - Name: filesArtifactToReference.Name, - Uuid: filesArtifactToReference.Uuid, - Files: []string{}, - } - } else { - // otherwise create a new one - // the only information we have about a files artifact that didn't already exist is the name - // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args - filesArtifact = &FilesArtifact{ - Name: filesArtifactName, - Uuid: planYaml.generateUuid(), - Files: []string{}, - } - planYaml.addFilesArtifactYaml(filesArtifact) - } - filesArtifacts = append(filesArtifacts, filesArtifact) - } - - taskYaml.Files = append(taskYaml.Files, &FileMount{ - MountPath: mountPath, - FilesArtifacts: filesArtifacts, - }) - } - } + taskYaml.Files = planYaml.getFileMountsFromFilesArtifacts(serviceConfig.GetFilesArtifactsExpansion()) // for store // - all files artifacts product from store are new files artifact that are added to the plan @@ -476,6 +369,51 @@ func (planYaml *PlanYaml) RemoveService(serviceName string) { } } +// getFileMountsFromFilesArtifacts turns filesArtifactExpansions into FileMount's +// file mounts have two cases: +// 1. the referenced files artifact already exists in the planYaml, in which case add the referenced files artifact to the proper filepath as a file mount +// 2. the referenced files artifact does not already exist in the plan, in which case the file MUST have been passed in via a top level arg +// for this case, +// - create new files artifact +// - add the files artifact to the plan +// - add it to as a file mount accordingly +func (planYaml *PlanYaml) getFileMountsFromFilesArtifacts(filesArtifactExpansion *service_directory.FilesArtifactsExpansion) []*FileMount { + var fileMounts []*FileMount + if filesArtifactExpansion == nil { + return fileMounts + } + for mountPath, artifactIdentifiers := range filesArtifactExpansion.ServiceDirpathsToArtifactIdentifiers { + var filesArtifacts []*FilesArtifact + for _, identifier := range artifactIdentifiers { + var filesArtifact *FilesArtifact + // if there's already a files artifact that exists with this name from a previous instruction, reference that + if filesArtifactToReference, ok := planYaml.filesArtifactIndex[identifier]; ok { + filesArtifact = &FilesArtifact{ + Name: filesArtifactToReference.Name, + Uuid: filesArtifactToReference.Uuid, + Files: []string{}, // leave empty because this is referencing an existing files artifact + } + } else { + // otherwise create a new one + // the only information we have about a files artifact that didn't already exist is the name + // if it didn't already exist AND interpretation was successful, it MUST HAVE been passed in via args of run function + filesArtifact = &FilesArtifact{ + Name: identifier, + Uuid: planYaml.generateUuid(), + Files: []string{}, // don't know at interpretation what files are on the artifact when passed in via args + } + planYaml.addFilesArtifactYaml(filesArtifact) + } + filesArtifacts = append(filesArtifacts, filesArtifact) + } + fileMounts = append(fileMounts, &FileMount{ + MountPath: mountPath, + FilesArtifacts: filesArtifacts, + }) + } + return fileMounts +} + func (planYaml *PlanYaml) addServiceYaml(service *Service) { planYaml.privatePlanYaml.Services = append(planYaml.privatePlanYaml.Services, service) }