194 releases (9 breaking)

new 0.88.18 Apr 22, 2024
0.88.12 Mar 29, 2024
0.85.53 Dec 20, 2023
0.85.38 Nov 29, 2023
0.80.23 Jul 31, 2023

#1196 in Hardware support

Download history 14/week @ 2023-12-31 35/week @ 2024-01-07 27/week @ 2024-01-14 22/week @ 2024-01-21 13/week @ 2024-02-04 581/week @ 2024-02-11 344/week @ 2024-02-18 588/week @ 2024-02-25 382/week @ 2024-03-03 720/week @ 2024-03-10 156/week @ 2024-03-17 370/week @ 2024-03-24 274/week @ 2024-03-31 259/week @ 2024-04-07 157/week @ 2024-04-14

1,077 downloads per month

BUSL-1.1

185KB
3.5K SLoC

Kurtosis Rust SDK

This is an SDK for Kurtosis, based on the protobufs available here;

Example

Make sure that the engine is running:

kurtosis engine start

Then you can run a Starlark script using Kurtosis+Rust:

use kurtosis_sdk::{engine_api::{engine_service_client::{EngineServiceClient}, CreateEnclaveArgs}, enclave_api::{api_container_service_client::ApiContainerServiceClient, RunStarlarkScriptArgs}};
use kurtosis_sdk::enclave_api::starlark_run_response_line::RunResponseLine::InstructionResult;

const STARLARK_SCRIPT : &str = "
def main(plan):
    plan.print('Hello World!')
";

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // CREATE ENCLAVE
    let mut engine = EngineServiceClient::connect("https://[::1]:9710").await?;
    let create_enclave_response = engine.create_enclave(CreateEnclaveArgs{
        enclave_name: "my-rust-test".to_string(),
        api_container_log_level: "info".to_string(),
        // Default
        api_container_version_tag: "".to_string(),
        is_partitioning_enabled: false,
    }).await?.into_inner();
    
    // CONNECT TO ENCLAVE
    let enclave_port = create_enclave_response.enclave_info.expect("Enclave info must be present").api_container_host_machine_info.expect("Enclave host machine info must be present").grpc_port_on_host_machine;
    let mut enclave = ApiContainerServiceClient::connect(format!("https://[::1]:{}", enclave_port)).await?;
    
    // RUN STARLARK SCRIPT
    let mut run_result = enclave.run_starlark_script(RunStarlarkScriptArgs{
        serialized_script: STARLARK_SCRIPT.to_string(),
        serialized_params: "{}".to_string(),
        dry_run: Option::Some(false),
        parallelism: Option::None,
        main_function_name: "main".to_string(),
    }).await?.into_inner();
    
    // GET OUTPUT LINES
    while let Some(next_message) = run_result.message().await? {
        next_message.run_response_line.map(|line| match line {
            InstructionResult(result) => {
                println!("{}", result.serialized_instruction_result)
            }
            _ => (),
        });
    }
    Ok(())
}

More details can be found on the docs.

Dependencies

~5–7MB
~125K SLoC