Skip to content

Commit 8c81ed4

Browse files
authored
CLOUDP-57866: Move PCGC into github.com/mongodb & rename it (#34)
1 parent 9efa1e2 commit 8c81ed4

22 files changed

+205
-244
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ require (
66
github.com/AlecAivazis/survey/v2 v2.0.5
77
github.com/Masterminds/semver v1.5.0
88
github.com/Sectorbob/mlab-ns2 v0.0.0-20171030222938-d3aa0c295a8a
9-
github.com/go-test/deep v1.0.1
9+
github.com/go-test/deep v1.0.5
1010
github.com/golang/mock v1.4.0
1111
github.com/mattn/go-colorable v0.1.4 // indirect
1212
github.com/mattn/go-isatty v0.0.12 // indirect
1313
github.com/mitchellh/go-homedir v1.1.0
14-
github.com/mongodb-labs/pcgc v0.1.0
1514
github.com/mongodb/go-client-mongodb-atlas v0.1.3
15+
github.com/mongodb/go-client-mongodb-ops-manager v0.0.1
1616
github.com/pelletier/go-toml v1.6.0 // indirect
1717
github.com/spf13/afero v1.2.2
1818
github.com/spf13/cast v1.3.1 // indirect

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
4040
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
4141
github.com/go-test/deep v1.0.1 h1:UQhStjbkDClarlmv0am7OXXO4/GaPdCGiUiMTvi28sg=
4242
github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
43+
github.com/go-test/deep v1.0.5 h1:AKODKU3pDH1RzZzm6YZu77YWtEAq6uh1rLIAQlay2qc=
44+
github.com/go-test/deep v1.0.5/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
4345
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
4446
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
4547
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
@@ -99,10 +101,10 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG
99101
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
100102
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
101103
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
102-
github.com/mongodb-labs/pcgc v0.1.0 h1:3SW8KOG6JT2fMUxm2jhZuFA7uvzKEnJo2IdvqvjEbRg=
103-
github.com/mongodb-labs/pcgc v0.1.0/go.mod h1:+6hisP7Ak3teFHE5kyR72APwCJzIBClcRDT03wxQxNU=
104104
github.com/mongodb/go-client-mongodb-atlas v0.1.3 h1:/l36BomZ93+YTQhqcnJLhgphP5+/VGqbmwAVQlWKhng=
105105
github.com/mongodb/go-client-mongodb-atlas v0.1.3/go.mod h1:LS8O0YLkA+sbtOb3fZLF10yY3tJM+1xATXMJ3oU35LU=
106+
github.com/mongodb/go-client-mongodb-ops-manager v0.0.1 h1:eIDlyuEA47+h0NNJhHN7RGS+cCcJ/xNWwYWnTIs52TE=
107+
github.com/mongodb/go-client-mongodb-ops-manager v0.0.1/go.mod h1:/klt2/hsSSBWGCHapu+d1rOJ23sXDDWduuGgepRzZwI=
106108
github.com/mwielbut/pointy v1.1.0 h1:U5/YEfoIkaGCHv0St3CgjduqXID4FNRoyZgLM1kY9vg=
107109
github.com/mwielbut/pointy v1.1.0/go.mod h1:MvvO+uMFj9T5DMda33HlvogsFBX7pWWKAkFIn4teYwY=
108110
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=

internal/cli/ops_manager_owner_create.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package cli
1616

1717
import (
1818
"github.com/AlecAivazis/survey/v2"
19-
cm "github.com/mongodb-labs/pcgc/cloudmanager"
19+
om "github.com/mongodb/go-client-mongodb-ops-manager/opsmngr"
2020
"github.com/mongodb/mongocli/internal/flags"
2121
"github.com/mongodb/mongocli/internal/json"
2222
"github.com/mongodb/mongocli/internal/store"
@@ -50,8 +50,8 @@ func (opts *opsManagerOwnerCreateOpts) Run() error {
5050
return json.PrettyPrint(result)
5151
}
5252

53-
func (opts *opsManagerOwnerCreateOpts) newOwner() *cm.User {
54-
user := &cm.User{
53+
func (opts *opsManagerOwnerCreateOpts) newOwner() *om.User {
54+
user := &om.User{
5555
Username: opts.email,
5656
Password: opts.password,
5757
FirstName: opts.firstName,

internal/convert/automation_config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ package convert
1717
import (
1818
"fmt"
1919

20-
"github.com/mongodb-labs/pcgc/cloudmanager"
20+
om "github.com/mongodb/go-client-mongodb-ops-manager/opsmngr"
2121
)
2222

2323
const (
2424
mongod = "mongod"
2525
)
2626

2727
// FromAutomationConfig convert from cloud format to mCLI format
28-
func FromAutomationConfig(in *cloudmanager.AutomationConfig) (out []ClusterConfig) {
28+
func FromAutomationConfig(in *om.AutomationConfig) (out []ClusterConfig) {
2929
out = make([]ClusterConfig, len(in.ReplicaSets))
3030

3131
for i, rs := range in.ReplicaSets {
@@ -53,16 +53,16 @@ func FromAutomationConfig(in *cloudmanager.AutomationConfig) (out []ClusterConfi
5353
}
5454

5555
// Shutdown a cluster processes
56-
func Shutdown(out *cloudmanager.AutomationConfig, name string) {
56+
func Shutdown(out *om.AutomationConfig, name string) {
5757
setDisabledByClusterName(out, name, true)
5858
}
5959

6060
// Startup a cluster processes
61-
func Startup(out *cloudmanager.AutomationConfig, name string) {
61+
func Startup(out *om.AutomationConfig, name string) {
6262
setDisabledByClusterName(out, name, false)
6363
}
6464

65-
func setDisabledByClusterName(out *cloudmanager.AutomationConfig, name string, disabled bool) {
65+
func setDisabledByClusterName(out *om.AutomationConfig, name string, disabled bool) {
6666
// This value may not be present and is mandatory
6767
if out.Auth.DeploymentAuthMechanisms == nil {
6868
out.Auth.DeploymentAuthMechanisms = make([]string, 0)
@@ -82,15 +82,15 @@ func setDisabledByClusterName(out *cloudmanager.AutomationConfig, name string, d
8282
}
8383

8484
// convertCloudMember map cloudmanager.Member -> convert.ProcessConfig
85-
func convertCloudMember(out *ProcessConfig, in cloudmanager.Member) {
85+
func convertCloudMember(out *ProcessConfig, in om.Member) {
8686
out.Votes = in.Votes
8787
out.Priority = in.Priority
8888
out.SlaveDelay = in.SlaveDelay
8989
out.BuildIndexes = &in.BuildIndexes
9090
}
9191

9292
// convertCloudProcess map cloudmanager.Process -> convert.ProcessConfig
93-
func convertCloudProcess(out *ProcessConfig, in *cloudmanager.Process) {
93+
func convertCloudProcess(out *ProcessConfig, in *om.Process) {
9494
out.DBPath = in.Args26.Storage.DBPath
9595
out.LogPath = in.Args26.SystemLog.Path
9696
out.Port = in.Args26.NET.Port

internal/convert/cluster_config.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package convert
1616

1717
import (
1818
"github.com/Masterminds/semver"
19-
"github.com/mongodb-labs/pcgc/cloudmanager"
19+
om "github.com/mongodb/go-client-mongodb-ops-manager/opsmngr"
2020
"github.com/mongodb/mongocli/internal/search"
2121
)
2222

@@ -39,8 +39,8 @@ type ClusterConfig struct {
3939

4040
// PatchAutomationConfig add the ClusterConfig to a cloudmanager.AutomationConfig
4141
// this method will modify the given AutomationConfig to add the new replica set information
42-
func (c *ClusterConfig) PatchAutomationConfig(out *cloudmanager.AutomationConfig) error {
43-
newProcesses := make([]*cloudmanager.Process, len(c.ProcessConfigs))
42+
func (c *ClusterConfig) PatchAutomationConfig(out *om.AutomationConfig) error {
43+
newProcesses := make([]*om.Process, len(c.ProcessConfigs))
4444

4545
newReplicaSet, err := c.toReplicaSet()
4646
if err != nil {
@@ -67,15 +67,15 @@ func (c *ClusterConfig) PatchAutomationConfig(out *cloudmanager.AutomationConfig
6767
}
6868

6969
// toReplicaSet convert from cli config to cloudmanager.ReplicaSet
70-
func (c *ClusterConfig) toReplicaSet() (*cloudmanager.ReplicaSet, error) {
70+
func (c *ClusterConfig) toReplicaSet() (*om.ReplicaSet, error) {
7171
protocolVer, err := protocolVer(c.FCVersion)
7272
if err != nil {
7373
return nil, err
7474
}
7575

76-
rs := &cloudmanager.ReplicaSet{
76+
rs := &om.ReplicaSet{
7777
ID: c.Name,
78-
Members: make([]cloudmanager.Member, len(c.ProcessConfigs)),
78+
Members: make([]om.Member, len(c.ProcessConfigs)),
7979
ProtocolVersion: protocolVer,
8080
}
8181

@@ -85,13 +85,13 @@ func (c *ClusterConfig) toReplicaSet() (*cloudmanager.ReplicaSet, error) {
8585
// patchProcesses replace replica set processes with new configuration
8686
// this will disable all existing processes for the given replica set and remove the association
8787
// Then try to patch then with the new config if one config exists for the same host:port
88-
func patchProcesses(out *cloudmanager.AutomationConfig, newReplicaSetID string, newProcesses []*cloudmanager.Process) {
88+
func patchProcesses(out *om.AutomationConfig, newReplicaSetID string, newProcesses []*om.Process) {
8989
for i, oldProcess := range out.Processes {
9090
if oldProcess.Args26.Replication != nil && oldProcess.Args26.Replication.ReplSetName == newReplicaSetID {
9191
oldProcess.Disabled = true
92-
oldProcess.Args26.Replication = new(cloudmanager.Replication)
92+
oldProcess.Args26.Replication = new(om.Replication)
9393
}
94-
pos, found := search.Processes(newProcesses, func(p *cloudmanager.Process) bool {
94+
pos, found := search.Processes(newProcesses, func(p *om.Process) bool {
9595
return p.Name == oldProcess.Name
9696
})
9797
if found {
@@ -105,8 +105,8 @@ func patchProcesses(out *cloudmanager.AutomationConfig, newReplicaSetID string,
105105
}
106106

107107
// patchReplicaSet if the replica set exists try to patch it if not add it
108-
func patchReplicaSet(out *cloudmanager.AutomationConfig, newReplicaSet *cloudmanager.ReplicaSet) {
109-
pos, found := search.ReplicaSets(out.ReplicaSets, func(r *cloudmanager.ReplicaSet) bool {
108+
func patchReplicaSet(out *om.AutomationConfig, newReplicaSet *om.ReplicaSet) {
109+
pos, found := search.ReplicaSets(out.ReplicaSets, func(r *om.ReplicaSet) bool {
110110
return r.ID == newReplicaSet.ID
111111
})
112112

@@ -118,7 +118,7 @@ func patchReplicaSet(out *cloudmanager.AutomationConfig, newReplicaSet *cloudman
118118
oldReplicaSet := out.ReplicaSets[pos]
119119
lastID := oldReplicaSet.Members[len(oldReplicaSet.Members)-1].ID
120120
for j, newMember := range newReplicaSet.Members {
121-
k, found := search.Members(oldReplicaSet.Members, func(m cloudmanager.Member) bool {
121+
k, found := search.Members(oldReplicaSet.Members, func(m om.Member) bool {
122122
return m.Host == newMember.Host
123123
})
124124
if found {

0 commit comments

Comments
 (0)