Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build/ci/evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,13 @@ tasks:
MONGODB_ATLAS_OPS_MANAGER_URL: ${mcli_ops_manager_url}
MONGODB_ATLAS_SERVICE: cloud
E2E_TAGS: atlas,clusters,flex
- name: atlas_clusters_iss_e2e
tags: ["e2e","clusters","atlas"]
must_have_test_results: true
depends_on:
- name: atlas_clusters_flags_e2e
variant: "e2e_atlas_clusters"
patch_optional: true
- name: atlas_plugin_install
tags: ["e2e","atlas","plugin","install"]
must_have_test_results: true
Expand Down
16 changes: 15 additions & 1 deletion docs/command/atlas-clusters-create.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ Options
- Type
- Required
- Description
* - --autoScalingMode
- string
- false
- The mode in which the cluster scales. Valid values are clusterWideScaling or independentShardScaling.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The mode in which the cluster scales. Valid values are clusterWideScaling or independentShardScaling.
- Mode in which the cluster scales. Valid values are clusterWideScaling or independentShardScaling.


Mutually exclusive with --file. This value defaults to "clusterWideScaling".
* - --backup
-
- false
Expand All @@ -88,7 +94,7 @@ Options
- false
- Path to an optional JSON configuration file that defines cluster settings. Note: Unsupported fields in the JSON file are ignored. To learn more about cluster configuration files for the Atlas CLI, see https://dochub.mongodb.org/core/cluster-config-file-atlascli.

Mutually exclusive with --tier, --provider, --members, --region, --diskSizeGB, --mdbVersion, --biConnector, --type, --shards, --tag.
Mutually exclusive with --tier, --provider, --members, --region, --diskSizeGB, --mdbVersion, --biConnector, --type, --shards, --tag, --autoScalingMode.
* - -h, --help
-
- false
Expand Down Expand Up @@ -234,3 +240,11 @@ Examples

# Deploy a cluster or a multi-cloud cluster from a JSON configuration file named myfile.json for the project with the ID 5e2211c17a3e5a48f5497de3:
atlas cluster create --projectId <projectId> --file myfile.json


.. code-block::
:copyable: false

# Deploy a three-member sharded cluster with independent shard scaling mode named myRS in GCP for the project with the ID 5e2211c17a3e5a48f5497de3:
atlas cluster create myRS --projectId 5e2211c17a3e5a48f5497de3 --provider GCP --region EASTERN_US --members 3 --tier M10 --mdbVersion 5.0 --diskSizeGB 10 --autoScalingMode independentShardScaling

4 changes: 4 additions & 0 deletions docs/command/atlas-clusters-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Options
- Type
- Required
- Description
* - --autoScalingMode
- string
- false
- The mode in which the cluster scales. Valid values are clusterWideScaling or independentShardScaling.
* - -h, --help
-
- false
Expand Down
4 changes: 4 additions & 0 deletions docs/command/atlas-deployments-setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ Options
- IP address to grant access to the deployment.

Mutually exclusive with --currentIp.
* - --autoScalingMode
- string
- false
- The mode in which the cluster scales. Valid values are clusterWideScaling or independentShardScaling. This value defaults to "clusterWideScaling".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The mode in which the cluster scales. Valid values are clusterWideScaling or independentShardScaling. This value defaults to "clusterWideScaling".
- Mode in which the cluster scales. Valid values are clusterWideScaling or independentShardScaling. This value defaults to "clusterWideScaling".

* - --bindIpAll
-
- false
Expand Down
4 changes: 4 additions & 0 deletions docs/command/atlas-setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Options
- IP address to grant access to the deployment.

Mutually exclusive with --currentIp.
* - --autoScalingMode
- string
- false
- The mode in which the cluster scales. Valid values are clusterWideScaling or independentShardScaling. This value defaults to "clusterWideScaling".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The mode in which the cluster scales. Valid values are clusterWideScaling or independentShardScaling. This value defaults to "clusterWideScaling".
- Mode in which the cluster scales. Valid values are clusterWideScaling or independentShardScaling. This value defaults to "clusterWideScaling".

* - --clusterName
- string
- false
Expand Down
32 changes: 32 additions & 0 deletions internal/cli/clusters/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ var errFailedToLoadClusterFileMessage = errors.New("failed to parse JSON file")
const (
cannotUseFlexWithClusterApisErrorCode = "CANNOT_USE_FLEX_CLUSTER_IN_CLUSTER_API"
deprecateMessageSharedTier = "Deprecation note: the M2 and M5 tiers are now deprecated ('%s' was selected); when selecting M2 or M5, a FLEX tier will be created instead. For the migration guide, visit: https://dochub.mongodb.org/core/flex-migration.\n"
independentShardScalingFlag = "independentShardScaling"
clusterWideScalingFlag = "clusterWideScaling"
)

func Builder() *cobra.Command {
Expand Down Expand Up @@ -138,6 +140,36 @@ func removeReadOnlyAttributes(out *atlasClustersPinned.AdvancedClusterDescriptio
}
}

