Skip to content

Commit

Permalink
refactor!: Migrate Kurtosis Print instruction to Starlark framework. …
Browse files Browse the repository at this point in the history
…This restrict the use of `print` to a single argument only. (#80) (#87)

* refactor!: Migrate Kurtosis Print instruction to Starlark framework. This restrict the use of `print` to a single argument only. (#80)

Migrate Kurtosis Print instruction to starlark framework

* feat!: integrate nature theme name to upload command cli (#89)

* fixed the typo

---------

Co-authored-by: Peeeekay <[email protected]>
  • Loading branch information
Guillaume Bouvignies and Peeeekay authored Mar 7, 2023
1 parent 60e357f commit 868da1b
Show file tree
Hide file tree
Showing 24 changed files with 416 additions and 513 deletions.

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions api/golang/core/lib/enclaves/enclave_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,20 @@ func (enclaveCtx *EnclaveContext) GetServices() (map[services.ServiceName]servic
}

// Docs available at https://docs.kurtosis.com/sdk#uploadfilesstring-pathtoupload-string-artifactname
func (enclaveCtx *EnclaveContext) UploadFiles(pathToUpload string, artifactName string) (services.FilesArtifactUUID, error) {
func (enclaveCtx *EnclaveContext) UploadFiles(pathToUpload string, artifactName string) (services.FilesArtifactUUID, services.FileArtifactName, error) {
content, err := shared_utils.CompressPath(pathToUpload, ensureCompressedFileIsLesserThanGRPCLimit)
if err != nil {
return "", stacktrace.Propagate(err,
return "", "", stacktrace.Propagate(err,
"There was an error compressing the file '%v' before upload",
pathToUpload)
}

args := binding_constructors.NewUploadFilesArtifactArgs(content, artifactName)
response, err := enclaveCtx.client.UploadFilesArtifact(context.Background(), args)
if err != nil {
return "", stacktrace.Propagate(err, "An error was encountered while uploading data to the API Container.")
return "", "", stacktrace.Propagate(err, "An error was encountered while uploading data to the API Container.")
}
return services.FilesArtifactUUID(response.Uuid), nil
return services.FilesArtifactUUID(response.GetUuid()), services.FileArtifactName(response.GetName()), nil
}

// Docs available at https://docs.kurtosis.com/sdk#storewebfilesstring-urltodownload-string-artifactname
Expand Down
1 change: 1 addition & 0 deletions api/golang/core/lib/services/service_config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

type FilesArtifactUUID string
type FileArtifactName string

const (
defaultSubnetwork = "default"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions api/protobuf/core/api_container_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ message UploadFilesArtifactArgs {
message UploadFilesArtifactResponse {
// UUID of the files artifact, for use when referencing it in the future
string uuid = 1;

// UUID of the files artifact, for use when referencing it in the future
string name = 2;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Code generated by protoc-gen-grpc-web. DO NOT EDIT.
// versions:
// protoc-gen-grpc-web v1.4.2
// protoc v3.19.1
// protoc v3.15.6
// source: api_container_service.proto


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,9 @@ export class UploadFilesArtifactResponse extends jspb.Message {
getUuid(): string;
setUuid(value: string): UploadFilesArtifactResponse;

getName(): string;
setName(value: string): UploadFilesArtifactResponse;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): UploadFilesArtifactResponse.AsObject;
static toObject(includeInstance: boolean, msg: UploadFilesArtifactResponse): UploadFilesArtifactResponse.AsObject;
Expand All @@ -1044,6 +1047,7 @@ export class UploadFilesArtifactResponse extends jspb.Message {
export namespace UploadFilesArtifactResponse {
export type AsObject = {
uuid: string,
name: string,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@

var jspb = require('google-protobuf');
var goog = jspb;
var global = (function() {
if (this) { return this; }
if (typeof window !== 'undefined') { return window; }
if (typeof global !== 'undefined') { return global; }
if (typeof self !== 'undefined') { return self; }
return Function('return this')();
}.call(null));
var global = Function('return this')();

var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js');
goog.object.extend(proto, google_protobuf_empty_pb);
Expand Down Expand Up @@ -8372,7 +8366,8 @@ proto.api_container_api.UploadFilesArtifactResponse.prototype.toObject = functio
*/
proto.api_container_api.UploadFilesArtifactResponse.toObject = function(includeInstance, msg) {
var f, obj = {
uuid: jspb.Message.getFieldWithDefault(msg, 1, "")
uuid: jspb.Message.getFieldWithDefault(msg, 1, ""),
name: jspb.Message.getFieldWithDefault(msg, 2, "")
};

if (includeInstance) {
Expand Down Expand Up @@ -8413,6 +8408,10 @@ proto.api_container_api.UploadFilesArtifactResponse.deserializeBinaryFromReader
var value = /** @type {string} */ (reader.readString());
msg.setUuid(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.setName(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -8449,6 +8448,13 @@ proto.api_container_api.UploadFilesArtifactResponse.serializeBinaryToWriter = fu
f
);
}
f = message.getName();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
};


Expand All @@ -8470,6 +8476,24 @@ proto.api_container_api.UploadFilesArtifactResponse.prototype.setUuid = function
};


/**
* optional string name = 2;
* @return {string}
*/
proto.api_container_api.UploadFilesArtifactResponse.prototype.getName = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};


/**
* @param {string} value
* @return {!proto.api_container_api.UploadFilesArtifactResponse} returns this
*/
proto.api_container_api.UploadFilesArtifactResponse.prototype.setName = function(value) {
return jspb.Message.setProto3StringField(this, 2, value);
};





Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Code generated by protoc-gen-grpc-web. DO NOT EDIT.
// versions:
// protoc-gen-grpc-web v1.4.2
// protoc v3.19.1
// protoc v3.15.6
// source: engine_service.proto


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@

var jspb = require('google-protobuf');
var goog = jspb;
var global = (function() {
if (this) { return this; }
if (typeof window !== 'undefined') { return window; }
if (typeof global !== 'undefined') { return global; }
if (typeof self !== 'undefined') { return self; }
return Function('return this')();
}.call(null));
var global = Function('return this')();

var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js');
goog.object.extend(proto, google_protobuf_empty_pb);
Expand Down
17 changes: 5 additions & 12 deletions cli/cli/commands/files/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package upload

import (
"context"
"fmt"
"github.com/kurtosis-tech/kurtosis/api/golang/engine/kurtosis_engine_rpc_api_bindings"
"github.com/kurtosis-tech/kurtosis/api/golang/engine/lib/kurtosis_context"
"github.com/kurtosis-tech/kurtosis/cli/cli/command_framework/highlevel/enclave_id_arg"
Expand All @@ -15,7 +14,6 @@ import (
"github.com/kurtosis-tech/stacktrace"
"github.com/sirupsen/logrus"
"os"
"time"
)

const (
Expand All @@ -30,8 +28,6 @@ const (

kurtosisBackendCtxKey = "kurtosis-backend"
engineClientCtxKey = "engine-client"

artifactNamePrefix = "cli-uploaded-artifact-%v"
)

var FilesUploadCmd = &engine_consuming_kurtosis_command.EngineConsumingKurtosisCommand{
Expand Down Expand Up @@ -65,8 +61,8 @@ var FilesUploadCmd = &engine_consuming_kurtosis_command.EngineConsumingKurtosisC

func run(
ctx context.Context,
kurtosisBackend backend_interface.KurtosisBackend,
engineClient kurtosis_engine_rpc_api_bindings.EngineServiceClient,
_ backend_interface.KurtosisBackend,
_ kurtosis_engine_rpc_api_bindings.EngineServiceClient,
_ metrics_client.MetricsClient,
flags *flags.ParsedFlags,
args *args.ParsedArgs,
Expand All @@ -93,19 +89,16 @@ func run(
if err != nil {
return stacktrace.Propagate(err, "An error occurred getting the name to be given to the produced artifact")
}
if artifactName == defaultName {
artifactName = fmt.Sprintf(artifactNamePrefix, time.Now().Unix())
}

filesArtifactUuid, err := enclaveCtx.UploadFiles(path, artifactName)
filesArtifactUuid, fileArtifactName, err := enclaveCtx.UploadFiles(path, artifactName)
if err != nil {
return stacktrace.Propagate(err, "An error occurred uploading files at path '%v' to enclave '%v'", path, enclaveIdentifier)
}
logrus.Infof("Files package '%v' uploaded with UUID: %v", artifactName, filesArtifactUuid)
logrus.Infof("Files package '%v' uploaded with UUID: %v", fileArtifactName, filesArtifactUuid)
return nil
}

func validatePathArg(ctx context.Context, flags *flags.ParsedFlags, args *args.ParsedArgs) error {
func validatePathArg(_ context.Context, _ *flags.ParsedFlags, args *args.ParsedArgs) error {
path, err := args.GetNonGreedyArg(pathArgKey)
if err != nil {
return stacktrace.Propagate(err, "An error occurred getting the path to validate using key '%v'", pathArgKey)
Expand Down
Loading

0 comments on commit 868da1b

Please sign in to comment.