Skip to content

Commit 7ed80ee

Browse files
committed
Update proto for aliases
1 parent 2742e0b commit 7ed80ee

File tree

7 files changed

+1588
-461
lines changed

7 files changed

+1588
-461
lines changed

index.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ function convertServiceInputs(inputs: DefangServiceInputs): pb.Service {
132132
resources.setReservations(reservations);
133133
deploy.setResources(resources);
134134
}
135-
switch (inputs.networks?.[0]) {
136-
case "public":
137-
service.setNetworks(pb.Network.PUBLIC);
138-
break;
139-
case "private":
140-
service.setNetworks(pb.Network.PRIVATE);
141-
break;
135+
const publicNetwork = inputs.networks?.public;
136+
const privateNetwork = inputs.networks?.private;
137+
if (publicNetwork !== undefined) {
138+
service.setNetworks(pb.Network.PUBLIC);
139+
service.setAliasesList(publicNetwork?.aliases ?? []);
140+
} else if (privateNetwork !== undefined) {
141+
service.setNetworks(pb.Network.PRIVATE);
142142
}
143143
service.setDeploy(deploy);
144144
service.setPlatform(
@@ -430,7 +430,7 @@ interface DefangServiceInputs {
430430
image?: string;
431431
init?: boolean;
432432
name: string;
433-
networks?: [Network];
433+
networks?: Record<NetworkName, Network>;
434434
platform?: Platform;
435435
ports?: Port[];
436436
project: string;
@@ -571,6 +571,12 @@ const defangServiceProvider: pulumi.dynamic.ResourceProvider<
571571
}
572572
}
573573
}
574+
if (Object.keys(news.networks || {}).length > 1) {
575+
failures.push({
576+
property: "networks",
577+
reason: "only one network can be specified",
578+
});
579+
}
574580
for (const secret of news.secrets || []) {
575581
// TODO: validate source name
576582
if (!secret.source) {
@@ -711,7 +717,7 @@ const defangServiceProvider: pulumi.dynamic.ResourceProvider<
711717
id: string,
712718
olds?: DefangServiceOutputs
713719
): Promise<pulumi.dynamic.ReadResult<DefangServiceOutputs>> {
714-
const serviceId = new pb.ServiceID();
720+
const serviceId = new pb.GetRequest();
715721
// serviceId.setProject(project);
716722
serviceId.setName(id);
717723
assert(olds?.fabricDNS, "fabricDNS is required");
@@ -745,7 +751,8 @@ const defangServiceProvider: pulumi.dynamic.ResourceProvider<
745751
export type Platform = "linux/arm64" | "linux/amd64" | "linux";
746752
export type Protocol = "tcp" | "udp" | "http" | "http2" | "grpc";
747753
export type DeviceCapability = "gpu";
748-
export type Network = "private" | "public";
754+
export type NetworkName = "private" | "public";
755+
export type Network = { aliases?: string[] } | null; // TODO: pulumi.Input<string>[]
749756

750757
export interface Port {
751758
target: number;
@@ -813,7 +820,7 @@ export interface DefangServiceArgs {
813820
/** the platform to deploy to; defaults to "linux/amd64" */
814821
platform?: pulumi.Input<Platform>;
815822
/** which network the service is in, ie. whether the service requires a public IP or not; defaults to "private" (was: internal=true) */
816-
networks?: [Network];
823+
networks?: Record<NetworkName, Network>;
817824
/** the optional deployment configuration */
818825
deploy?: pulumi.Input<Deploy>;
819826
/** the ports to expose */

io/defang/v1/fabric.proto

Lines changed: 83 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ service FabricController {
2424
option deprecated = true;
2525
}; // used by pulumi-defang provider; should use Deploy
2626
rpc Deploy(DeployRequest) returns (DeployResponse);
27-
rpc Get(ServiceID) returns (ServiceInfo) {
27+
rpc Get(GetRequest) returns (ServiceInfo) {
2828
option idempotency_level = NO_SIDE_EFFECTS;
2929
}; // should be GetService
3030
rpc Delete(DeleteRequest) returns (DeleteResponse) {
@@ -38,7 +38,7 @@ service FabricController {
3838
}
3939
rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse);
4040
// rpc Promote(google.protobuf.Empty) returns (google.protobuf.Empty);
41-
rpc GetServices(google.protobuf.Empty) returns (ListServicesResponse) {
41+
rpc GetServices(GetServicesRequest) returns (ListServicesResponse) {
4242
option idempotency_level = NO_SIDE_EFFECTS;
4343
}; // should be ListServices
4444

@@ -63,7 +63,7 @@ service FabricController {
6363
rpc DeleteSecrets(Secrets) returns (google.protobuf.Empty) {
6464
option deprecated = true;
6565
};
66-
rpc ListSecrets(google.protobuf.Empty) returns (Secrets) {
66+
rpc ListSecrets(ListConfigsRequest) returns (Secrets) {
6767
option idempotency_level = NO_SIDE_EFFECTS;
6868
option deprecated = true;
6969
} // no values
@@ -104,6 +104,33 @@ service FabricController {
104104
rpc VerifyDNSSetup(VerifyDNSSetupRequest) returns (google.protobuf.Empty) {
105105
option idempotency_level = NO_SIDE_EFFECTS;
106106
}
107+
108+
rpc GetSelectedProvider(GetSelectedProviderRequest)
109+
returns (GetSelectedProviderResponse) {
110+
option idempotency_level = NO_SIDE_EFFECTS;
111+
}
112+
113+
rpc SetSelectedProvider(SetSelectedProviderRequest)
114+
returns (google.protobuf.Empty) {
115+
option idempotency_level = IDEMPOTENT;
116+
}
117+
}
118+
119+
enum Provider {
120+
PROVIDER_UNSPECIFIED = 0;
121+
DEFANG = 1;
122+
AWS = 2;
123+
DIGITALOCEAN = 3;
124+
GCP = 4;
125+
}
126+
127+
message GetSelectedProviderRequest { string project = 1; }
128+
129+
message GetSelectedProviderResponse { Provider provider = 1; }
130+
131+
message SetSelectedProviderRequest {
132+
string project = 1;
133+
Provider provider = 2;
107134
}
108135

109136
message VerifyDNSSetupRequest {
@@ -164,6 +191,8 @@ message DeployRequest {
164191
string project = 2 [ deprecated = true ]; // deprecated; use compose.name
165192
DeploymentMode mode = 3;
166193
bytes compose = 4; // yaml (or json)
194+
string delegate_domain = 5;
195+
string delegation_set_id = 6;
167196
}
168197

169198
message DeployResponse {
@@ -174,6 +203,7 @@ message DeployResponse {
174203
message DeleteRequest {
175204
repeated string names = 1;
176205
string project = 2; // defaults to tenant ID
206+
string delegate_domain = 3;
177207
}
178208

179209
message DeleteResponse { string etag = 1; }
@@ -195,7 +225,10 @@ message StartGenerateResponse { string uuid = 1; }
195225

196226
message GenerateStatusRequest { string uuid = 1; }
197227

198-
message UploadURLRequest { string digest = 1; }
228+
message UploadURLRequest {
229+
string digest = 1;
230+
string project = 2;
231+
}
199232

200233
message UploadURLResponse { string url = 1; }
201234

@@ -299,14 +332,12 @@ message TokenRequest {
299332
string assertion = 4; // jwt-bearer
300333
uint32 expires_in = 5; // seconds
301334
string anon_id = 6;
302-
303-
// string refresh_token = 6;
335+
string refresh_token = 7;
304336
}
305337

306338
message TokenResponse {
307-
string access_token = 1; // our JWT
308-
309-
// string refresh_token = 2;
339+
string access_token = 1; // short-lived token
340+
string refresh_token = 2;
310341
// string token_type = 3; // "Bearer"
311342
// uint32 expires_in = 4; // 3600
312343
// string id_token = 5; // "eyJhbGciOiJSUzI…"
@@ -325,6 +356,9 @@ message TailRequest {
325356
repeated string services = 1;
326357
google.protobuf.Timestamp since = 2;
327358
string etag = 3;
359+
string project = 4;
360+
uint32 log_type = 5;
361+
string pattern = 6;
328362
}
329363

330364
message LogEntry {
@@ -334,7 +368,6 @@ message LogEntry {
334368
string service = 4;
335369
string etag = 5;
336370
string host = 6;
337-
string job = 7;
338371
}
339372

340373
message TailResponse {
@@ -353,59 +386,57 @@ message ListServicesResponse {
353386
message ProjectUpdate {
354387
repeated ServiceInfo services = 1;
355388
string alb_arn = 2;
356-
string project = 3 [deprecated = true]; // deprecated; use compose.name
389+
string project = 3 [ deprecated = true ]; // deprecated; use compose.name
357390
bytes compose = 4;
358391
string cd_version = 5;
359392
}
360393

361394
enum Platform {
362-
option deprecated = true;
395+
option deprecated = true; // still used by pulumi-defang provider
363396
LINUX_AMD64 = 0;
364397
LINUX_ARM64 = 1;
365398
LINUX_ANY = 2;
366399
}
367400

368-
message ServiceID { string name = 1; }
401+
message GetRequest { // was GetRequest
402+
string name = 1;
403+
string project = 2;
404+
}
369405

370406
message Device {
371-
option deprecated = true;
407+
option deprecated = true; // still used by pulumi-defang provider
372408
repeated string capabilities = 1; // "gpu", "tpu", etc.
373409
string driver = 2; // "nvidia", "amd", etc.
374410
uint32 count = 3; // number of devices to reserve
375411
}
376412

377413
message Resource {
378-
option deprecated = true;
414+
option deprecated = true; // still used by pulumi-defang provider
379415
float memory = 1; // in MiB
380416
float cpus = 2; // fractional vCPUs
381417
repeated Device devices = 3; // devices & capabilities
382418
}
383419

384420
message Resources {
385-
option deprecated = true;
421+
option deprecated = true; // still used by pulumi-defang provider
386422
Resource reservations = 1; // requested resources
387423

388424
// Resource limits = 2; // hard limits
389425
}
390426

391427
message Deploy {
392-
option deprecated = true;
393-
uint32 replicas = 1; // number of initial replicas
394-
Resources resources = 2; // reservations and limits
428+
option deprecated = true; // still used by pulumi-defang provider
429+
uint32 replicas = 1; // number of initial replicas
430+
Resources resources = 2; // reservations and limits
395431

396432
// Placement placement = 3;
397433
// EndpointMode endpoint_mode
398434
// Mode mode
399435
}
400436

401-
// message Range {
402-
// uint32 from = 1;
403-
// uint32 to = 2;
404-
// }
405-
406437
enum Protocol {
407-
option deprecated = true;
408-
ANY = 0; // unspecified means any protocol
438+
option deprecated = true; // still used by pulumi-defang provider
439+
ANY = 0; // unspecified means any protocol
409440
UDP = 1;
410441
TCP = 2;
411442
HTTP = 3;
@@ -414,13 +445,13 @@ enum Protocol {
414445
}
415446

416447
enum Mode {
417-
option deprecated = true;
448+
option deprecated = true; // still used by pulumi-defang provider
418449
HOST = 0; // no load-balancer; suitable for internal services and functions
419450
INGRESS = 1; // with load-balancer; suitable for public services
420451
}
421452

422453
message Port {
423-
option deprecated = true;
454+
option deprecated = true; // still used by pulumi-defang provider
424455
uint32 target = 1;
425456
Protocol protocol = 2;
426457
Mode mode = 3; // load-balanced (ingress) or not (host)
@@ -430,13 +461,13 @@ message Port {
430461
}
431462

432463
message Secret {
433-
option deprecated = true;
434-
string source = 1; // name of the secret
464+
option deprecated = true; // still used by pulumi-defang provider
465+
string source = 1; // name of the secret
435466
// string target = 2;
436467
}
437468

438469
message Build {
439-
option deprecated = true;
470+
option deprecated = true; // still used by pulumi-defang provider
440471
string context = 1; // path or URL to the build context
441472
string dockerfile = 2; // path to the Dockerfile
442473
map<string, string> args = 3; // build-time variables
@@ -445,22 +476,22 @@ message Build {
445476
}
446477

447478
message HealthCheck {
448-
option deprecated = true;
479+
option deprecated = true; // still used by pulumi-defang provider
449480
repeated string test = 1;
450481
uint32 interval = 2; // in seconds
451482
uint32 timeout = 3; // in seconds; must be less than interval
452483
uint32 retries = 4;
453484
}
454485

455486
enum Network {
456-
option deprecated = true;
457-
UNSPECIFIED = 0; // was: internal=false
458-
PRIVATE = 1; // was: internal=true
487+
option deprecated = true; // still used by pulumi-defang provider
488+
UNSPECIFIED = 0; // was: internal=false
489+
PRIVATE = 1; // was: internal=true
459490
PUBLIC = 2;
460491
}
461492

462493
message Service {
463-
option deprecated = true;
494+
option deprecated = true; // still used by pulumi-defang provider
464495
string name = 1;
465496
string image = 2;
466497
Platform platform = 3;
@@ -478,19 +509,18 @@ message Service {
478509
// create dns records
479510
StaticFiles static_files = 15; // x-defang-static-files: use a managed CDN
480511
Network networks = 16; // currently only 1 network is supported
481-
Redis redis = 18; // x-defang-redis: use a managed redis
482-
Postgres postgres = 19; // x-defang-postgres: use a managed
483-
string project = 20; // defaults to tenant ID
512+
repeated string aliases = 17;
513+
Redis redis = 18; // x-defang-redis: use a managed redis
514+
string project = 20; // defaults to tenant ID
484515
}
485516

486517
message StaticFiles {
487-
option deprecated = true;
518+
option deprecated = true; // still used by pulumi-defang provider
488519
string folder = 1;
489520
repeated string redirects = 2;
490521
}
491522

492523
message Redis { option deprecated = true; }
493-
message Postgres { option deprecated = true; }
494524

495525
// TODO: internal message; move to a separate proto file; was Event
496526
message DeployEvent {
@@ -523,6 +553,7 @@ message PublishRequest { Event event = 1; }
523553
message SubscribeRequest {
524554
repeated string services = 1;
525555
string etag = 2;
556+
string project = 3;
526557
}
527558

528559
message SubscribeResponse {
@@ -532,15 +563,26 @@ message SubscribeResponse {
532563
ServiceState state = 4;
533564
}
534565

566+
message GetServicesRequest { string project = 1; }
567+
535568
message DelegateSubdomainZoneRequest {
536569
repeated string name_server_records = 1;
537570
}
538571

539572
message DelegateSubdomainZoneResponse { string zone = 1; }
540573

574+
enum SubscriptionTier {
575+
SUBSCRIPTION_TIER_UNSPECIFIED = 0;
576+
PERSONAL = 1;
577+
BASIC = 2;
578+
PRO = 3;
579+
TEAM = 4;
580+
}
581+
541582
message WhoAmIResponse {
542583
string tenant = 1;
543584
string account = 2;
544585
string region = 3;
545586
string user_id = 4;
587+
SubscriptionTier tier = 5;
546588
}

0 commit comments

Comments
 (0)