func removeReadOnlyAttributesLatest(out *atlasv2.ClusterDescription20240805) {
out.Id = nil
out.CreateDate = nil
out.StateName = nil
out.MongoDBVersion = nil
out.ConnectionStrings = nil
isTenant := false

for i, spec := range out.GetReplicationSpecs() {
(*out.ReplicationSpecs)[i].Id = nil
for _, c := range spec.GetRegionConfigs() {
if c.GetProviderName() == tenant {
isTenant = true
// Set disksize to nil for tenant clusters
for _, c := range spec.GetRegionConfigs() {
c.ElectableSpecs.DiskSizeGB = nil
}
}
}
}

if isTenant {
out.BiConnector = nil
out.EncryptionAtRestProvider = nil
out.MongoDBMajorVersion = nil
out.PitEnabled = nil
out.BackupEnabled = nil
}
}

func removeReadOnlyAttributesSharedCluster(out *atlas.Cluster) {
out.ID = ""
out.CreateDate = ""
Expand Down
168 changes: 168 additions & 0 deletions internal/cli/clusters/clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"time"

"github.com/go-test/deep"
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/pointer"
atlasClustersPinned "go.mongodb.org/atlas-sdk/v20240530005/admin"
atlasv2 "go.mongodb.org/atlas-sdk/v20250312003/admin"
)

func TestRemoveReadOnlyAttributes(t *testing.T) {
Expand Down Expand Up @@ -152,3 +154,169 @@ func TestRemoveReadOnlyAttributes(t *testing.T) {
})
}
}

func TestRemoveReadOnlyAttributesLatest(t *testing.T) {
var (
id = "Test"
testVar = "test"
specID = "22"
diskSizeGB = 30.0
priority = 7
providerName = "AWS"
regionName = "US_EAST_1"
timeStamp = time.Now()
)
tests := []struct {
name string
args *atlasv2.ClusterDescription20240805
want *atlasv2.ClusterDescription20240805
}{
{
name: "One ReplicationSpec",
args: &atlasv2.ClusterDescription20240805{
Id: &id,
MongoDBVersion: &testVar,
StateName: &testVar,
ReplicationSpecs: &[]atlasv2.ReplicationSpec20240805{
{
Id: &specID,
RegionConfigs: &[]atlasv2.CloudRegionConfig20240805{
{
ElectableSpecs: &atlasv2.HardwareSpec20240805{
DiskSizeGB: &diskSizeGB,
},
Priority: &priority,
ProviderName: &providerName,
RegionName: &regionName,
},
},
},
},
CreateDate: &timeStamp,
},
want: &atlasv2.ClusterDescription20240805{
ReplicationSpecs: &[]atlasv2.ReplicationSpec20240805{
{
RegionConfigs: &[]atlasv2.CloudRegionConfig20240805{
{
ElectableSpecs: &atlasv2.HardwareSpec20240805{
DiskSizeGB: &diskSizeGB,
},
Priority: &priority,
ProviderName: &providerName,
RegionName: &regionName,
},
},
},
},
},
},
{
name: "More ReplicationSpecs",
args: &atlasv2.ClusterDescription20240805{
Id: &id,
MongoDBVersion: &testVar,
StateName: &testVar,
ReplicationSpecs: &[]atlasv2.ReplicationSpec20240805{
{
Id: &specID,
RegionConfigs: &[]atlasv2.CloudRegionConfig20240805{
{
ElectableSpecs: &atlasv2.HardwareSpec20240805{
DiskSizeGB: &diskSizeGB,
},
Priority: &priority,
ProviderName: &providerName,
RegionName: &regionName,
},
},
},
{
Id: &specID,
RegionConfigs: &[]atlasv2.CloudRegionConfig20240805{
{
ElectableSpecs: &atlasv2.HardwareSpec20240805{
DiskSizeGB: &diskSizeGB,
},
},
},
},
},
CreateDate: &timeStamp,
},
want: &atlasv2.ClusterDescription20240805{
ReplicationSpecs: &[]atlasv2.ReplicationSpec20240805{
{
RegionConfigs: &[]atlasv2.CloudRegionConfig20240805{
{
ElectableSpecs: &atlasv2.HardwareSpec20240805{
DiskSizeGB: &diskSizeGB,
},
Priority: &priority,
ProviderName: &providerName,
RegionName: &regionName,
},
},
},
{
RegionConfigs: &[]atlasv2.CloudRegionConfig20240805{
{
ElectableSpecs: &atlasv2.HardwareSpec20240805{
DiskSizeGB: &diskSizeGB,
},
},
},
},
},
},
},
{
name: "Tenant cluster",
args: &atlasv2.ClusterDescription20240805{
Id: &id,
ReplicationSpecs: &[]atlasv2.ReplicationSpec20240805{
{
RegionConfigs: &[]atlasv2.CloudRegionConfig20240805{
{
ElectableSpecs: &atlasv2.HardwareSpec20240805{
DiskSizeGB: &diskSizeGB,
},
Priority: &priority,
ProviderName: pointer.Get(tenant),
RegionName: &regionName,
},
},
},
},
},
want: &atlasv2.ClusterDescription20240805{
ReplicationSpecs: &[]atlasv2.ReplicationSpec20240805{
{
RegionConfigs: &[]atlasv2.CloudRegionConfig20240805{
{
ElectableSpecs: &atlasv2.HardwareSpec20240805{
DiskSizeGB: nil,
},
Priority: &priority,
ProviderName: pointer.Get(tenant),
RegionName: &regionName,
},
},
},
},
},
},
}

for _, tt := range tests {
name := tt.name
arg := tt.args
want := tt.want
t.Run(name, func(t *testing.T) {
removeReadOnlyAttributesLatest(arg)
if diff := deep.Equal(arg, want); diff != nil {
t.Error(diff)
}
})
}
}
Loading
Loading