Skip to content

Commit 97542d5

Browse files
authored
Merge branch 'main' into tenants
2 parents d1ec924 + f51ef72 commit 97542d5

File tree

7 files changed

+737
-716
lines changed

7 files changed

+737
-716
lines changed

src/pkg/cli/client/byoc/aws/byoc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ func (b *ByocAws) deploy(ctx context.Context, req *defangv1.DeployRequest, cmd s
230230
data, err := proto.Marshal(&defangv1.ProjectUpdate{
231231
CdVersion: b.CDImage,
232232
Compose: req.Compose,
233+
Mode: req.Mode,
233234
Services: serviceInfos,
234235
})
235236
if err != nil {

src/pkg/cli/client/byoc/do/byoc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ func (b *ByocDo) deploy(ctx context.Context, req *defangv1.DeployRequest, cmd st
154154
data, err := proto.Marshal(&defangv1.ProjectUpdate{
155155
CdVersion: b.CDImage,
156156
Compose: req.Compose,
157+
Mode: req.Mode,
157158
Services: serviceInfos,
158159
})
159-
160160
if err != nil {
161161
return nil, err
162162
}

src/pkg/cli/client/byoc/gcp/byoc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ func (b *ByocGcp) deploy(ctx context.Context, req *defangv1.DeployRequest, comma
460460
data, err := proto.Marshal(&defangv1.ProjectUpdate{
461461
CdVersion: b.CDImage,
462462
Compose: req.Compose,
463+
Mode: req.Mode,
463464
Services: serviceInfos,
464465
})
465466
if err != nil {

src/pkg/cli/composeDown.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"google.golang.org/protobuf/types/known/timestamppb"
1616
)
1717

18-
func ComposeDown(ctx context.Context, projectName string, c client.FabricClient, provider client.Provider, names ...string) (types.ETag, error) {
18+
func ComposeDown(ctx context.Context, projectName string, fabric client.FabricClient, provider client.Provider, names ...string) (types.ETag, error) {
1919
term.Debugf("Destroying project %q %q", projectName, names)
2020

2121
if dryrun.DoDryRun {
@@ -34,7 +34,7 @@ func ComposeDown(ctx context.Context, projectName string, c client.FabricClient,
3434
return "", err
3535
}
3636

37-
err = c.PutDeployment(ctx, &defangv1.PutDeploymentRequest{
37+
err = fabric.PutDeployment(ctx, &defangv1.PutDeploymentRequest{
3838
Deployment: &defangv1.Deployment{
3939
Action: defangv1.DeploymentAction_DEPLOYMENT_ACTION_DOWN,
4040
Id: etag,
@@ -54,7 +54,7 @@ func ComposeDown(ctx context.Context, projectName string, c client.FabricClient,
5454
return etag, nil
5555
}
5656

57-
delegateDomain, err := c.GetDelegateSubdomainZone(ctx, &defangv1.GetDelegateSubdomainZoneRequest{}) // TODO: pass projectName
57+
delegateDomain, err := fabric.GetDelegateSubdomainZone(ctx, &defangv1.GetDelegateSubdomainZoneRequest{}) // TODO: pass projectName
5858
if err != nil {
5959
term.Debug("GetDelegateSubdomainZone failed:", err)
6060
return "", errors.New("failed to get delegate domain")

src/pkg/cli/composeUp.go

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"time"
87

98
"github.com/DefangLabs/defang/src/pkg/cli/client"
109
"github.com/DefangLabs/defang/src/pkg/cli/compose"
@@ -94,12 +93,19 @@ func ComposeUp(ctx context.Context, project *compose.Project, fabric client.Fabr
9493
deployRequest.DelegationSetId = delegation.DelegationSetId
9594
}
9695

96+
accountInfo, err := p.AccountInfo(ctx)
97+
if err != nil {
98+
return nil, project, err
99+
}
100+
101+
var action defangv1.DeploymentAction
97102
var resp *defangv1.DeployResponse
98103
if upload == compose.UploadModePreview || upload == compose.UploadModeEstimate {
99104
resp, err = p.Preview(ctx, deployRequest)
100105
if err != nil {
101106
return nil, project, err
102107
}
108+
action = defangv1.DeploymentAction_DEPLOYMENT_ACTION_PREVIEW
103109
} else {
104110
if delegation != nil && len(delegation.NameServers) > 0 {
105111
req := &defangv1.DelegateSubdomainZoneRequest{NameServerRecords: delegation.NameServers, Project: project.Name}
@@ -109,33 +115,29 @@ func ComposeUp(ctx context.Context, project *compose.Project, fabric client.Fabr
109115
}
110116
}
111117

112-
accountInfo, err := p.AccountInfo(ctx)
113-
if err != nil {
114-
return nil, project, err
115-
}
116-
117-
timestamp := time.Now()
118118
resp, err = p.Deploy(ctx, deployRequest)
119119
if err != nil {
120120
return nil, project, err
121121
}
122+
action = defangv1.DeploymentAction_DEPLOYMENT_ACTION_UP
123+
}
122124

123-
err = fabric.PutDeployment(ctx, &defangv1.PutDeploymentRequest{
124-
Deployment: &defangv1.Deployment{
125-
Action: defangv1.DeploymentAction_DEPLOYMENT_ACTION_UP,
126-
Id: resp.Etag,
127-
Project: project.Name,
128-
Provider: accountInfo.Provider.Value(),
129-
ProviderAccountId: accountInfo.AccountID,
130-
ProviderString: string(accountInfo.Provider),
131-
Region: accountInfo.Region,
132-
Timestamp: timestamppb.New(timestamp),
133-
},
134-
})
135-
if err != nil {
136-
term.Debugf("PutDeployment failed: %v", err)
137-
term.Warn("Unable to update deployment history, but deployment will proceed anyway.")
138-
}
125+
err = fabric.PutDeployment(ctx, &defangv1.PutDeploymentRequest{
126+
Deployment: &defangv1.Deployment{
127+
Action: action,
128+
Id: resp.Etag,
129+
Project: project.Name,
130+
Provider: accountInfo.Provider.Value(),
131+
ProviderAccountId: accountInfo.AccountID,
132+
ProviderString: string(accountInfo.Provider),
133+
Region: accountInfo.Region,
134+
ServiceCount: int32(len(fixedProject.Services)), // #nosec G115 - service count will not overflow int32
135+
Timestamp: timestamppb.Now(),
136+
},
137+
})
138+
if err != nil {
139+
term.Debugf("PutDeployment failed: %v", err)
140+
term.Warn("Unable to update deployment history, but deployment will proceed anyway.")
139141
}
140142

141143
if term.DoDebug() {

0 commit comments

Comments
 (0)