Skip to content

Commit

Permalink
pull local package
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Nov 25, 2024
1 parent 8f763bd commit 18de25e
Show file tree
Hide file tree
Showing 10 changed files with 310 additions and 201 deletions.

Large diffs are not rendered by default.

38 changes: 37 additions & 1 deletion api/golang/core/lib/enclaves/enclave_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,49 @@ func (enclaveCtx *EnclaveContext) GetStarlarkRun(ctx context.Context) (*kurtosis
return response, nil
}

func (enclaveCtx *EnclaveContext) GetStarlarkPackagePlanYaml(ctx context.Context, packageId string, serializedParams string) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) {
func (enclaveCtx *EnclaveContext) GetStarlarkRemotePackagePlanYaml(ctx context.Context, packageId string, serializedParams string) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) {
serializedParams, err := maybeParseYaml(serializedParams)
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred when parsing YAML args for package '%s':\n%s", packageId, serializedParams)
}
response, err := enclaveCtx.client.GetStarlarkPackagePlanYaml(ctx, &kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs{
PackageId: packageId,
IsRemote: true,
SerializedParams: &serializedParams,
RelativePathToMainFile: nil,
MainFunctionName: nil,
})
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred while getting the Starlark package plan yaml.")
}
return response, nil
}

func (enclaveCtx *EnclaveContext) GetStarlarkPackagePlanYaml(ctx context.Context, packageRootPath string, serializedParams string) (*kurtosis_core_rpc_api_bindings.PlanYaml, error) {
packageName, packageReplaceOptions, err := getPackageNameAndReplaceOptions(packageRootPath)
if err != nil {
return nil, err
}

serializedParams, err = maybeParseYaml(serializedParams)
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred when parsing YAML args for package '%s':\n%s", packageName, serializedParams)
}

err = enclaveCtx.uploadStarlarkPackage(packageName, packageRootPath)
if err != nil {
return nil, stacktrace.Propagate(err, "Error uploading package '%s' prior to executing it", packageRootPath)
}

if len(packageReplaceOptions) > 0 {
if err = enclaveCtx.uploadLocalStarlarkPackageDependencies(packageRootPath, packageReplaceOptions); err != nil {
return nil, stacktrace.Propagate(err, "An error occurred while uploading the local starlark package dependencies from the replace options '%+v'", packageReplaceOptions)
}
}

