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

feat: add and check port aliasing #2373

Merged
merged 23 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1,421 changes: 716 additions & 705 deletions api/golang/core/kurtosis_core_rpc_api_bindings/api_container_service.pb.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func NewPort(
MaybeApplicationProtocol: maybeApplicationProtocol,
MaybeWaitTimeout: maybeWaitTimeout,
Locked: nil,
Alias: nil,
}
}

Expand Down
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 @@ -81,6 +81,9 @@ message Port {

// this is useful in the cloud context; ignore in local
optional bool locked = 5;

// this is useful in the cloud context; ignore in local
optional string alias = 6;
}

message Container {
Expand Down
3 changes: 3 additions & 0 deletions api/rust/src/api_container_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub struct Port {
/// this is useful in the cloud context; ignore in local
#[prost(bool, optional, tag = "5")]
pub locked: ::core::option::Option<bool>,
/// this is useful in the cloud context; ignore in local
#[prost(string, optional, tag = "6")]
pub alias: ::core::option::Option<::prost::alloc::string::String>,
}
/// Nested message and enum types in `Port`.
pub mod port {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export class Port extends jspb.Message {
hasLocked(): boolean;
clearLocked(): Port;

getAlias(): string;
setAlias(value: string): Port;
hasAlias(): boolean;
clearAlias(): Port;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): Port.AsObject;
static toObject(includeInstance: boolean, msg: Port): Port.AsObject;
Expand All @@ -36,6 +41,7 @@ export namespace Port {
maybeApplicationProtocol: string,
maybeWaitTimeout: string,
locked?: boolean,
alias?: string,
}

export enum TransportProtocol {
Expand All @@ -48,6 +54,11 @@ export namespace Port {
_LOCKED_NOT_SET = 0,
LOCKED = 5,
}

export enum AliasCase {
_ALIAS_NOT_SET = 0,
ALIAS = 6,
}
}

export class Container extends jspb.Message {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,8 @@ proto.api_container_api.Port.toObject = function(includeInstance, msg) {
transportProtocol: jspb.Message.getFieldWithDefault(msg, 2, 0),
maybeApplicationProtocol: jspb.Message.getFieldWithDefault(msg, 3, ""),
maybeWaitTimeout: jspb.Message.getFieldWithDefault(msg, 4, ""),
locked: jspb.Message.getBooleanFieldWithDefault(msg, 5, false)
locked: jspb.Message.getBooleanFieldWithDefault(msg, 5, false),
alias: jspb.Message.getFieldWithDefault(msg, 6, "")
};

if (includeInstance) {
Expand Down Expand Up @@ -1116,6 +1117,10 @@ proto.api_container_api.Port.deserializeBinaryFromReader = function(msg, reader)
var value = /** @type {boolean} */ (reader.readBool());
msg.setLocked(value);
break;
case 6:
var value = /** @type {string} */ (reader.readString());
msg.setAlias(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -1180,6 +1185,13 @@ proto.api_container_api.Port.serializeBinaryToWriter = function(message, writer)
f
);
}
f = /** @type {string} */ (jspb.Message.getField(message, 6));
if (f != null) {
writer.writeString(
6,
f
);
}
};


Expand Down Expand Up @@ -1300,6 +1312,42 @@ proto.api_container_api.Port.prototype.hasLocked = function() {
};


/**
* optional string alias = 6;
* @return {string}
*/
proto.api_container_api.Port.prototype.getAlias = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, ""));
};


/**
* @param {string} value
* @return {!proto.api_container_api.Port} returns this
*/
proto.api_container_api.Port.prototype.setAlias = function(value) {
return jspb.Message.setField(this, 6, value);
};


/**
* Clears the field making it undefined.
* @return {!proto.api_container_api.Port} returns this
*/
proto.api_container_api.Port.prototype.clearAlias = function() {
return jspb.Message.setField(this, 6, undefined);
};


/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.api_container_api.Port.prototype.hasAlias = function() {
return jspb.Message.getField(this, 6) != null;
};



/**
* List of repeated fields within this message type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ export declare class Port extends Message<Port> {
*/
locked?: boolean;

/**
* this is useful in the cloud context; ignore in local
*
* @generated from field: optional string alias = 6;
*/
alias?: string;

