Skip to content

Commit 55cce5c

Browse files
committed
task: move commands to more specific pkgs
1 parent 7bdb182 commit 55cce5c

32 files changed

+123
-123
lines changed

internal/cli/opsmanager/agents.go renamed to internal/cli/agents/agents.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package agents
1616

1717
import (
1818
"github.com/mongodb/mongocli/internal/description"
1919
"github.com/spf13/cobra"
2020
)
2121

22-
func AgentsBuilder() *cobra.Command {
22+
func Builder() *cobra.Command {
2323
cmd := &cobra.Command{
2424
Use: "agents",
2525
Aliases: []string{"agent"},
2626
Short: description.Agents,
2727
}
2828

29-
cmd.AddCommand(AgentsUpgradeBuilder())
29+
cmd.AddCommand(UpgradeBuilder())
3030
return cmd
3131
}

internal/cli/opsmanager/agents_upgrade.go renamed to internal/cli/agents/upgrade.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package agents
1616

1717
import (
1818
"github.com/mongodb/mongocli/internal/cli"
@@ -24,18 +24,18 @@ import (
2424
"github.com/spf13/cobra"
2525
)
2626

27-
type AgentsUpgradeOpts struct {
27+
type UpgradeOpts struct {
2828
cli.GlobalOpts
2929
store store.AgentUpgrader
3030
}
3131

32-
func (opts *AgentsUpgradeOpts) initStore() error {
32+
func (opts *UpgradeOpts) initStore() error {
3333
var err error
3434
opts.store, err = store.New(config.Default())
3535
return err
3636
}
3737

38-
func (opts *AgentsUpgradeOpts) Run() error {
38+
func (opts *UpgradeOpts) Run() error {
3939
r, err := opts.store.UpgradeAgent(opts.ConfigProjectID())
4040

4141
if err != nil {
@@ -46,8 +46,8 @@ func (opts *AgentsUpgradeOpts) Run() error {
4646
}
4747

4848
// mongocli ops-manager agents upgrade [--projectId projectId]
49-
func AgentsUpgradeBuilder() *cobra.Command {
50-
opts := &AgentsUpgradeOpts{}
49+
func UpgradeBuilder() *cobra.Command {
50+
opts := &UpgradeOpts{}
5151
cmd := &cobra.Command{
5252
Use: "upgrade",
5353
Args: cobra.NoArgs,

internal/cli/opsmanager/agents_upgrade_test.go renamed to internal/cli/agents/upgrade_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package agents
1616

1717
import (
1818
"testing"
@@ -30,7 +30,7 @@ func TestAgentsUpgradeOpts_Run(t *testing.T) {
3030

3131
expected := new(opsmngr.AutomationConfigAgent)
3232

33-
opts := &AgentsUpgradeOpts{
33+
opts := &UpgradeOpts{
3434
store: mockStore,
3535
}
3636

internal/cli/opsmanager/automation.go renamed to internal/cli/automation/automation.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package automation
1616

1717
import (
1818
"github.com/mongodb/mongocli/internal/description"
1919
"github.com/spf13/cobra"
2020
)
2121

22-
func AutomationBuilder() *cobra.Command {
22+
func Builder() *cobra.Command {
2323
cmd := &cobra.Command{
2424
Use: "automation",
2525
Short: description.Automation,
2626
}
2727

28-
cmd.AddCommand(AutomationStatusBuilder())
29-
cmd.AddCommand(AutomationDescribeBuilder())
30-
cmd.AddCommand(AutomationUpdateBuilder())
31-
cmd.AddCommand(AutomationWatchBuilder())
28+
cmd.AddCommand(StatusBuilder())
29+
cmd.AddCommand(DescribeBuilder())
30+
cmd.AddCommand(UpdateBuilder())
31+
cmd.AddCommand(WatchBuilder())
3232

3333
return cmd
3434
}

internal/cli/opsmanager/automation_describe.go renamed to internal/cli/automation/describe.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package automation
1616

1717
import (
1818
"github.com/mongodb/mongocli/internal/cli"
@@ -24,18 +24,18 @@ import (
2424
"github.com/spf13/cobra"
2525
)
2626

27-
type AutomationDescribeOpts struct {
27+
type DescribeOpts struct {
2828
cli.GlobalOpts
2929
store store.AutomationGetter
3030
}
3131

32-
func (opts *AutomationDescribeOpts) initStore() error {
32+
func (opts *DescribeOpts) initStore() error {
3333
var err error
3434
opts.store, err = store.New(config.Default())
3535
return err
3636
}
3737

38-
func (opts *AutomationDescribeOpts) Run() error {
38+
func (opts *DescribeOpts) Run() error {
3939
r, err := opts.store.GetAutomationConfig(opts.ConfigProjectID())
4040

4141
if err != nil {
@@ -46,8 +46,8 @@ func (opts *AutomationDescribeOpts) Run() error {
4646
}
4747

4848
// mongocli ops-manager automation describe [--projectId projectId]
49-
func AutomationDescribeBuilder() *cobra.Command {
50-
opts := &AutomationDescribeOpts{}
49+
func DescribeBuilder() *cobra.Command {
50+
opts := &DescribeOpts{}
5151
cmd := &cobra.Command{
5252
Use: "describe",
5353
Aliases: []string{"show", "get"},

internal/cli/opsmanager/automation_describe_test.go renamed to internal/cli/automation/describe_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package automation
1616

1717
import (
1818
"testing"
@@ -30,7 +30,7 @@ func TestAutomationShowOpts_Run(t *testing.T) {
3030

3131
expected := fixture.AutomationConfig()
3232

33-
opts := &AutomationDescribeOpts{
33+
opts := &DescribeOpts{
3434
store: mockStore,
3535
}
3636

internal/cli/opsmanager/automation_status.go renamed to internal/cli/automation/status.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package automation
1616

1717
import (
1818
"github.com/mongodb/mongocli/internal/cli"
@@ -25,18 +25,18 @@ import (
2525
"github.com/spf13/cobra"
2626
)
2727

28-
type AutomationStatusOpts struct {
28+
type StatusOpts struct {
2929
cli.GlobalOpts
3030
store store.AutomationStatusGetter
3131
}
3232

33-
func (opts *AutomationStatusOpts) initStore() error {
33+
func (opts *StatusOpts) initStore() error {
3434
var err error
3535
opts.store, err = store.New(config.Default())
3636
return err
3737
}
3838

39-
func (opts *AutomationStatusOpts) Run() error {
39+
func (opts *StatusOpts) Run() error {
4040
result, err := opts.store.GetAutomationStatus(opts.ConfigProjectID())
4141

4242
if err != nil {
@@ -47,8 +47,8 @@ func (opts *AutomationStatusOpts) Run() error {
4747
}
4848

4949
// mongocli ops-manager automation status [--projectId projectId]
50-
func AutomationStatusBuilder() *cobra.Command {
51-
opts := &AutomationStatusOpts{}
50+
func StatusBuilder() *cobra.Command {
51+
opts := &StatusOpts{}
5252
cmd := &cobra.Command{
5353
Use: "status",
5454
Short: description.ShowAutomationStatus,

internal/cli/opsmanager/automation_status_test.go renamed to internal/cli/automation/status_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package automation
1616

1717
import (
1818
"testing"
@@ -30,7 +30,7 @@ func TestAutomationStatus_Run(t *testing.T) {
3030

3131
expected := fixture.AutomationStatus()
3232

33-
opts := &AutomationStatusOpts{
33+
opts := &StatusOpts{
3434
store: mockStore,
3535
}
3636

internal/cli/opsmanager/automation_update.go renamed to internal/cli/automation/update.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package automation
1616

1717
import (
1818
"fmt"
1919

2020
"github.com/mongodb/mongocli/internal/cli"
21-
2221
"github.com/mongodb/mongocli/internal/config"
2322
"github.com/mongodb/mongocli/internal/file"
2423
"github.com/mongodb/mongocli/internal/flag"
@@ -29,20 +28,20 @@ import (
2928
"go.mongodb.org/ops-manager/opsmngr"
3029
)
3130

32-
type AutomationUpdateOpts struct {
31+
type UpdateOpts struct {
3332
cli.GlobalOpts
3433
filename string
3534
fs afero.Fs
3635
store store.AutomationUpdater
3736
}
3837

39-
func (opts *AutomationUpdateOpts) initStore() error {
38+
func (opts *UpdateOpts) initStore() error {
4039
var err error
4140
opts.store, err = store.New(config.Default())
4241
return err
4342
}
4443

45-
func (opts *AutomationUpdateOpts) Run() error {
44+
func (opts *UpdateOpts) Run() error {
4645
newConfig := new(opsmngr.AutomationConfig)
4746
err := file.Load(opts.fs, opts.filename, newConfig)
4847
if err != nil {
@@ -53,14 +52,14 @@ func (opts *AutomationUpdateOpts) Run() error {
5352
return err
5453
}
5554

56-
fmt.Print(deploymentStatus(config.OpsManagerURL(), opts.ConfigProjectID()))
55+
fmt.Print(cli.DeploymentStatus(config.OpsManagerURL(), opts.ConfigProjectID()))
5756

5857
return nil
5958
}
6059

6160
// mongocli om automation update --projectId projectId --file myfile.json
62-
func AutomationUpdateBuilder() *cobra.Command {
63-
opts := &AutomationUpdateOpts{
61+
func UpdateBuilder() *cobra.Command {
62+
opts := &UpdateOpts{
6463
fs: afero.NewOsFs(),
6564
}
6665
cmd := &cobra.Command{

internal/cli/opsmanager/automation_update_test.go renamed to internal/cli/automation/update_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package automation
1616

1717
import (
1818
"testing"
@@ -40,7 +40,7 @@ func TestAutomationUpdate_Run(t *testing.T) {
4040
}`
4141
fileName := "om_automation_test.json"
4242
_ = afero.WriteFile(appFS, fileName, []byte(fileJSON), 0600)
43-
createOpts := &AutomationUpdateOpts{
43+
createOpts := &UpdateOpts{
4444
store: mockStore,
4545
fs: appFS,
4646
filename: fileName,

internal/cli/opsmanager/automation_watch.go renamed to internal/cli/automation/watch.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package automation
1616

1717
import (
1818
"fmt"
@@ -28,18 +28,18 @@ import (
2828
"github.com/spf13/cobra"
2929
)
3030

31-
type AutomationWatchOpts struct {
31+
type WatchOpts struct {
3232
cli.GlobalOpts
3333
store store.AutomationStatusGetter
3434
}
3535

36-
func (opts *AutomationWatchOpts) initStore() error {
36+
func (opts *WatchOpts) initStore() error {
3737
var err error
3838
opts.store, err = store.New(config.Default())
3939
return err
4040
}
4141

42-
func (opts *AutomationWatchOpts) Run() error {
42+
func (opts *WatchOpts) Run() error {
4343
for {
4444
result, err := opts.store.GetAutomationStatus(opts.ConfigProjectID())
4545
if err != nil {
@@ -63,8 +63,8 @@ func (opts *AutomationWatchOpts) Run() error {
6363
}
6464

6565
// mongocli ops-manager automation watch [--projectId projectId]
66-
func AutomationWatchBuilder() *cobra.Command {
67-
opts := &AutomationWatchOpts{}
66+
func WatchBuilder() *cobra.Command {
67+
opts := &WatchOpts{}
6868
cmd := &cobra.Command{
6969
Use: "watch",
7070
Short: description.WatchAutomationStatus,

internal/cli/opsmanager/automation_watch_test.go renamed to internal/cli/automation/watch_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package opsmanager
15+
package automation
1616

1717
import (
1818
"testing"
@@ -30,7 +30,7 @@ func TestAutomationWatch_Run(t *testing.T) {
3030

3131
expected := fixture.AutomationStatus()
3232

33-
opts := &AutomationWatchOpts{
33+
opts := &WatchOpts{
3434
store: mockStore,
3535
}
3636

0 commit comments

Comments
 (0)