• 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

10.26
/internal/cli/integrations/list.go
1
// Copyright 2020 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 integrations
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
const listTemplate = `TYPE{{range valueOrEmptySlice .Results}}
31
{{.Type}}{{end}}
32
`
33

34
//go:generate go tool go.uber.org/mock/mockgen -typed -destination=list_mock_test.go -package=integrations -source=list.go
35

36
type IntegrationLister interface {
37
        Integrations(string) (*atlasv2.PaginatedIntegration, error)
38
}
39
type ListOpts struct {
40
        cli.ProjectOpts
41
        cli.OutputOpts
42
        store IntegrationLister
43
}
44

45
func (opts *ListOpts) initStore(ctx context.Context) func() error {
×
46
        return func() error {
×
47
                var err error
×
48
                opts.store, err = store.New(store.AuthenticatedPreset(config.Default()), store.WithContext(ctx))
×
49
                return err
×
50
        }
×
51
}
52

53
func (opts *ListOpts) Run() error {
1✔
54
        r, err := opts.store.Integrations(opts.ConfigProjectID())
1✔
55
        if err != nil {
1✔
56
                return err
×
57
        }
×
58

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

62
// atlas integrations(s) list --projectId projectId.
63
func ListBuilder() *cobra.Command {
×
64
        opts := new(ListOpts)
×
65
        cmd := &cobra.Command{
×
66
                Use:     "list",
×
67
                Short:   "Return all active third-party integrations for your project.",
×
68
                Long:    fmt.Sprintf(usage.RequiredRole, "Project Owner"),
×
69
                Aliases: []string{"ls"},
×
70
                Args:    require.NoArgs,
×
71
                Annotations: map[string]string{
×
72
                        "output": listTemplate,
×
73
                },
×
74
                Example: `  # Return a JSON-formatted list of active third-party integrations for the project with the ID 5e2211c17a3e5a48f5497de3:
×
75
  atlas integrations list --projectId 5e2211c17a3e5a48f5497de3 --output json`,
×
76
                PreRunE: func(cmd *cobra.Command, _ []string) error {
×
77
                        return opts.PreRunE(
×
78
                                opts.ValidateProjectID,
×
79
                                opts.initStore(cmd.Context()),
×
80
                                opts.InitOutput(cmd.OutOrStdout(), listTemplate),
×
81
                        )
×
82
                },
×
83
                RunE: func(_ *cobra.Command, _ []string) error {
×
84
                        return opts.Run()
×
85
                },
×
86
        }
87

88
        opts.AddProjectOptsFlags(cmd)
×
89
        opts.AddOutputOptFlags(cmd)
×
90

×
91
        return cmd
×
92
}
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