4
4
"context"
5
5
"errors"
6
6
"fmt"
7
- "time"
8
7
9
8
"github.com/DefangLabs/defang/src/pkg/cli/client"
10
9
"github.com/DefangLabs/defang/src/pkg/cli/compose"
@@ -94,12 +93,19 @@ func ComposeUp(ctx context.Context, project *compose.Project, fabric client.Fabr
94
93
deployRequest .DelegationSetId = delegation .DelegationSetId
95
94
}
96
95
96
+ accountInfo , err := p .AccountInfo (ctx )
97
+ if err != nil {
98
+ return nil , project , err
99
+ }
100
+
101
+ var action defangv1.DeploymentAction
97
102
var resp * defangv1.DeployResponse
98
103
if upload == compose .UploadModePreview || upload == compose .UploadModeEstimate {
99
104
resp , err = p .Preview (ctx , deployRequest )
100
105
if err != nil {
101
106
return nil , project , err
102
107
}
108
+ action = defangv1 .DeploymentAction_DEPLOYMENT_ACTION_PREVIEW
103
109
} else {
104
110
if delegation != nil && len (delegation .NameServers ) > 0 {
105
111
req := & defangv1.DelegateSubdomainZoneRequest {NameServerRecords : delegation .NameServers , Project : project .Name }
@@ -109,33 +115,29 @@ func ComposeUp(ctx context.Context, project *compose.Project, fabric client.Fabr
109
115
}
110
116
}
111
117
112
- accountInfo , err := p .AccountInfo (ctx )
113
- if err != nil {
114
- return nil , project , err
115
- }
116
-
117
- timestamp := time .Now ()
118
118
resp , err = p .Deploy (ctx , deployRequest )
119
119
if err != nil {
120
120
return nil , project , err
121
121
}
122
+ action = defangv1 .DeploymentAction_DEPLOYMENT_ACTION_UP
123
+ }
122
124
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." )
139
141
}
140
142
141
143
if term .DoDebug () {
0 commit comments