@@ -12,15 +12,14 @@ import (
12
12
"time"
13
13
14
14
"github.com/DefangLabs/defang/src/pkg/cli/client"
15
- cliClient "github.com/DefangLabs/defang/src/pkg/cli/client"
16
15
"github.com/DefangLabs/defang/src/pkg/cli/compose"
17
16
"github.com/DefangLabs/defang/src/pkg/logs"
18
17
"github.com/DefangLabs/defang/src/pkg/money"
19
18
"github.com/DefangLabs/defang/src/pkg/term"
20
19
defangv1 "github.com/DefangLabs/defang/src/protos/io/defang/v1"
21
20
)
22
21
23
- func RunEstimate (ctx context.Context , project * compose.Project , client cliClient .FabricClient , previewProvider cliClient .Provider , estimateProviderID cliClient .ProviderID , region string , mode defangv1.DeploymentMode ) (* defangv1.EstimateResponse , error ) {
22
+ func RunEstimate (ctx context.Context , project * compose.Project , client client .FabricClient , previewProvider client .Provider , estimateProviderID client .ProviderID , region string , mode defangv1.DeploymentMode ) (* defangv1.EstimateResponse , error ) {
24
23
term .Debugf ("Running estimate for project %s in region %s with mode %s" , project .Name , region , mode )
25
24
preview , err := GeneratePreview (ctx , project , client , previewProvider , estimateProviderID , mode , region )
26
25
if err != nil {
@@ -40,7 +39,7 @@ func RunEstimate(ctx context.Context, project *compose.Project, client cliClient
40
39
return estimate , nil
41
40
}
42
41
43
- func GeneratePreview (ctx context.Context , project * compose.Project , client client.FabricClient , previewProvider cliClient .Provider , estimateProviderID cliClient .ProviderID , mode defangv1.DeploymentMode , region string ) (string , error ) {
42
+ func GeneratePreview (ctx context.Context , project * compose.Project , client client.FabricClient , previewProvider client .Provider , estimateProviderID client .ProviderID , mode defangv1.DeploymentMode , region string ) (string , error ) {
44
43
os .Setenv ("DEFANG_JSON" , "1" ) // HACK: always show JSON output for estimate
45
44
since := time .Now ()
46
45
@@ -111,16 +110,17 @@ func PrintEstimate(mode defangv1.DeploymentMode, estimate *defangv1.EstimateResp
111
110
subtotal := (* money .Money )(estimate .Subtotal )
112
111
tableItems := prepareEstimateLineItemTableItems (estimate .LineItems )
113
112
term .Println ("" )
114
- if mode == defangv1 .DeploymentMode_DEVELOPMENT || mode == defangv1 .DeploymentMode_MODE_UNSPECIFIED {
113
+ switch mode {
114
+ case defangv1 .DeploymentMode_DEVELOPMENT , defangv1 .DeploymentMode_MODE_UNSPECIFIED :
115
115
term .Println ("Estimate for Deployment Mode: AFFORDABLE" )
116
116
term .Println (affordableModeEstimateSummary )
117
- } else if mode == defangv1 .DeploymentMode_STAGING {
117
+ case defangv1 .DeploymentMode_STAGING :
118
118
term .Println ("Estimate for Deployment Mode: BALANCED" )
119
119
term .Println (balancedModeEstimateSummary )
120
- } else if mode == defangv1 .DeploymentMode_PRODUCTION {
120
+ case defangv1 .DeploymentMode_PRODUCTION :
121
121
term .Println ("Estimate for Deployment Mode: HIGH_AVAILABILITY" )
122
122
term .Println (highAvailabilityModeEstimateSummary )
123
- } else {
123
+ default :
124
124
term .Printf ("Estimate for %s Mode\n " , mode .String ())
125
125
}
126
126
0 commit comments