Skip to content

Commit

Permalink
finish swapping future ref mostly
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Feb 29, 2024
1 parent 323ac97 commit 80ace33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
6 changes: 3 additions & 3 deletions core/server/api_container/server/startosis_engine/plan.yml
Expand Up @@ -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
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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...)
}

Expand Down Expand Up @@ -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

Expand Down
Expand Up @@ -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",
Expand All @@ -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)
Expand Down

0 comments on commit 80ace33

Please sign in to comment.