constructor(data?: PartialMessage<Port>);

static readonly runtime: typeof proto3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const Port = proto3.makeMessageType(
{ no: 3, name: "maybe_application_protocol", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "maybe_wait_timeout", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 5, name: "locked", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
{ no: 6, name: "alias", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
],
);

Expand Down
1 change: 1 addition & 0 deletions cli/cli/commands/service/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ func parsePortSpecStr(specStr string) (*kurtosis_core_rpc_api_bindings.Port, err
MaybeApplicationProtocol: maybeApplicationProtocol,
MaybeWaitTimeout: defaultPortWaitTimeoutStr, //TODO we should add this to the port's arguments instead of using only a default value
Locked: nil,
Alias: nil,
}, nil
}

Expand Down
8 changes: 4 additions & 4 deletions cli/cli/commands/service/add/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@ func TestParsePortSpecstr_SuccessCases(t *testing.T) {
args: args{
specStr: "http:3333",
},
want: &kurtosis_core_rpc_api_bindings.Port{Number: uint32(3333), TransportProtocol: kurtosis_core_rpc_api_bindings.Port_TCP, MaybeApplicationProtocol: "http", MaybeWaitTimeout: defaultPortWaitTimeoutStr, Locked: nil},
want: &kurtosis_core_rpc_api_bindings.Port{Number: uint32(3333), TransportProtocol: kurtosis_core_rpc_api_bindings.Port_TCP, MaybeApplicationProtocol: "http", MaybeWaitTimeout: defaultPortWaitTimeoutStr, Locked: nil, Alias: nil},
},
{
name: "Successfully parse str with application protocol and with transport protocol",
args: args{
specStr: "http:3333/udp",
},
want: &kurtosis_core_rpc_api_bindings.Port{Number: uint32(3333), TransportProtocol: kurtosis_core_rpc_api_bindings.Port_UDP, MaybeApplicationProtocol: "http", MaybeWaitTimeout: defaultPortWaitTimeoutStr, Locked: nil},
want: &kurtosis_core_rpc_api_bindings.Port{Number: uint32(3333), TransportProtocol: kurtosis_core_rpc_api_bindings.Port_UDP, MaybeApplicationProtocol: "http", MaybeWaitTimeout: defaultPortWaitTimeoutStr, Locked: nil, Alias: nil},
},
{
name: "Successfully parse str without application protocol and with transport protocol",
args: args{
specStr: "3333/udp",
},
want: &kurtosis_core_rpc_api_bindings.Port{Number: uint32(3333), TransportProtocol: kurtosis_core_rpc_api_bindings.Port_UDP, MaybeApplicationProtocol: "", MaybeWaitTimeout: defaultPortWaitTimeoutStr, Locked: nil},
want: &kurtosis_core_rpc_api_bindings.Port{Number: uint32(3333), TransportProtocol: kurtosis_core_rpc_api_bindings.Port_UDP, MaybeApplicationProtocol: "", MaybeWaitTimeout: defaultPortWaitTimeoutStr, Locked: nil, Alias: nil},
},
{
name: "Successfully parse str without application protocol and without transport protocol",
args: args{
specStr: "3333",
},
want: &kurtosis_core_rpc_api_bindings.Port{Number: uint32(3333), TransportProtocol: kurtosis_core_rpc_api_bindings.Port_TCP, MaybeApplicationProtocol: "", MaybeWaitTimeout: defaultPortWaitTimeoutStr, Locked: nil},
want: &kurtosis_core_rpc_api_bindings.Port{Number: uint32(3333), TransportProtocol: kurtosis_core_rpc_api_bindings.Port_TCP, MaybeApplicationProtocol: "", MaybeWaitTimeout: defaultPortWaitTimeoutStr, Locked: nil, Alias: nil},
},
}
for _, parsePortSpecTest := range parsePortSpecSuccessTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ func (service *ApiContainerGatewayServiceServer) startRunningConnectionForKurtos
MaybeApplicationProtocol: privateApiPort.GetMaybeApplicationProtocol(),
MaybeWaitTimeout: privateApiPort.GetMaybeWaitTimeout(),
Locked: nil,
Alias: nil,
}
}

Expand Down