response, err := enclaveCtx.client.GetStarlarkPackagePlanYaml(ctx, &kurtosis_core_rpc_api_bindings.StarlarkPackagePlanYamlArgs{
PackageId: packageName,
IsRemote: false,
SerializedParams: &serializedParams,
RelativePathToMainFile: nil,
MainFunctionName: nil,
Expand Down
9 changes: 6 additions & 3 deletions api/protobuf/core/api_container_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,16 @@ message StarlarkScriptPlanYamlArgs {
message StarlarkPackagePlanYamlArgs {
string package_id = 1;

// whether or not this is package yaml should be pulled from on disk package or cloned
bool is_remote = 2;

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

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

// The name of the main function, the default value is "run"
optional string main_function_name = 4;
optional string main_function_name = 5;
}
9 changes: 6 additions & 3 deletions api/rust/src/api_container_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,17 +715,20 @@ pub struct StarlarkScriptPlanYamlArgs {
pub struct StarlarkPackagePlanYamlArgs {
#[prost(string, tag = "1")]
pub package_id: ::prost::alloc::string::String,
/// whether or not this is package yaml should be pulled from on disk package or cloned
#[prost(bool, tag = "2")]
pub is_remote: bool,
/// Serialized parameters data for the Starlark package main function
/// This should be a valid JSON string
#[prost(string, optional, tag = "2")]
#[prost(string, optional, tag = "3")]
pub serialized_params: ::core::option::Option<::prost::alloc::string::String>,
/// The relative main file filepath, the default value is the "main.star" file in the root of a package
#[prost(string, optional, tag = "3")]
#[prost(string, optional, tag = "4")]
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, optional, tag = "4")]
#[prost(string, optional, tag = "5")]
pub main_function_name: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,9 @@ export class StarlarkPackagePlanYamlArgs extends jspb.Message {
getPackageId(): string;
setPackageId(value: string): StarlarkPackagePlanYamlArgs;

getIsRemote(): boolean;
setIsRemote(value: boolean): StarlarkPackagePlanYamlArgs;

getSerializedParams(): string;
setSerializedParams(value: string): StarlarkPackagePlanYamlArgs;
hasSerializedParams(): boolean;
Expand All @@ -1567,24 +1570,25 @@ export class StarlarkPackagePlanYamlArgs extends jspb.Message {
export namespace StarlarkPackagePlanYamlArgs {
export type AsObject = {
packageId: string,
isRemote: boolean,
serializedParams?: string,
relativePathToMainFile?: string,
mainFunctionName?: string,
}

export enum SerializedParamsCase {
_SERIALIZED_PARAMS_NOT_SET = 0,
SERIALIZED_PARAMS = 2,
SERIALIZED_PARAMS = 3,
}

export enum RelativePathToMainFileCase {
_RELATIVE_PATH_TO_MAIN_FILE_NOT_SET = 0,
RELATIVE_PATH_TO_MAIN_FILE = 3,
RELATIVE_PATH_TO_MAIN_FILE = 4,
}

export enum MainFunctionNameCase {
_MAIN_FUNCTION_NAME_NOT_SET = 0,
MAIN_FUNCTION_NAME = 4,
MAIN_FUNCTION_NAME = 5,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11107,9 +11107,10 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.toObject = functio
proto.api_container_api.StarlarkPackagePlanYamlArgs.toObject = function(includeInstance, msg) {
var f, obj = {
packageId: jspb.Message.getFieldWithDefault(msg, 1, ""),
serializedParams: jspb.Message.getFieldWithDefault(msg, 2, ""),
relativePathToMainFile: jspb.Message.getFieldWithDefault(msg, 3, ""),
mainFunctionName: jspb.Message.getFieldWithDefault(msg, 4, "")
isRemote: jspb.Message.getBooleanFieldWithDefault(msg, 2, false),
serializedParams: jspb.Message.getFieldWithDefault(msg, 3, ""),
relativePathToMainFile: jspb.Message.getFieldWithDefault(msg, 4, ""),
mainFunctionName: jspb.Message.getFieldWithDefault(msg, 5, "")
};

if (includeInstance) {
Expand Down Expand Up @@ -11151,14 +11152,18 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.deserializeBinaryFromReader
msg.setPackageId(value);
break;
case 2:
var value = /** @type {boolean} */ (reader.readBool());
msg.setIsRemote(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString());
msg.setSerializedParams(value);
break;
case 3:
case 4:
var value = /** @type {string} */ (reader.readString());
msg.setRelativePathToMainFile(value);
break;
case 4:
case 5:
var value = /** @type {string} */ (reader.readString());
msg.setMainFunctionName(value);
break;
Expand Down Expand Up @@ -11198,9 +11203,9 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.serializeBinaryToWriter = fu
f
);
}
f = /** @type {string} */ (jspb.Message.getField(message, 2));
if (f != null) {
writer.writeString(
f = message.getIsRemote();
if (f) {
writer.writeBool(
2,
f
);
Expand All @@ -11219,6 +11224,13 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.serializeBinaryToWriter = fu
f
);
}
f = /** @type {string} */ (jspb.Message.getField(message, 5));
if (f != null) {
writer.writeString(
5,
f
);
}
};


Expand All @@ -11241,11 +11253,29 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setPackageId = fun


/**
* optional string serialized_params = 2;
* optional bool is_remote = 2;
* @return {boolean}
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.getIsRemote = function() {
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false));
};


/**
* @param {boolean} value
* @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setIsRemote = function(value) {
return jspb.Message.setProto3BooleanField(this, 2, value);
};


/**
* optional string serialized_params = 3;
* @return {string}
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.getSerializedParams = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};


Expand All @@ -11254,7 +11284,7 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.getSerializedParam
* @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setSerializedParams = function(value) {
return jspb.Message.setField(this, 2, value);
return jspb.Message.setField(this, 3, value);
};


Expand All @@ -11263,7 +11293,7 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setSerializedParam
* @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.clearSerializedParams = function() {
return jspb.Message.setField(this, 2, undefined);
return jspb.Message.setField(this, 3, undefined);
};


Expand All @@ -11272,16 +11302,16 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.clearSerializedPar
* @return {boolean}
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.hasSerializedParams = function() {
return jspb.Message.getField(this, 2) != null;
return jspb.Message.getField(this, 3) != null;
};


/**
* optional string relative_path_to_main_file = 3;
* optional string relative_path_to_main_file = 4;
* @return {string}
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.getRelativePathToMainFile = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, ""));
};


Expand All @@ -11290,7 +11320,7 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.getRelativePathToM
* @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setRelativePathToMainFile = function(value) {
return jspb.Message.setField(this, 3, value);
return jspb.Message.setField(this, 4, value);
};


Expand All @@ -11299,7 +11329,7 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setRelativePathToM
* @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.clearRelativePathToMainFile = function() {
return jspb.Message.setField(this, 3, undefined);
return jspb.Message.setField(this, 4, undefined);
};


Expand All @@ -11308,16 +11338,16 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.clearRelativePathT
* @return {boolean}
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.hasRelativePathToMainFile = function() {
return jspb.Message.getField(this, 3) != null;
return jspb.Message.getField(this, 4) != null;
};


/**
* optional string main_function_name = 4;
* optional string main_function_name = 5;
* @return {string}
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.getMainFunctionName = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, ""));
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, ""));
};


Expand All @@ -11326,7 +11356,7 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.getMainFunctionNam
* @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setMainFunctionName = function(value) {
return jspb.Message.setField(this, 4, value);
return jspb.Message.setField(this, 5, value);
};


Expand All @@ -11335,7 +11365,7 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.setMainFunctionNam
* @return {!proto.api_container_api.StarlarkPackagePlanYamlArgs} returns this
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.clearMainFunctionName = function() {
return jspb.Message.setField(this, 4, undefined);
return jspb.Message.setField(this, 5, undefined);
};


Expand All @@ -11344,7 +11374,7 @@ proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.clearMainFunctionN
* @return {boolean}
*/
proto.api_container_api.StarlarkPackagePlanYamlArgs.prototype.hasMainFunctionName = function() {
return jspb.Message.getField(this, 4) != null;
return jspb.Message.getField(this, 5) != null;
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1906,25 +1906,32 @@ export declare class StarlarkPackagePlanYamlArgs extends Message<StarlarkPackage
*/
packageId: string;

/**
* whether or not this is package yaml should be pulled from on disk package or cloned
*
* @generated from field: bool is_remote = 2;
*/
isRemote: boolean;

/**
* Serialized parameters data for the Starlark package main function
* This should be a valid JSON string
*
* @generated from field: optional string serialized_params = 2;
* @generated from field: optional string serialized_params = 3;
*/
serializedParams?: string;

/**
* The relative main file filepath, the default value is the "main.star" file in the root of a package
*
* @generated from field: optional string relative_path_to_main_file = 3;
* @generated from field: optional string relative_path_to_main_file = 4;
*/
relativePathToMainFile?: string;

/**
* The name of the main function, the default value is "run"
*
* @generated from field: optional string main_function_name = 4;
* @generated from field: optional string main_function_name = 5;
*/
mainFunctionName?: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,10 @@ export const StarlarkPackagePlanYamlArgs = proto3.makeMessageType(
"api_container_api.StarlarkPackagePlanYamlArgs",
() => [
{ no: 1, name: "package_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "serialized_params", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
{ no: 3, name: "relative_path_to_main_file", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
{ no: 4, name: "main_function_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
{ no: 2, name: "is_remote", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 3, name: "serialized_params", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
{ no: 4, name: "relative_path_to_main_file", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
{ no: 5, name: "main_function_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
],
);

Loading

0 comments on commit 18de25e

Please sign in to comment.