Skip to content

Commit

Permalink
Use Pulumi project name in RPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
lionello committed Sep 10, 2024
1 parent 6ea5a5b commit b5a0985
Show file tree
Hide file tree
Showing 6 changed files with 2,397 additions and 230 deletions.
5 changes: 5 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ async function upsert(
force: boolean = false
): Promise<pb.ServiceInfo> {
const service = convertServiceInputs(inputs);
service.setProject(pulumi.getProject());
const client = await connect(inputs.fabricDNS);
try {
// Upload the build context, if provided
Expand All @@ -301,6 +302,7 @@ async function upsert(
return;
}
const sv = new pb.SecretValue();
sv.setProject(pulumi.getProject());
sv.setName(secret.source);
sv.setValue(secret.value);
return new Promise((resolve, reject) =>
Expand Down Expand Up @@ -346,6 +348,7 @@ function waitForSteadyState(
service: string
) {
const subscribeRequest = new pb.SubscribeRequest();
// subscribeRequest.setProject(pulumi.getProject());
subscribeRequest.setEtag(etag);
subscribeRequest.addServices(service);
const subscribeStream = client.subscribe(subscribeRequest);
Expand Down Expand Up @@ -609,6 +612,7 @@ const defangServiceProvider: pulumi.dynamic.ResourceProvider<
},
async delete(id: string, olds: DefangServiceOutputs): Promise<void> {
const serviceIds = new pb.DeleteRequest();
serviceIds.setProject(pulumi.getProject());
serviceIds.addNames(id);
const client = await connect(olds.fabricDNS);
try {
Expand Down Expand Up @@ -693,6 +697,7 @@ const defangServiceProvider: pulumi.dynamic.ResourceProvider<
olds?: DefangServiceOutputs
): Promise<pulumi.dynamic.ReadResult<DefangServiceOutputs>> {
const serviceId = new pb.ServiceID();
// serviceId.setProject(pulumi.getProject());
serviceId.setName(id);
assert(olds?.fabricDNS, "fabricDNS is required");
const client = await connect(olds.fabricDNS);
Expand Down
154 changes: 103 additions & 51 deletions io/defang/v1/fabric.proto
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// protos/v1/fabric.proto
// protos/io/defang/v1/fabric.proto
syntax = "proto3";

option go_package = "github.com/DefangLabs/defang/src/protos/io/defang/v1";
// option java_multiple_files = true;
// option java_package = "io.defang.fabric";
// option java_outer_classname = "FabricProto";

package io.defang.v1;

import "google/protobuf/empty.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";

service FabricController {
Expand All @@ -23,12 +21,16 @@ service FabricController {
rpc RevokeToken(google.protobuf.Empty) returns (google.protobuf.Empty);

rpc Tail(TailRequest) returns (stream TailResponse);
rpc Update(Service) returns (ServiceInfo); // deprecated; use Deploy
rpc Update(Service) returns (ServiceInfo) {
option deprecated = true;
}; // used by pulumi-defang provider; should use Deploy
rpc Deploy(DeployRequest) returns (DeployResponse);
rpc Get(ServiceID) returns (ServiceInfo) {
option idempotency_level = NO_SIDE_EFFECTS;
}; // should be GetService
rpc Delete(DeleteRequest) returns (DeleteResponse); // deprecated; use Deploy
rpc Delete(DeleteRequest) returns (DeleteResponse){
option deprecated = true;
}; // used by pulumi-defang provider; should use Deploy
rpc Publish(PublishRequest) returns (google.protobuf.Empty);
rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse);
// rpc Promote(google.protobuf.Empty) returns (google.protobuf.Empty);
Expand All @@ -42,19 +44,34 @@ service FabricController {
rpc GenerateStatus(GenerateStatusRequest) returns (GenerateFilesResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
}
rpc Debug(DebugRequest) returns (DebugResponse); // TEST
rpc Debug(DebugRequest) returns (DebugResponse);

rpc SignEULA(google.protobuf.Empty)
returns (google.protobuf.Empty); // AgreeToS
rpc CheckToS(google.protobuf.Empty) returns (google.protobuf.Empty) {
option idempotency_level = NO_SIDE_EFFECTS;
}

rpc PutSecret(SecretValue) returns (google.protobuf.Empty);
rpc DeleteSecrets(Secrets) returns (google.protobuf.Empty);
// deprecate - change to use *Config functions
rpc PutSecret(SecretValue) returns (google.protobuf.Empty) {option deprecated = true;};
rpc DeleteSecrets(Secrets) returns (google.protobuf.Empty) {option deprecated = true;};
rpc ListSecrets(google.protobuf.Empty) returns (Secrets) {
option idempotency_level = NO_SIDE_EFFECTS;
option deprecated = true;
} // no values

rpc GetConfigs(GetConfigsRequest) returns (GetConfigsResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
}; // no values
rpc PutConfig(PutConfigRequest) returns (google.protobuf.Empty) {
option idempotency_level = IDEMPOTENT;

};
rpc DeleteConfigs(DeleteConfigsRequest) returns (google.protobuf.Empty);
rpc ListConfigs(ListConfigsRequest) returns (ListConfigsResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
}; // no values

rpc CreateUploadURL(UploadURLRequest) returns (UploadURLResponse);

rpc DelegateSubdomainZone(DelegateSubdomainZoneRequest)
Expand Down Expand Up @@ -105,9 +122,18 @@ message TrackRequest {
string arch = 5;
}

enum DeploymentMode {
UNSPECIFIED_MODE= 0;
DEVELOPMENT = 1;
STAGING = 2;
PRODUCTION = 3;
}

message DeployRequest {
repeated Service services = 1;
string project = 2;
repeated Service services = 1 [deprecated = true]; // deprecated; use compose
string project = 2 [deprecated = true]; // deprecated; use compose.name
DeploymentMode mode = 3;
google.protobuf.Struct compose = 4;
}

message DeployResponse {
Expand Down Expand Up @@ -172,7 +198,7 @@ message ServiceInfo {
string etag = 4;
string status = 5;
repeated string nat_ips = 6; // comma-separated list of NAT IPs
repeated string lb_ips = 7; // comma-separated list of internal CIDR for the load-balancer
repeated string lb_ips = 7; // comma-separated list of internal CIDRs for the load-balancer
string private_fqdn = 8; // fully qualified domain name (host)
string public_fqdn = 9; // fully qualified domain name (ingress)
google.protobuf.Timestamp created_at = 10;
Expand All @@ -181,15 +207,11 @@ message ServiceInfo {
bool use_acme_cert = 13; // If we should setup the facilities to use ACME(let's encrypt) certs
reserved 14; // was: string lb_dns
ServiceState state = 15; // enumerated status of the service
string domainname = 16; // domain name for the service

// bool is_function = 5; // true if service is a function
}

// message Project {
// repeated Service services = 1;
// repeated SecretValue secrets = 2;
// }

message Secrets {
repeated string names = 1;
string project = 2; // defaults to tenant ID
Expand All @@ -201,6 +223,46 @@ message SecretValue {
string project = 3; // defaults to tenant ID
}

message Config {
string name = 1;
string value = 2;
string project = 3;
bool is_sensitive = 4;
}

message ConfigKey {
string name = 1;
string project = 2; // defaults to tenant ID
}

message GetConfigsRequest {
repeated ConfigKey configs = 1;
}

message GetConfigsResponse {
repeated Config configs = 1;
}


message DeleteConfigsRequest {
repeated ConfigKey configs = 1;
}

message PutConfigRequest {
string name = 1;
string value = 2;
string project = 3;
bool is_sensitive = 4;
}

message ListConfigsRequest {
string project = 1; // defaults to tenant ID
}

message ListConfigsResponse {
repeated ConfigKey configs = 1;
}

message TokenRequest {
string tenant = 1;
string auth_code = 2; // from GitHub authorization code flow
Expand Down Expand Up @@ -262,10 +324,12 @@ message ListServicesResponse {
message ProjectUpdate {
repeated ServiceInfo services = 1;
string alb_arn = 2;
string project = 3;
string project = 3; // should we use compose.name?
google.protobuf.Struct compose = 4;
}

enum Platform {
option deprecated = true;
LINUX_AMD64 = 0;
LINUX_ARM64 = 1;
LINUX_ANY = 2;
Expand All @@ -274,36 +338,28 @@ enum Platform {
message ServiceID { string name = 1; }

message Device {
option deprecated = true;
repeated string capabilities = 1; // "gpu", "tpu", etc.
string driver = 2; // "nvidia", "amd", etc.
uint32 count = 3; // number of devices to reserve

// repeated string device_ids = 4; // device IDs to reserve
// map<string, string> options = 5;
}

/* placement specifies constraints and preferences for platform to select a
* physical node to run service containers. */
// message Placement {
// /* constraints defines a REQUIRED property the platform's node MUST fulfill
// to run service container. */ map<string, string> constraints = 1;
// /* preferences defines a property the platform's node SHOULD fulfill to run
// service container. */ map<string, string> preferences = 2;
// }

message Resource {
option deprecated = true;
float memory = 1; // in MiB
float cpus = 2; // fractional vCPUs
repeated Device devices = 3; // devices & capabilities
}

message Resources {
option deprecated = true;
Resource reservations = 1; // requested resources

// Resource limits = 2; // hard limits
}

message Deploy {
option deprecated = true;
uint32 replicas = 1; // number of initial replicas
Resources resources = 2; // reservations and limits

Expand All @@ -318,6 +374,7 @@ message Deploy {
// }

enum Protocol {
option deprecated = true;
ANY = 0; // unspecified means any protocol
UDP = 1;
TCP = 2;
Expand All @@ -327,11 +384,13 @@ enum Protocol {
}

enum Mode {
option deprecated = true;
HOST = 0; // no load-balancer; suitable for internal services and functions
INGRESS = 1; // with load-balancer; suitable for public services
}

message Port {
option deprecated = true;
uint32 target = 1;
Protocol protocol = 2;
Mode mode = 3; // load-balanced (ingress) or not (host)
Expand All @@ -341,54 +400,41 @@ message Port {
}

message Secret {
option deprecated = true;
string source = 1; // name of the secret
// string target = 2;
}

message Build {
option deprecated = true;
string context = 1; // path or URL to the build context
string dockerfile = 2; // path to the Dockerfile
map<string, string> args = 3; // build-time variables
float shm_size = 4; // in MiB
string target = 5;

// string dockerfile_inline = 4; // inline Dockerfile
// repeated string ssh = 4;
// repeated string cache_from = 4;
// repeated string cache_to = 4;
// repeated string extra_hosts = 4;
// string isolation = 4;
// bool privileged = 4;
// map<string, string> labels = 4;
// bool no_cache = 4;
// bool pull = 4;
// repeated Secret secrets = 4;
// repeated string tags = 4;
// repeated Platform platforms = 4;
}

message HealthCheck {
option deprecated = true;
repeated string test = 1;
uint32 interval = 2; // in seconds
uint32 timeout = 3; // in seconds; must be less than interval
uint32 retries = 4;

// uint32 start_period = 5;
// uint32 start_interval = 5; not supported by ECS
// bool disable = 6;
}

enum Network {
option deprecated = true;
UNSPECIFIED = 0; // was: internal=false
PRIVATE = 1; // was: internal=true
PUBLIC = 2;
}

message Service {
option deprecated = true;
string name = 1;
string image = 2;
Platform platform = 3;
bool internal = 4; // deprecated: use networks
bool internal = 4 [deprecated = true]; // deprecated: use networks
Deploy deploy = 5;
repeated Port ports = 6;
map<string, string> environment = 7;
Expand All @@ -403,15 +449,21 @@ message Service {
Network networks = 16; // currently only 1 network is supported
Redis redis = 18; // x-defang-redis: use a managed redis
Postgres postgres = 19; // x-defang-postgres: use a managed
string project = 20; // defaults to tenant ID
}

message StaticFiles {
option deprecated = true;
string folder = 1;
repeated string redirects = 2;
}

message Redis {}
message Postgres {}
message Redis {
option deprecated = true;
}
message Postgres {
option deprecated = true;
}

message Event {
string specversion = 1; // required (but we don't care)
Expand Down
Loading

0 comments on commit b5a0985

Please sign in to comment.