Skip to content

Commit 55a848c

Browse files
committed
use const
1 parent 545d948 commit 55a848c

File tree

5 files changed

+30
-26
lines changed

5 files changed

+30
-26
lines changed

internal/cli/deployments/options/deployment_opts.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,26 @@ import (
4545
const (
4646
spinnerSpeed = 100 * time.Millisecond
4747
// based on https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Clusters/operation/createCluster
48-
clusterNamePattern = "^[a-zA-Z0-9][a-zA-Z0-9-]*$"
49-
PausedState = "PAUSED"
50-
StoppedState = "STOPPED"
51-
IdleState = "IDLE"
52-
UpdatingState = "UPDATING"
53-
DeletingState = "DELETING"
54-
RestartingState = "RESTARTING"
55-
LocalCluster = "local"
56-
AtlasCluster = "atlas"
57-
CompassConnect = "compass"
58-
MongoshConnect = "mongosh"
59-
VsCodeConnect = "vscode"
60-
PromptTypeMessage = "What type of deployment would you like to work with?"
61-
MaxItemsPerPage = 500
62-
ContainerFilter = "mongodb-atlas-local=container"
63-
bytesInGb = 1073741824
64-
minimumRAM = 2 * bytesInGb
65-
minimumCores = 2
48+
clusterNamePattern = "^[a-zA-Z0-9][a-zA-Z0-9-]*$"
49+
PausedState = "PAUSED"
50+
StoppedState = "STOPPED"
51+
IdleState = "IDLE"
52+
UpdatingState = "UPDATING"
53+
DeletingState = "DELETING"
54+
RestartingState = "RESTARTING"
55+
LocalCluster = "local"
56+
AtlasCluster = "atlas"
57+
CompassConnect = "compass"
58+
MongoshConnect = "mongosh"
59+
VsCodeConnect = "vscode"
60+
PromptTypeMessage = "What type of deployment would you like to work with?"
61+
MaxItemsPerPage = 500
62+
ContainerFilter = "mongodb-atlas-local=container"
63+
ClusterWideScaling = "CLUSTER_WIDE_SCALING"
64+
IndependentShardScaling = "INDEPENDENT_SHARD_SCALING"
65+
bytesInGb = 1073741824
66+
minimumRAM = 2 * bytesInGb
67+
minimumCores = 2
6668
)
6769

6870
var (

internal/cli/deployments/pause.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ func (opts *PauseOpts) RunAtlas() error {
108108
defer opts.StopSpinner()
109109

110110
clusterAutoScalingConfig, err := opts.store.GetClusterAutoScalingConfig(opts.ConfigProjectID(), opts.DeploymentName)
111-
if err != nil || clusterAutoScalingConfig.GetAutoScalingMode() == "CLUSTER_WIDE_SCALING" {
111+
if err != nil || clusterAutoScalingConfig.GetAutoScalingMode() == options.ClusterWideScaling {
112112
r, err := opts.store.PauseCluster(opts.ConfigProjectID(), opts.DeploymentName)
113113
if err != nil {
114114
return err
115115
}
116116
return opts.Print(r)
117117
}
118118

119-
// If cluster is not CLUSTER_WIDE_SCALING, we use the latest API version
119+
// If cluster is not cluster wide scaling, we use the latest API version
120120
r, err := opts.store.PauseClusterLatest(opts.ConfigProjectID(), opts.DeploymentName)
121121
if err != nil {
122122
return err

internal/cli/deployments/pause_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"testing"
2323

2424
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli"
25+
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/deployments/options"
2526
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/deployments/test/fixture"
2627
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/pointer"
2728
"github.com/stretchr/testify/assert"
@@ -98,7 +99,7 @@ func TestPause_RunAtlas_clusterWideScaling(t *testing.T) {
9899
GetClusterAutoScalingConfig(projectID, deploymentName).
99100
Return(
100101
&atlasv2.ClusterDescriptionAutoScalingModeConfiguration{
101-
AutoScalingMode: pointer.Get("CLUSTER_WIDE_SCALING"),
102+
AutoScalingMode: pointer.Get(options.ClusterWideScaling),
102103
}, nil).
103104
Times(1)
104105

@@ -146,7 +147,7 @@ func TestPause_RunAtlas_independentShardScaling(t *testing.T) {
146147
GetClusterAutoScalingConfig(projectID, deploymentName).
147148
Return(
148149
&atlasv2.ClusterDescriptionAutoScalingModeConfiguration{
149-
AutoScalingMode: pointer.Get("INDEPENDENT_SHARD_SCALING"),
150+
AutoScalingMode: pointer.Get(string(options.IndependentShardScaling)),
150151
}, nil).
151152
Times(1)
152153

internal/cli/deployments/start.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ func (opts *StartOpts) RunAtlas() error {
8787
defer opts.StopSpinner()
8888

8989
clusterAutoScalingConfig, err := opts.store.GetClusterAutoScalingConfig(opts.ConfigProjectID(), opts.DeploymentName)
90-
if err != nil || clusterAutoScalingConfig.GetAutoScalingMode() == "CLUSTER_WIDE_SCALING" {
90+
if err != nil || clusterAutoScalingConfig.GetAutoScalingMode() == options.ClusterWideScaling {
9191
r, err := opts.store.StartCluster(opts.ConfigProjectID(), opts.DeploymentName)
9292
if err != nil {
9393
return err
9494
}
9595
return opts.Print(r)
9696
}
9797

98-
// If cluster is not CLUSTER_WIDE_SCALING, we use the latest API version
98+
// If cluster is not cluster wide scaling, we use the latest API version
9999
r, err := opts.store.StartClusterLatest(opts.ConfigProjectID(), opts.DeploymentName)
100100
if err != nil {
101101
return err

internal/cli/deployments/start_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"testing"
2323

2424
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli"
25+
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/deployments/options"
2526
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/deployments/test/fixture"
2627
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/pointer"
2728
"github.com/stretchr/testify/assert"
@@ -123,7 +124,7 @@ func TestStart_RunAtlas_clusterWideScaling(t *testing.T) {
123124
GetClusterAutoScalingConfig(projectID, deploymentName).
124125
Return(
125126
&atlasv2.ClusterDescriptionAutoScalingModeConfiguration{
126-
AutoScalingMode: pointer.Get("CLUSTER_WIDE_SCALING"),
127+
AutoScalingMode: pointer.Get(string(options.ClusterWideScaling)),
127128
}, nil).
128129
Times(1)
129130

@@ -169,7 +170,7 @@ func TestStart_RunAtlas_independentShardScaling(t *testing.T) {
169170
GetClusterAutoScalingConfig(projectID, deploymentName).
170171
Return(
171172
&atlasv2.ClusterDescriptionAutoScalingModeConfiguration{
172-
AutoScalingMode: pointer.Get("INDEPENDENT_SHARD_SCALING"),
173+
AutoScalingMode: pointer.Get(string(options.IndependentShardScaling)),
173174
}, nil).
174175
Times(1)
175176

0 commit comments

Comments
 (0)