• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb / mongodb-atlas-cli / 25848964073

14 May 2026 07:59AM UTC coverage: 22.479% (-41.3%) from 63.771%
25848964073

push

github

web-flow
build(deps): bump test-summary/action from 2.4 to 2.6 (#4576)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

8987 of 39979 relevant lines covered (22.48%)

0.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.0
/internal/cli/streams/instance/list.go
1
// Copyright 2023 MongoDB Inc
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
package instance
16

17
import (
18
        "context"
19
        "fmt"
20

21
        "github.com/mongodb/atlas-cli-core/config"
22
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli"
23
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/require"
24
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store"
25
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/usage"
26
        "github.com/spf13/cobra"
27
        atlasv2 "go.mongodb.org/atlas-sdk/v20250312018/admin"
28
)
29

30
//go:generate go tool go.uber.org/mock/mockgen -typed -destination=list_mock_test.go -package=instance -source=list.go
31

32
type StreamsLister interface {
33
        ProjectStreams(*atlasv2.ListStreamWorkspacesApiParams) (*atlasv2.PaginatedApiStreamsTenant, error)
34
}
35

36
type ListOpts struct {
37
        cli.ProjectOpts
38
        cli.OutputOpts
39
        cli.ListOpts
40
        store StreamsLister
41
}
42

43
const (
44
        listTemplate = `ID        NAME        CLOUD        REGION{{range valueOrEmptySlice .Results}}
45
{{.Id}}        {{.Name}}        {{.DataProcessRegion.CloudProvider}}        {{.DataProcessRegion.Region}}{{end}}
46
`
47
)
48

49
func (opts *ListOpts) Run() error {
1✔
50
        listParams := new(atlasv2.ListStreamWorkspacesApiParams)
1✔
51
        listParams.ItemsPerPage = &opts.ItemsPerPage
1✔
52
        listParams.GroupId = opts.ProjectID
1✔
53
        listParams.PageNum = &opts.PageNum
1✔
54

1✔
55
        r, err := opts.store.ProjectStreams(listParams)
1✔
56
        if err != nil {
1✔
57
                return err
×
58
        }
×
59

60
        return opts.Print(r)
1✔
61
}
62

63
func (opts *ListOpts) initStore(ctx context.Context) func() error {
×
64
        return func() error {
×
65
                var err error
×
66
                opts.store, err = store.New(store.AuthenticatedPreset(config.Default()), store.WithContext(ctx))
×
67
                return err
×
68
        }
×
69
}
70

71
// ListBuilder
72
// atlas streams instance list.
73
func ListBuilder() *cobra.Command {
×
74
        opts := &ListOpts{}
×
75
        cmd := &cobra.Command{
×
76
                Use:   "list",
×
77
                Short: "List all the Atlas Stream Processing instances for your project.",
×
78
                Long:  fmt.Sprintf(usage.RequiredRole, "Project Read Only"),
×
79
                Example: `  # Return a JSON-formatted list of all Atlas Stream Processing instances for the project with ID 5e2211c17a3e5a48f5497de3:
×
80
  atlas streams instance list --projectId 5e2211c17a3e5a48f5497de3 --output json`,
×
81
                Args: require.NoArgs,
×
82
                Annotations: map[string]string{
×
83
                        "output": listTemplate,
×
84
                },
×
85
                PreRunE: func(cmd *cobra.Command, _ []string) error {
×
86
                        return opts.PreRunE(
×
87
                                opts.ValidateProjectID,
×
88
                                opts.initStore(cmd.Context()),
×
89
                                opts.InitOutput(cmd.OutOrStdout(), listTemplate),
×
90
                        )
×
91
                },
×
92
                RunE: func(_ *cobra.Command, _ []string) error {
×
93
                        return opts.Run()
×
94
                },
×
95
        }
96

97
        opts.AddListOptsFlagsWithoutOmitCount(cmd)
×
98

×
99
        opts.AddProjectOptsFlags(cmd)
×
100
        opts.AddOutputOptFlags(cmd)
×
101

×
102
        return cmd
×
103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc