Skip to content

Commit 9ce4fc9

Browse files
blvaCiprian Tibulca
andauthored
CLOUDP-201526: List deployments even if atlas throw errors (#2311)
Co-authored-by: Ciprian Tibulca <[email protected]>
1 parent 3f16010 commit 9ce4fc9

File tree

1 file changed

+8
-5
lines changed
  • internal/cli/atlas/deployments

1 file changed

+8
-5
lines changed

internal/cli/atlas/deployments/list.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package deployments
1717
import (
1818
"context"
1919
"errors"
20+
"fmt"
2021

2122
"github.com/mongodb/mongodb-atlas-cli/internal/cli"
2223
"github.com/mongodb/mongodb-atlas-cli/internal/cli/atlas/deployments/options"
@@ -47,6 +48,7 @@ const listTemplate = `NAME TYPE MDB VER STATE
4748
{{end}}`
4849

4950
const MaxItemsPerPage = 500
51+
const errAtlas = "failed to retrieve Atlas deployments with: %s"
5052

5153
func (opts *ListOpts) initStore(ctx context.Context) func() error {
5254
return func() error {
@@ -102,21 +104,22 @@ func (opts *ListOpts) getAtlasDeployments() ([]options.Deployment, error) {
102104
}
103105

104106
func (opts *ListOpts) Run(ctx context.Context) error {
105-
atlasClusters, err := opts.getAtlasDeployments()
106-
if err != nil {
107-
return err
108-
}
109-
110107
mdbContainers, err := opts.GetLocalDeployments(ctx)
111108
if err != nil && !errors.Is(err, podman.ErrPodmanNotFound) {
112109
return err
113110
}
114111

112+
atlasClusters, atlasErr := opts.getAtlasDeployments()
113+
115114
err = opts.Print(append(atlasClusters, mdbContainers...))
116115
if err != nil {
117116
return err
118117
}
119118

119+
if atlasErr != nil {
120+
return fmt.Errorf(errAtlas, atlasErr.Error())
121+
}
122+
120123
return nil
121124
}
122125

0 commit comments

Comments
 (0)