Skip to content

Commit 9149875

Browse files
authored
Track deployment region (#1114)
* Add region to Deployment proto Also use Provider enum instead of string * Add region to Deployment proto Also use Provider enum instead of string
1 parent 2c7a857 commit 9149875

File tree

9 files changed

+810
-772
lines changed

9 files changed

+810
-772
lines changed

src/cmd/cli/command/commands_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ func (m *mockFabricService) CheckToS(context.Context, *connect.Request[emptypb.E
6464

6565
func (m *mockFabricService) WhoAmI(context.Context, *connect.Request[emptypb.Empty]) (*connect.Response[defangv1.WhoAmIResponse], error) {
6666
return connect.NewResponse(&defangv1.WhoAmIResponse{
67-
Tenant: "default",
68-
Account: "default",
69-
Region: "us-west-2",
70-
Tier: defangv1.SubscriptionTier_HOBBY,
67+
Tenant: "default",
68+
ProviderAccountId: "default",
69+
Region: "us-west-2",
70+
Tier: defangv1.SubscriptionTier_HOBBY,
7171
}), nil
7272
}
7373

src/pkg/cli/client/mock.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ func (m MockFabricClient) ListDeployments(ctx context.Context, req *defangv1.Lis
124124
{
125125
Id: "a1b2c3",
126126
Project: "test",
127-
Provider: "aws",
127+
Provider: defangv1.Provider_AWS,
128128
ProviderAccountId: "1234567890",
129+
ProviderString: "aws",
130+
Region: "us-test-2",
129131
Timestamp: timestamppb.Now(),
130132
},
131133
},

src/pkg/cli/composeDown.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ func ComposeDown(ctx context.Context, projectName string, c client.FabricClient,
3838
Action: defangv1.DeploymentAction_DEPLOYMENT_ACTION_DOWN,
3939
Id: etag,
4040
Project: projectName,
41-
Provider: string(accountInfo.Provider()),
41+
Provider: accountInfo.Provider().EnumValue(),
4242
ProviderAccountId: accountInfo.AccountID(),
43+
ProviderString: string(accountInfo.Provider()),
44+
Region: accountInfo.Region(),
4345
Timestamp: timestamppb.New(time.Now()),
4446
},
4547
})

src/pkg/cli/composeUp.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ func ComposeUp(ctx context.Context, project *compose.Project, fabric client.Fabr
121121
Action: defangv1.DeploymentAction_DEPLOYMENT_ACTION_UP,
122122
Id: resp.Etag,
123123
Project: project.Name,
124-
Provider: string(accountInfo.Provider()),
124+
Provider: accountInfo.Provider().EnumValue(),
125125
ProviderAccountId: accountInfo.AccountID(),
126+
ProviderString: string(accountInfo.Provider()),
127+
Region: accountInfo.Region(),
126128
Timestamp: timestamppb.New(timestamp),
127129
},
128130
})

src/pkg/cli/deploymentsList.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type PrintDeployment struct {
1313
Deployment string
1414
Provider string
1515
DeployedAt string
16+
Region string
1617
}
1718

1819
func DeploymentsList(ctx context.Context, projectName string, client client.GrpcClient) error {
@@ -34,10 +35,11 @@ func DeploymentsList(ctx context.Context, projectName string, client client.Grpc
3435
for i, d := range response.Deployments {
3536
deployments[i] = PrintDeployment{
3637
Deployment: d.Id,
37-
Provider: d.Provider,
38+
Provider: d.ProviderString, // TODO: use Provider
3839
DeployedAt: d.Timestamp.AsTime().Format(time.RFC3339),
40+
Region: d.Region,
3941
}
4042
}
4143

42-
return term.Table(deployments, []string{"Deployment", "Provider", "DeployedAt"})
44+
return term.Table(deployments, []string{"Deployment", "Provider", "DeployedAt"}) // TODO: add region
4345
}

src/pkg/cli/deploymentsList_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ func (g *mockListDeploymentsHandler) ListDeployments(ctx context.Context, req *c
2727
{
2828
Id: "a1b2c3",
2929
Project: "test",
30-
Provider: "playground",
30+
Provider: defangv1.Provider_DEFANG,
3131
ProviderAccountId: "1234567890",
32+
ProviderString: "playground",
33+
Region: "us-test-2",
3234
Timestamp: timestamppb.Now(),
3335
},
3436
}

src/pkg/cli/whoami_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ type grpcWhoamiMockHandler struct {
1919

2020
func (g *grpcWhoamiMockHandler) WhoAmI(context.Context, *connect.Request[emptypb.Empty]) (*connect.Response[defangv1.WhoAmIResponse], error) {
2121
return connect.NewResponse(&defangv1.WhoAmIResponse{
22-
Tenant: "tenant-1",
23-
Account: "playground",
24-
Region: "us-test-2",
25-
Tier: defangv1.SubscriptionTier_PRO,
22+
Tenant: "tenant-1",
23+
ProviderAccountId: "playground",
24+
Region: "us-test-2",
25+
Tier: defangv1.SubscriptionTier_PRO,
2626
}), nil
2727
}
2828

src/protos/io/defang/v1/fabric.pb.go

Lines changed: 781 additions & 755 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/protos/io/defang/v1/fabric.proto

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,14 @@ enum DeploymentAction {
367367
}
368368

369369
message Deployment {
370-
string id = 1;
370+
string id = 1; // aka etag
371371
string project = 2;
372-
string provider = 3;
372+
string provider_string = 3 [ deprecated = true ]; // was: provider
373373
string provider_account_id = 4;
374374
google.protobuf.Timestamp timestamp = 5;
375375
DeploymentAction action = 6;
376+
string region = 7;
377+
Provider provider = 8;
376378
}
377379

378380
message PutDeploymentRequest { Deployment deployment = 1; }
@@ -660,7 +662,7 @@ message SetOptionsRequest {
660662

661663
message WhoAmIResponse {
662664
string tenant = 1;
663-
string account = 2;
665+
string provider_account_id = 2;
664666
string region = 3;
665667
string user_id = 4;
666668
SubscriptionTier tier = 5;

0 commit comments

Comments
 (0)