Skip to content

CLOUDP-62037: Add Labels when Creating/Updating cluster with mongocli Atlas #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7c198bc
Refactoring
andreaangiolillo Apr 29, 2020
1dacaa0
Merge remote-tracking branch 'origin/master'
andreaangiolillo Apr 29, 2020
39b30ca
Merge remote-tracking branch 'origin/master'
andreaangiolillo Apr 29, 2020
861d88e
Merge remote-tracking branch 'origin/master'
andreaangiolillo Apr 30, 2020
a1ba80a
Merge remote-tracking branch 'origin/master'
andreaangiolillo May 5, 2020
658d057
Merge remote-tracking branch 'origin/master'
andreaangiolillo May 5, 2020
5927427
Merge remote-tracking branch 'origin/master'
andreaangiolillo May 7, 2020
6fffc8c
Merge remote-tracking branch 'origin/master'
andreaangiolillo May 7, 2020
b0da6c5
Merge remote-tracking branch 'origin/master'
andreaangiolillo May 8, 2020
08b90d3
Merge remote-tracking branch 'origin/master'
andreaangiolillo May 8, 2020
8904b24
Merge remote-tracking branch 'origin'
andreaangiolillo May 8, 2020
247a32e
Merge remote-tracking branch 'origin/master'
andreaangiolillo May 14, 2020
031f320
CLOUDP-62037: Add Labels when Creating/Updating cluster with mongocli…
andreaangiolillo May 14, 2020
be85d46
Merge remote-tracking branch 'origin/master' into CLOUDP-62037
andreaangiolillo May 14, 2020
e2d55e4
Merge remote-tracking branch 'origin/master' into CLOUDP-62037
andreaangiolillo May 14, 2020
47351ac
Addressed PR comment
andreaangiolillo May 14, 2020
ed9491c
Merge remote-tracking branch 'origin/master' into CLOUDP-62037
andreaangiolillo May 14, 2020
7f5f4f1
Added break
andreaangiolillo May 14, 2020
d5716d1
Addressed PR comments
andreaangiolillo May 14, 2020
17f5ea6
Addressed PR comment
andreaangiolillo May 14, 2020
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
19 changes: 19 additions & 0 deletions internal/cli/atlas_clusters_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,29 @@ func (opts *atlasClustersCreateOpts) newCluster() (*atlas.Cluster, error) {
cluster.Name = opts.name
}

updateLabels(cluster)

cluster.GroupID = opts.ProjectID()
return cluster, nil
}

func updateLabels(out *atlas.Cluster) {
found := false
for _, v := range out.Labels {
if v.Key == labelKey && v.Value == labelValue {
found = true
break
}
}

if !found {
out.Labels = append(out.Labels, atlas.Label{
Key: labelKey,
Value: labelValue,
})
}
}

func (opts *atlasClustersCreateOpts) applyOpts(out *atlas.Cluster) {
replicationSpec := opts.newReplicationSpec()
out.ProviderBackupEnabled = &opts.backup
Expand Down
2 changes: 2 additions & 0 deletions internal/cli/atlas_clusters_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func (opts *atlasClustersUpdateOpts) patchOpts(out *atlas.Cluster) {
if opts.tier != "" {
out.ProviderSettings.InstanceSizeName = opts.tier
}

updateLabels(out)
}

// mongocli atlas cluster(s) update name --projectId projectId [--tier M#] [--diskSizeGB N] [--mdbVersion]
Expand Down
2 changes: 2 additions & 0 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (
const (
fallbackSuccessMessage = "'%s' deleted\n"
fallbackFailMessage = "entry not deleted"
labelKey = "Infrastructure Tool"
labelValue = "mongoCLI"
)

type globalOpts struct {
Expand Down