Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: protobuf definitions for more idiomatic SDKs #1586

Merged
merged 10 commits into from Oct 30, 2023
1,185 changes: 606 additions & 579 deletions api/golang/core/kurtosis_core_rpc_api_bindings/api_container_service.pb.go

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions api/golang/core/lib/binding_constructors/binding_constructors.go
Expand Up @@ -50,10 +50,10 @@ func NewRunStarlarkScriptArgs(
*parallelismCopy = parallelism
return &kurtosis_core_rpc_api_bindings.RunStarlarkScriptArgs{
SerializedScript: serializedString,
SerializedParams: serializedParams,
SerializedParams: &serializedParams,
DryRun: &dryRun,
Parallelism: parallelismCopy,
MainFunctionName: mainFunctionName,
MainFunctionName: &mainFunctionName,
ExperimentalFeatures: experimentalFeatures,
CloudInstanceId: cloudInstanceIdCopy,
CloudUserId: cloudUserIdCopy,
Expand Down Expand Up @@ -82,11 +82,11 @@ func NewRunStarlarkPackageArgs(
PackageId: packageId,
ClonePackage: &clonePackage,
StarlarkPackageContent: nil,
SerializedParams: serializedParams,
SerializedParams: &serializedParams,
DryRun: &dryRun,
Parallelism: parallelismCopy,
RelativePathToMainFile: relativePathToMainFile,
MainFunctionName: mainFunctionName,
RelativePathToMainFile: &relativePathToMainFile,
MainFunctionName: &mainFunctionName,
ExperimentalFeatures: experimentalFeatures,
CloudInstanceId: cloudInstanceIdCopy,
CloudUserId: cloudUserIdCopy,
Expand Down Expand Up @@ -115,11 +115,11 @@ func NewRunStarlarkRemotePackageArgs(
PackageId: packageId,
ClonePackage: &clonePackage,
StarlarkPackageContent: nil,
SerializedParams: serializedParams,
SerializedParams: &serializedParams,
DryRun: &dryRun,
Parallelism: parallelismCopy,
RelativePathToMainFile: relativePathToMainFile,
MainFunctionName: mainFunctionName,
RelativePathToMainFile: &relativePathToMainFile,
MainFunctionName: &mainFunctionName,
ExperimentalFeatures: experimentalFeatures,
CloudInstanceId: cloudInstanceIdCopy,
CloudUserId: cloudUserIdCopy,
Expand Down
597 changes: 306 additions & 291 deletions api/golang/engine/kurtosis_engine_rpc_api_bindings/engine_service.pb.go

Large diffs are not rendered by default.

42 changes: 24 additions & 18 deletions api/golang/engine/lib/kurtosis_context/kurtosis_context.go
Expand Up @@ -30,7 +30,7 @@ const (
DefaultGrpcEngineServerPortNum = uint16(9710)

// Blank tells the engine server to use the default
defaultApiContainerVersionTag = ""
defaultApiContainerVersionTagStr = ""

serviceLogsStreamContentChanBufferSize = 5

Expand All @@ -42,7 +42,7 @@ const (
)

var (
apiContainerLogLevel = logrus.DebugLevel
defaultApiContainerLogLevelStr = logrus.DebugLevel.String()

apicPortTransportProtocol = portal_api.TransportProtocol_TCP

Expand Down Expand Up @@ -110,12 +110,7 @@ func (kurtosisCtx *KurtosisContext) CreateEnclave(
enclaveName string,
) (*enclaves.EnclaveContext, error) {

createEnclaveArgs := &kurtosis_engine_rpc_api_bindings.CreateEnclaveArgs{
EnclaveName: enclaveName,
ApiContainerVersionTag: defaultApiContainerVersionTag,
ApiContainerLogLevel: apiContainerLogLevel.String(),
Mode: kurtosis_engine_rpc_api_bindings.EnclaveMode_TEST,
}
createEnclaveArgs := newCreateEnclaveArgsWithDefaultValues(enclaveName)

response, err := kurtosisCtx.engineClient.CreateEnclave(ctx, createEnclaveArgs)
if err != nil {
Expand All @@ -136,12 +131,7 @@ func (kurtosisCtx *KurtosisContext) CreateProductionEnclave(
enclaveName string,
) (*enclaves.EnclaveContext, error) {

createEnclaveArgs := &kurtosis_engine_rpc_api_bindings.CreateEnclaveArgs{
EnclaveName: enclaveName,
ApiContainerVersionTag: defaultApiContainerVersionTag,
ApiContainerLogLevel: apiContainerLogLevel.String(),
Mode: kurtosis_engine_rpc_api_bindings.EnclaveMode_PRODUCTION,
}
createEnclaveArgs := newCreateEnclaveArgsWithDefaultValues(enclaveName)

response, err := kurtosisCtx.engineClient.CreateEnclave(ctx, createEnclaveArgs)
if err != nil {
Expand Down Expand Up @@ -260,7 +250,7 @@ func (kurtosisCtx *KurtosisContext) DestroyEnclave(ctx context.Context, enclaveI
// Docs available at https://docs.kurtosis.com/sdk#cleanboolean-shouldcleanall---enclavenameanduuid-removedenclavenameanduuids
func (kurtosisCtx *KurtosisContext) Clean(ctx context.Context, shouldCleanAll bool) ([]*kurtosis_engine_rpc_api_bindings.EnclaveNameAndUuid, error) {
cleanArgs := &kurtosis_engine_rpc_api_bindings.CleanArgs{
ShouldCleanAll: shouldCleanAll,
ShouldCleanAll: &shouldCleanAll,
}
cleanResponse, err := kurtosisCtx.engineClient.Clean(ctx, cleanArgs)
if err != nil {
Expand Down Expand Up @@ -519,10 +509,10 @@ func newGetServiceLogsArgs(
getUserServiceLogsArgs := &kurtosis_engine_rpc_api_bindings.GetServiceLogsArgs{
EnclaveIdentifier: enclaveIdentifier,
ServiceUuidSet: userServiceUuuidSet,
FollowLogs: shouldFollowLogs,
FollowLogs: &shouldFollowLogs,
ConjunctiveFilters: grpcConjunctiveFilters,
ReturnAllLogs: shouldReturnAllLogs,
NumLogLines: numLogLines,
ReturnAllLogs: &shouldReturnAllLogs,
NumLogLines: &numLogLines,
}

return getUserServiceLogsArgs, nil
Expand Down Expand Up @@ -598,3 +588,19 @@ func newServiceLogsStreamContentFromGrpcStreamResponse(

return newServiceLogsStreamContentObj
}

func newCreateEnclaveArgsWithDefaultValues(enclaveName string) *kurtosis_engine_rpc_api_bindings.CreateEnclaveArgs {

defaultApiContainerVersionTag := defaultApiContainerVersionTagStr
defaultApiContainerLogLevel := defaultApiContainerLogLevelStr
defaultEnclaveMode := kurtosis_engine_rpc_api_bindings.EnclaveMode_TEST

createEnclaveArgs := &kurtosis_engine_rpc_api_bindings.CreateEnclaveArgs{
EnclaveName: &enclaveName,
ApiContainerVersionTag: &defaultApiContainerVersionTag,
ApiContainerLogLevel: &defaultApiContainerLogLevel,
Mode: &defaultEnclaveMode,
}

return createEnclaveArgs
}
32 changes: 16 additions & 16 deletions api/protobuf/core/api_container_service.proto
Expand Up @@ -144,7 +144,7 @@ enum Connect {
message RunStarlarkScriptArgs {
string serialized_script = 1;

string serialized_params = 2;
optional string serialized_params = 2;

// Defaults to false
optional bool dry_run = 3;
Expand All @@ -153,7 +153,7 @@ message RunStarlarkScriptArgs {
optional int32 parallelism = 4;

// The name of the main function, the default value is "run"
string main_function_name = 5;
optional string main_function_name = 5;

repeated KurtosisFeatureFlag experimental_features = 6;

Expand All @@ -177,7 +177,7 @@ message RunStarlarkPackageArgs {

// Serialized parameters data for the Starlark package main function
// This should be a valid JSON string
string serialized_params = 5;
optional string serialized_params = 5;

// Defaults to false
optional bool dry_run = 6;
Expand All @@ -192,10 +192,10 @@ message RunStarlarkPackageArgs {
optional bool clone_package = 8;

// The relative main file filepath, the default value is the "main.star" file in the root of a package
string relative_path_to_main_file = 9;
optional string relative_path_to_main_file = 9;

// The name of the main function, the default value is "run"
string main_function_name = 10;
optional string main_function_name = 10;

repeated KurtosisFeatureFlag experimental_features = 11;

Expand Down Expand Up @@ -359,15 +359,15 @@ message WaitForHttpGetEndpointAvailabilityArgs {
//The port of the service to check. For instance 8080
uint32 port = 2;
//The path of the service to check. It mustn't start with the first slash. For instance `service/health`
string path = 3;
optional string path = 3;
//The number of milliseconds to wait until executing the first HTTP call
uint32 initial_delay_milliseconds = 4;
optional uint32 initial_delay_milliseconds = 4;
//Max number of HTTP call attempts that this will execute until giving up and returning an error
uint32 retries = 5;
optional uint32 retries = 5;
//Number of milliseconds to wait between retries
uint32 retries_delay_milliseconds = 6;
optional uint32 retries_delay_milliseconds = 6;
//If the endpoint returns this value, the service will be marked as available (e.g. Hello World).
string body_text = 7;
optional string body_text = 7;
}

// ==============================================================================================
Expand All @@ -379,17 +379,17 @@ message WaitForHttpPostEndpointAvailabilityArgs {
//The port of the service to check. For instance 8080
uint32 port = 2;
//The path of the service to check. It mustn't start with the first slash. For instance `service/health`
string path = 3;
optional string path = 3;
//The content of the request body.
string request_body = 4;
optional string request_body = 4;
//The number of milliseconds to wait until executing the first HTTP call
uint32 initial_delay_milliseconds = 5;
optional uint32 initial_delay_milliseconds = 5;
//Max number of HTTP call attempts that this will execute until giving up and returning an error
uint32 retries = 6;
optional uint32 retries = 6;
//Number of milliseconds to wait between retries
uint32 retries_delay_milliseconds = 7;
optional uint32 retries_delay_milliseconds = 7;
//If the endpoint returns this value, the service will be marked as available (e.g. Hello World).
string body_text = 8;
optional string body_text = 8;
}

// ==============================================================================================
Expand Down
16 changes: 8 additions & 8 deletions api/protobuf/engine/engine_service.proto
Expand Up @@ -43,14 +43,14 @@ message GetEngineInfoResponse {
// ==============================================================================================
message CreateEnclaveArgs {
// The name of the new Kurtosis Enclave
string enclave_name = 1;
optional string enclave_name = 1;
// The image tag of the API container that should be used inside the enclave
// If blank, will use the default version that the engine server uses
string api_container_version_tag = 2;
optional string api_container_version_tag = 2;
// The API container log level
string api_container_log_level = 3;
optional string api_container_log_level = 3;

EnclaveMode mode = 4;
optional EnclaveMode mode = 4;
}

enum EnclaveMode {
Expand Down Expand Up @@ -188,7 +188,7 @@ message DestroyEnclaveArgs {
// ==============================================================================================
message CleanArgs {
// If true, It will clean even the running enclaves
bool should_clean_all = 1;
optional bool should_clean_all = 1;
}

message EnclaveNameAndUuid {
Expand All @@ -210,13 +210,13 @@ message GetServiceLogsArgs {
// "Set" of service UUIDs in the enclave
map<string, bool> service_uuid_set = 2;
// If true, It will follow the container logs
bool follow_logs = 3;
optional bool follow_logs = 3;
// The conjunctive log lines filters, the first filter is applied over the found log lines, the second filter is applied over the filter one result and so on (like grep)
repeated LogLineFilter conjunctive_filters = 4;
// If true, return all log lines
bool return_all_logs = 5;
optional bool return_all_logs = 5;
// If [return_all_logs] is false, return [num_log_lines]
uint32 num_log_lines = 6;
optional uint32 num_log_lines = 6;
}

message GetServiceLogsResponse {
Expand Down
66 changes: 34 additions & 32 deletions api/rust/src/api_container_api.rs
Expand Up @@ -159,17 +159,17 @@ pub struct ServiceInfo {
pub struct RunStarlarkScriptArgs {
#[prost(string, tag = "1")]
pub serialized_script: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub serialized_params: ::prost::alloc::string::String,
#[prost(string, optional, tag = "2")]
pub serialized_params: ::core::option::Option<::prost::alloc::string::String>,
/// Defaults to false
#[prost(bool, optional, tag = "3")]
pub dry_run: ::core::option::Option<bool>,
/// Defaults to 4
#[prost(int32, optional, tag = "4")]
pub parallelism: ::core::option::Option<i32>,
/// The name of the main function, the default value is "run"
#[prost(string, tag = "5")]
pub main_function_name: ::prost::alloc::string::String,
#[prost(string, optional, tag = "5")]
pub main_function_name: ::core::option::Option<::prost::alloc::string::String>,
#[prost(enumeration = "KurtosisFeatureFlag", repeated, tag = "6")]
pub experimental_features: ::prost::alloc::vec::Vec<i32>,
/// Defaults to empty
Expand All @@ -186,8 +186,8 @@ pub struct RunStarlarkPackageArgs {
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, tag = "5")]
pub serialized_params: ::prost::alloc::string::String,
#[prost(string, optional, tag = "5")]
pub serialized_params: ::core::option::Option<::prost::alloc::string::String>,
/// Defaults to false
#[prost(bool, optional, tag = "6")]
pub dry_run: ::core::option::Option<bool>,
Expand All @@ -201,11 +201,13 @@ pub struct RunStarlarkPackageArgs {
#[prost(bool, optional, tag = "8")]
pub clone_package: ::core::option::Option<bool>,
/// The relative main file filepath, the default value is the "main.star" file in the root of a package
#[prost(string, tag = "9")]
pub relative_path_to_main_file: ::prost::alloc::string::String,
#[prost(string, optional, tag = "9")]
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, tag = "10")]
pub main_function_name: ::prost::alloc::string::String,
#[prost(string, optional, tag = "10")]
pub main_function_name: ::core::option::Option<::prost::alloc::string::String>,
#[prost(enumeration = "KurtosisFeatureFlag", repeated, tag = "11")]
pub experimental_features: ::prost::alloc::vec::Vec<i32>,
/// Defaults to empty
Expand Down Expand Up @@ -458,20 +460,20 @@ pub struct WaitForHttpGetEndpointAvailabilityArgs {
#[prost(uint32, tag = "2")]
pub port: u32,
/// The path of the service to check. It mustn't start with the first slash. For instance `service/health`
#[prost(string, tag = "3")]
pub path: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub path: ::core::option::Option<::prost::alloc::string::String>,
/// The number of milliseconds to wait until executing the first HTTP call
#[prost(uint32, tag = "4")]
pub initial_delay_milliseconds: u32,
#[prost(uint32, optional, tag = "4")]
pub initial_delay_milliseconds: ::core::option::Option<u32>,
/// Max number of HTTP call attempts that this will execute until giving up and returning an error
#[prost(uint32, tag = "5")]
pub retries: u32,
#[prost(uint32, optional, tag = "5")]
pub retries: ::core::option::Option<u32>,
/// Number of milliseconds to wait between retries
#[prost(uint32, tag = "6")]
pub retries_delay_milliseconds: u32,
#[prost(uint32, optional, tag = "6")]
pub retries_delay_milliseconds: ::core::option::Option<u32>,
/// If the endpoint returns this value, the service will be marked as available (e.g. Hello World).
#[prost(string, tag = "7")]
pub body_text: ::prost::alloc::string::String,
#[prost(string, optional, tag = "7")]
pub body_text: ::core::option::Option<::prost::alloc::string::String>,
}
/// ==============================================================================================
/// Wait For HTTP Post Endpoint Availability
Expand All @@ -486,23 +488,23 @@ pub struct WaitForHttpPostEndpointAvailabilityArgs {
#[prost(uint32, tag = "2")]
pub port: u32,
/// The path of the service to check. It mustn't start with the first slash. For instance `service/health`
#[prost(string, tag = "3")]
pub path: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub path: ::core::option::Option<::prost::alloc::string::String>,
/// The content of the request body.
#[prost(string, tag = "4")]
pub request_body: ::prost::alloc::string::String,
#[prost(string, optional, tag = "4")]
pub request_body: ::core::option::Option<::prost::alloc::string::String>,
/// The number of milliseconds to wait until executing the first HTTP call
#[prost(uint32, tag = "5")]
pub initial_delay_milliseconds: u32,
#[prost(uint32, optional, tag = "5")]
pub initial_delay_milliseconds: ::core::option::Option<u32>,
/// Max number of HTTP call attempts that this will execute until giving up and returning an error
#[prost(uint32, tag = "6")]
pub retries: u32,
#[prost(uint32, optional, tag = "6")]
pub retries: ::core::option::Option<u32>,
/// Number of milliseconds to wait between retries
#[prost(uint32, tag = "7")]
pub retries_delay_milliseconds: u32,
#[prost(uint32, optional, tag = "7")]
pub retries_delay_milliseconds: ::core::option::Option<u32>,
/// If the endpoint returns this value, the service will be marked as available (e.g. Hello World).
#[prost(string, tag = "8")]
pub body_text: ::prost::alloc::string::String,
#[prost(string, optional, tag = "8")]
pub body_text: ::core::option::Option<::prost::alloc::string::String>,
}
/// ==============================================================================================
/// Streamed Data Chunk
Expand Down