Skip to content

Commit

Permalink
Merge branch 'main' into lporoli/fix-files-artifact-in-debug
Browse files Browse the repository at this point in the history
  • Loading branch information
leoporoli authored Feb 6, 2024
2 parents e8f01d4 + 4545b79 commit 1576373
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 26 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [0.86.13](https://github.com/kurtosis-tech/kurtosis/compare/0.86.12...0.86.13) (2024-02-05)


### Features

* add `env_vars` as input to `run_sh` ([#2114](https://github.com/kurtosis-tech/kurtosis/issues/2114)) ([5a30ea7](https://github.com/kurtosis-tech/kurtosis/commit/5a30ea75865bfc5fb9359d3da206124d13ebc45e)), closes [#2050](https://github.com/kurtosis-tech/kurtosis/issues/2050)
* add nodejs devtools to Nix ([#2099](https://github.com/kurtosis-tech/kurtosis/issues/2099)) ([7bbb2bc](https://github.com/kurtosis-tech/kurtosis/commit/7bbb2bc7a5487b05f91089634beed5e83e3329de))
* add run docker compose with kurtosis guide ([#2085](https://github.com/kurtosis-tech/kurtosis/issues/2085)) ([7bbe479](https://github.com/kurtosis-tech/kurtosis/commit/7bbe4796a5b1e952fb85d7cf89136b34ad35f70a))
* Add RunStarlarkScript to enclave manager API ([#2103](https://github.com/kurtosis-tech/kurtosis/issues/2103)) ([1eeb3eb](https://github.com/kurtosis-tech/kurtosis/commit/1eeb3eb3880e8df83c78642dce391070cda9f515))


### Bug Fixes

* adding the `core script build call`, which was removed by accident, in the main build script ([#2118](https://github.com/kurtosis-tech/kurtosis/issues/2118)) ([1f73821](https://github.com/kurtosis-tech/kurtosis/commit/1f738216851718bda1ebf9f9bf8936a715ae2cdf))
* Fix calls to stacktrace in the reverse proxy module ([#2100](https://github.com/kurtosis-tech/kurtosis/issues/2100)) ([a7fefc2](https://github.com/kurtosis-tech/kurtosis/commit/a7fefc235676335d195c4f98a10bb31c5b46a794))

## [0.86.12](https://github.com/kurtosis-tech/kurtosis/compare/0.86.11...0.86.12) (2024-01-25)


Expand Down
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Business Source License 1.1
Parameters

Licensor: Kurtosis Technologies, Inc.
Licensed Work: Kurtosis 0.86.12
Licensed Work: Kurtosis 0.86.13
The Licensed Work is (c) 2024 Kurtosis Technologies, Inc.
Additional Use Grant: You may make use of the Licensed Work, provided that
you may not use the Licensed Work for an Environment Orchestration Service.
Expand All @@ -12,7 +12,7 @@ you may not use the Licensed Work for an Environment Orchestration Service.
allows third parties (other than your employees and
contractors) to create distributed system environments.

Change Date: 2028-01-25
Change Date: 2028-02-05

Change License: Apache 2.0 (Apache License, Version 2.0)

Expand Down
2 changes: 1 addition & 1 deletion api/golang/kurtosis_version/kurtosis_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ const (
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
// This is necessary so that Kurt Core consumers will know if they're compatible with the currently-running
// API container
KurtosisVersion = "0.86.12"
KurtosisVersion = "0.86.13"
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
)
2 changes: 1 addition & 1 deletion api/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kurtosis-sdk"
version = "0.86.12"
version = "0.86.13"
license = "BUSL-1.1"
description = "Rust SDK for Kurtosis"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion api/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kurtosis-sdk",
"//": "NOTE: DO NOT UPDATE THIS VERSION MANUALLY - IT WILL BE UPDATED DURING THE RELEASE PROCESS!",
"version": "0.86.12",
"version": "0.86.13",
"main": "./build/index",
"description": "This repo contains a Typescript client for communicating with the Kurtosis Engine server, which is responsible for creating, managing and destroying Kurtosis Enclaves.",
"types": "./build/index",
Expand Down
2 changes: 1 addition & 1 deletion api/typescript/src/kurtosis_version/kurtosis_version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
// This is necessary so that Kurt Core consumers (e.g. modules) will know if they're compatible with the currently-running
// API container
export const KURTOSIS_VERSION: string = "0.86.12"
export const KURTOSIS_VERSION: string = "0.86.13"
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,13 @@ func (builtin *RunPythonCapabilities) Interpret(_ string, arguments *builtin_arg
}
}

envVars, interpretationErr := extractEnvVarsIfDefined(arguments)
if err != nil {
return nil, interpretationErr
}

// build a service config from image and files artifacts expansion.
builtin.serviceConfig, err = getServiceConfig(image, filesArtifactExpansion)
builtin.serviceConfig, err = getServiceConfig(image, filesArtifactExpansion, envVars)
if err != nil {
return nil, startosis_errors.WrapWithInterpretationError(err, "An error occurred creating service config using image '%s'", image)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ func NewRunShService(serviceNetwork service_network.ServiceNetwork, runtimeValue
IsOptional: true,
ZeroValueProvider: builtin_argument.ZeroValueProvider[*starlark.List],
},
{
Name: EnvVarsArgName,
IsOptional: true,
ZeroValueProvider: builtin_argument.ZeroValueProvider[*starlark.Dict],
Validator: nil,
},
{
Name: WaitArgName,
IsOptional: true,
Expand Down Expand Up @@ -90,6 +96,7 @@ func NewRunShService(serviceNetwork service_network.ServiceNetwork, runtimeValue
FilesArgName: true,
StoreFilesArgName: true,
WaitArgName: true,
EnvVarsArgName: true,
},
}
}
Expand Down Expand Up @@ -147,8 +154,13 @@ func (builtin *RunShCapabilities) Interpret(_ string, arguments *builtin_argumen
}
}

envVars, interpretationErr := extractEnvVarsIfDefined(arguments)
if err != nil {
return nil, interpretationErr
}

// build a service config from image and files artifacts expansion.
builtin.serviceConfig, err = getServiceConfig(image, filesArtifactExpansion)
builtin.serviceConfig, err = getServiceConfig(image, filesArtifactExpansion, envVars)
if err != nil {
return nil, startosis_errors.WrapWithInterpretationError(err, "An error occurred creating service config using image '%s'", image)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
StoreFilesArgName = "store"
WaitArgName = "wait"
FilesArgName = "files"
EnvVarsArgName = "env_vars"

newlineChar = "\n"

Expand Down Expand Up @@ -248,7 +249,11 @@ func resultMapToString(resultMap map[string]starlark.Comparable, builtinNameForL
return fmt.Sprintf("Command returned with exit code '%v' and the following output: %v", exitCode, outputStr)
}

func getServiceConfig(image string, filesArtifactExpansion *service_directory.FilesArtifactsExpansion) (*service.ServiceConfig, error) {
func getServiceConfig(
image string,
filesArtifactExpansion *service_directory.FilesArtifactsExpansion,
envVars *map[string]string,
) (*service.ServiceConfig, error) {
serviceConfig, err := service.CreateServiceConfig(
image,
nil,
Expand All @@ -262,7 +267,7 @@ func getServiceConfig(image string, filesArtifactExpansion *service_directory.Fi
// command is completed
runTailCommandToPreventContainerToStopOnCreating,
nil,
nil,
*envVars,
filesArtifactExpansion,
nil,
0,
Expand Down Expand Up @@ -293,3 +298,21 @@ func removeService(ctx context.Context, serviceNetwork service_network.ServiceNe
}
return nil
}

func extractEnvVarsIfDefined(arguments *builtin_argument.ArgumentValuesSet) (*map[string]string, *startosis_errors.InterpretationError) {
envVars := map[string]string{}
if arguments.IsSet(EnvVarsArgName) {
envVarsStarlark, err := builtin_argument.ExtractArgumentValue[*starlark.Dict](arguments, EnvVarsArgName)
if err != nil {
return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", EnvVarsArgName)
}
if envVarsStarlark != nil && envVarsStarlark.Len() > 0 {
var interpretationErr *startosis_errors.InterpretationError
envVars, interpretationErr = kurtosis_types.SafeCastToMapStringString(envVarsStarlark, EnvVarsArgName)
if interpretationErr != nil {
return nil, interpretationErr
}
}
}
return &envVars, nil
}
41 changes: 41 additions & 0 deletions docs/docs/api-reference/starlark-reference/exec-recipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,47 @@ If you are trying to run a complex `command` with `|`, you should prefix the com
be rewritten as `command = ["/bin/sh", "-c", "echo a | grep a"]`. Not doing so makes everything after the `echo` as args of that command, instead of following the behavior you would expect from a shell.
:::

:::tip
If the executed command returns a proper `JSON` formatted data structure, it's necessary to pass the output through `jq`'s `fromjson` function to enable `jq` to parse the input.
For more information on `jq`'s built-in methods, plese refer to `jq`'s documentation. The following is an example of how to parse the json formatted output using `jq` syntax:

Example:
```
def run(plan, args={}):
plan.add_service(
name = "service",
config = ServiceConfig(
image = "alpine",
entrypoint = ["/bin/sh", "-c", "sleep infinity"],
)
)
cmd = ''' echo '{"key": "value"}' '''
result = plan.exec(
service_name = "service",
recipe = ExecRecipe(
command = ["/bin/sh", "-c", cmd],
extract = {
"example_reference_key": "fromjson | .key" # <----- Notice the use of `fromjson`
}
),
)
plan.print(result["output"])
plan.print(result["extract.example_reference_key"])
```

will output:
```
> print msg="{{kurtosis:1f60460f3eee4036af01b41fc2ecddc0:output.runtime_value}}"
{"key": "value"}
> print msg="{{kurtosis:1f60460f3eee4036af01b41fc2ecddc0:extract.example_reference_key.runtime_value}}"
value
```

:::


<!--------------- ONLY LINKS BELOW THIS POINT ---------------------->
[exec-reference]: ./plan.md#exec
[wait-reference]: ./plan.md#wait
7 changes: 7 additions & 0 deletions docs/docs/api-reference/starlark-reference/plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,13 @@ The `run_sh` instruction executes a one-time execution task. It runs the bash co
# OPTIONAL (Default: badouralix/curl-jq)
image = "badouralix/curl-jq",

# Defines environment variables that should be set inside the Docker container running the task.
# OPTIONAL (Default: {})
env_vars = {
"VAR_1": "VALUE_1",
"VAR_2": "VALUE_2",
},

# A mapping of path_on_task_where_contents_will_be_mounted -> files_artifact_id_to_mount
# For more information about file artifacts, see below.
# CAUTION: duplicate paths to files or directories to be mounted is not supported, and it will fail
Expand Down
5 changes: 0 additions & 5 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ const config = {
label: 'Starlark',
activeBasePath: '/sdk'
},
{
href: 'https://web3.kurtosis.com',
position: 'left',
label: 'Kurtosis for Web3',
},
{
href: 'https://www.kurtosis.com/release-notes',
position: 'left',
Expand Down
5 changes: 0 additions & 5 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ const sidebars = {
]
},
'code-examples',
{
"type": "link",
"label": "Kurtosis for Web3",
"href": "https://web3.kurtosis.com",
},
'faq',
'best-practices',
'roadmap',
Expand Down
2 changes: 1 addition & 1 deletion enclave-manager/web/lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages": ["packages/*"],
"version": "0.86.12",
"version": "0.86.13",
"npmClient": "yarn",
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": false,
Expand Down
4 changes: 2 additions & 2 deletions enclave-manager/web/packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kurtosis/emui-app",
"version": "0.86.12",
"version": "0.86.13",
"private": true,
"homepage": ".",
"dependencies": {
Expand All @@ -9,7 +9,7 @@
"html-react-parser": "^4.2.2",
"js-cookie": "^3.0.5",
"kurtosis-cloud-indexer-sdk": "^0.0.2",
"kurtosis-ui-components": "0.86.12",
"kurtosis-ui-components": "0.86.13",
"react-error-boundary": "^4.0.11",
"react-hook-form": "^7.47.0",
"yaml": "^2.3.4"
Expand Down
2 changes: 1 addition & 1 deletion enclave-manager/web/packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kurtosis-ui-components",
"version": "0.86.12",
"version": "0.86.13",
"private": false,
"main": "build/index",
"description": "This repo contains components used by Kurtosis UI applications.",
Expand Down
2 changes: 1 addition & 1 deletion internal_testsuites/golang/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lang_root_dirpath="$(dirname "${script_dirpath}")"
# ==================================================================================================
PARALLELISM=2
DOCKER_TIMEOUT="3m" # This must be Go-parseable timeout
KUBERNETES_TIMEOUT="8m" # K8S takes longer than docker
KUBERNETES_TIMEOUT="510s" # K8S takes longer than docker

TESTSUITE_CLUSTER_BACKEND_DOCKER="docker"
TESTSUITE_CLUSTER_BACKEND_KUBERNETES="kubernetes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def run(plan):
result2 = plan.run_sh(run="cat /temp/tech.txt | tr -d '\n'", files={"/temp": file_artifacts[0]})
plan.verify(result2.output, "==", "kurtosis")
`

runShWithEnvVar = `
def run(plan):
result = plan.run_sh(run="mkdir -p kurtosis && echo $EXAMPLE",image="badouralix/curl-jq",env_vars={"EXAMPLE": "value"})
plan.verify(result.output, "==", "value\n")
`
)

func TestStarlark_RunshTaskSimple(t *testing.T) {
Expand Down Expand Up @@ -101,3 +107,9 @@ func TestStarlark_RunShWithNewLineRemovalPipe(t *testing.T) {
_, err := test_helpers.SetupSimpleEnclaveAndRunScript(t, ctx, runshTest, runShWithNewLineRemoval)
require.Nil(t, err)
}

func TestStarlark_RunShWithEnvVars(t *testing.T) {
ctx := context.Background()
_, err := test_helpers.SetupSimpleEnclaveAndRunScript(t, ctx, runshTest, runShWithEnvVar)
require.Nil(t, err)
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.86.12
0.86.13

0 comments on commit 1576373

Please sign in to comment.