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

mongodb / mongodb-atlas-cli / 26228926989

21 May 2026 01:27PM UTC coverage: 22.63% (-41.6%) from 64.198%
26228926989

push

github

apix-bot[bot]
Update compliance report for v1.55.0

8987 of 39713 relevant lines covered (22.63%)

0.25 hits per line

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

6.98
/internal/cli/integrations/delete.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/flag"
25
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store"
26
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/usage"
27
        "github.com/spf13/cobra"
28
)
29

30
//go:generate go tool go.uber.org/mock/mockgen -typed -destination=delete_mock_test.go -package=integrations -source=delete.go
31

32
type IntegrationDeleter interface {
33
        DeleteIntegration(string, string) error
34
}
35

36
type DeleteOpts struct {
37
        cli.ProjectOpts
38
        *cli.DeleteOpts
39
        store IntegrationDeleter
40
}
41

42
func (opts *DeleteOpts) initStore(ctx context.Context) func() error {
×
43
        return func() error {
×
44
                var err error
×
45
                opts.store, err = store.New(store.AuthenticatedPreset(config.Default()), store.WithContext(ctx))
×
46
                return err
×
47
        }
×
48
}
49

50
func (opts *DeleteOpts) Run() error {
1✔
51
        return opts.Delete(opts.store.DeleteIntegration, opts.ConfigProjectID())
1✔
52
}
1✔
53

54
// atlas integration(s) delete <TYPE> [--force] --projectId projectId.
55
func DeleteBuilder() *cobra.Command {
×
56
        opts := &DeleteOpts{
×
57
                DeleteOpts: cli.NewDeleteOpts("Integration '%s' deleted\n", "Integration not deleted"),
×
58
        }
×
59
        cmd := &cobra.Command{
×
60
                Use:     "delete <integrationType>",
×
61
                Aliases: []string{"rm"},
×
62
                Short:   "Remove the specified third-party integration from your project.",
×
63
                Long: `Deleting an integration from a project removes that integration configuration only for that project. This does not affect any other project or organization's configured integrations.
×
64

×
65
` + fmt.Sprintf(usage.RequiredRole, "Project Owner"),
×
66
                Args: require.ExactValidArgs(1),
×
67
                Example: `  # Remove the Datadog integration for the project with the ID 5e2211c17a3e5a48f5497de3:
×
68
  atlas integrations delete DATADOG --projectId 5e2211c17a3e5a48f5497de3`,
×
69
                ValidArgs: []string{"PAGER_DUTY", "MICROSOFT_TEAMS", "SLACK", "DATADOG", "NEW_RELIC", "OPS_GENIE", "VICTOR_OPS", "WEBHOOK", "PROMETHEUS"},
×
70
                Annotations: map[string]string{
×
71
                        "integrationTypeDesc": "Human-readable label that identifies the service integration to delete. Valid values are PAGER_DUTY, MICROSOFT_TEAMS, SLACK, DATADOG, NEW_RELIC, OPS_GENIE, VICTOR_OPS, WEBHOOK, PROMETHEUS.",
×
72
                        "output":              opts.SuccessMessage(),
×
73
                },
×
74
                PreRunE: func(cmd *cobra.Command, args []string) error {
×
75
                        opts.Entry = args[0]
×
76
                        return opts.PreRunE(
×
77
                                opts.ValidateProjectID,
×
78
                                opts.initStore(cmd.Context()),
×
79
                                opts.Prompt,
×
80
                        )
×
81
                },
×
82
                RunE: func(_ *cobra.Command, _ []string) error {
×
83
                        return opts.Run()
×
84
                },
×
85
        }
86

87
        cmd.Flags().BoolVar(&opts.Confirm, flag.Force, false, usage.Force)
×
88
        opts.AddProjectOptsFlags(cmd)
×
89

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