Skip to content

Commit

Permalink
feat: Make the cloud instance config available to the EM UI (#2350)
Browse files Browse the repository at this point in the history
## Description
The EM UI needs to retrieve the cloud instance config as part of the
instance termination warning work. We add this method to the EM API. The
cloud api requires typescript bindings so the GetCloudInstanceConfig
response definition can be found.

## Is this change user facing?
NO
  • Loading branch information
laurentluce authored Apr 3, 2024
1 parent 1900abe commit 8b9b5ce
Show file tree
Hide file tree
Showing 16 changed files with 1,475 additions and 271 deletions.
31 changes: 30 additions & 1 deletion cloud/api/scripts/regenerate-proto-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,38 @@ api_golang_proto_generated_rel_dir="golang"
api_go_mod_rel_file="golang/go.mod"

# Typescript
#api_typescript_proto_generated_rel_dir="typescript/src/generated"
api_typescript_rel_dir="typescript"

NODE_ES_TOOLS_PROTOC_BIN_FILENAME="protoc-gen-es"

NODE_CONNECT_ES_TOOLS_PROTOC_BIN_FILENAME="protoc-gen-connect-es"

# ==================================================================================================
# Main Logic
# ==================================================================================================

if ! node_es_protoc_bin_filepath="$(which "${NODE_ES_TOOLS_PROTOC_BIN_FILENAME}")"; then
echo "Error: Couldn't find Node gRPC tools protoc plugin binary '${NODE_ES_TOOLS_PROTOC_BIN_FILENAME}' on the PATH" >&2
return 1
fi
if [ -z "${node_es_protoc_bin_filepath}" ]; then
echo "Error: Got an empty filepath when looking for the Node gRPC tools protoc plugin binary '${NODE_ES_TOOLS_PROTOC_BIN_FILENAME}'" >&2
return 1
fi

if ! node_connect_es_protoc_bin_filepath="$(which "${NODE_CONNECT_ES_TOOLS_PROTOC_BIN_FILENAME}")"; then
echo "Error: Couldn't find Node gRPC tools protoc plugin binary '${NODE_CONNECT_ES_TOOLS_PROTOC_BIN_FILENAME}' on the PATH" >&2
return 1
fi
if [ -z "${node_connect_es_protoc_bin_filepath}" ]; then
echo "Error: Got an empty filepath when looking for the Node gRPC tools protoc plugin binary '${NODE_CONNECT_ES_TOOLS_PROTOC_BIN_FILENAME}'" >&2
return 1
fi

api_proto_abs_dir="${root_dirpath}/${api_proto_rel_dir}"
api_google_dependency_abs_dir="${api_proto_abs_dir}/google"

api_typescript_abs_dir="${root_dirpath}/${api_typescript_rel_dir}"
api_golang_proto_generated_abs_dir="${root_dirpath}/${api_golang_proto_generated_rel_dir}"
api_go_mod_abs_file="${root_dirpath}/${api_go_mod_rel_file}"
api_golang_module="$(grep "^${GO_MOD_FILE_MODULE_KEYWORD}" "${api_go_mod_abs_file}" | awk '{print $2}')"
Expand All @@ -47,6 +70,12 @@ protoc \
--go-grpc_opt=require_unimplemented_servers=false \
--connect-go_out="${api_golang_proto_generated_abs_dir}" \
--connect-go_opt=module="${api_golang_module}" \
--plugin=protoc-gen-es="${node_es_protoc_bin_filepath}" \
--es_out="${api_typescript_abs_dir}/src/" \
--es_opt=target=ts \
--plugin=protoc-gen-connect-es="${node_connect_es_protoc_bin_filepath}" \
--connect-es_out="${api_typescript_abs_dir}/src/" \
--connect-es_opt=target=ts \
"${api_proto_abs_dir}"/*.proto


46 changes: 46 additions & 0 deletions cloud/api/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"version": "0.0.0",
"name": "kurtosis-cloud-sdk",
"main": "./build/index",
"description": "This repo contains a Typescript client for communicating with the Kurtosis cloud backend.",
"types": "./build/index",
"scripts": {
"clean": "rm -rf build",
"build": "tsc",
"test": "jest"
},
"files": [
"build"
],
"repository": {
"type": "git",
"url": "git+https://github.com/kurtosis-tech/kurtosis-cloud-sdk.git"
},
"keywords": [
"kurtosis",
"cloud"
],
"author": "Kurtosis Technologies Inc <[email protected]> (https://www.kurtosistech.com/)",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/kurtosis-tech/kurtosis-cloud-sdk/issues"
},
"homepage": "https://github.com/kurtosis-tech/kurtosis-cloud-sdk#readme",
"engines": {
"node": ">=16.13.0"
},
"dependencies": {
"@bufbuild/protobuf": "^1.3.3",
"@connectrpc/connect": "^0.13.0",
"@connectrpc/connect-web": "^0.13.0"
},
"devDependencies": {
"@babel/core": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"@bufbuild/protoc-gen-es": "^1.3.3",
"@connectrpc/protoc-gen-connect-es": "^0.13.0",
"@types/jest": "^29.5.6",
"jest": "^29.7.0",
"typescript": "^4.3.5"
}
}
91 changes: 91 additions & 0 deletions cloud/api/typescript/src/kurtosis_backend_server_api_connect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// @generated by protoc-gen-connect-es v0.13.0 with parameter "target=ts"
// @generated from file kurtosis_backend_server_api.proto (package kurtosis_cloud, syntax proto3)
/* eslint-disable */
// @ts-nocheck

import { Empty, MethodIdempotency, MethodKind } from "@bufbuild/protobuf";
import { CancelPaymentSubscriptionArgs, GetCloudInstanceConfigArgs, GetCloudInstanceConfigResponse, GetOrCreateApiKeyRequest, GetOrCreateApiKeyResponse, GetOrCreateInstanceRequest, GetOrCreateInstanceResponse, GetOrCreatePaymentConfigArgs, GetOrCreatePaymentConfigResponse, RefreshDefaultPaymentMethodArgs, UpdateAddressArgs } from "./kurtosis_backend_server_api_pb.js";

/**
* @generated from service kurtosis_cloud.KurtosisCloudBackendServer
*/
export const KurtosisCloudBackendServer = {
typeName: "kurtosis_cloud.KurtosisCloudBackendServer",
methods: {
/**
* @generated from rpc kurtosis_cloud.KurtosisCloudBackendServer.IsAvailable
*/
isAvailable: {
name: "IsAvailable",
I: Empty,
O: Empty,
kind: MethodKind.Unary,
idempotency: MethodIdempotency.NoSideEffects,
},
/**
* @generated from rpc kurtosis_cloud.KurtosisCloudBackendServer.GetCloudInstanceConfig
*/
getCloudInstanceConfig: {
name: "GetCloudInstanceConfig",
I: GetCloudInstanceConfigArgs,
O: GetCloudInstanceConfigResponse,
kind: MethodKind.Unary,
idempotency: MethodIdempotency.NoSideEffects,
},
/**
* @generated from rpc kurtosis_cloud.KurtosisCloudBackendServer.GetOrCreateApiKey
*/
getOrCreateApiKey: {
name: "GetOrCreateApiKey",
I: GetOrCreateApiKeyRequest,
O: GetOrCreateApiKeyResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kurtosis_cloud.KurtosisCloudBackendServer.GetOrCreateInstance
*/
getOrCreateInstance: {
name: "GetOrCreateInstance",
I: GetOrCreateInstanceRequest,
O: GetOrCreateInstanceResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kurtosis_cloud.KurtosisCloudBackendServer.GetOrCreatePaymentConfig
*/
getOrCreatePaymentConfig: {
name: "GetOrCreatePaymentConfig",
I: GetOrCreatePaymentConfigArgs,
O: GetOrCreatePaymentConfigResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kurtosis_cloud.KurtosisCloudBackendServer.RefreshDefaultPaymentMethod
*/
refreshDefaultPaymentMethod: {
name: "RefreshDefaultPaymentMethod",
I: RefreshDefaultPaymentMethodArgs,
O: Empty,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kurtosis_cloud.KurtosisCloudBackendServer.CancelPaymentSubscription
*/
cancelPaymentSubscription: {
name: "CancelPaymentSubscription",
I: CancelPaymentSubscriptionArgs,
O: Empty,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kurtosis_cloud.KurtosisCloudBackendServer.UpdateAddress
*/
updateAddress: {
name: "UpdateAddress",
I: UpdateAddressArgs,
O: Empty,
kind: MethodKind.Unary,
},
}
} as const;

Loading

0 comments on commit 8b9b5ce

Please sign in to comment.