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)