• 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

8.11
/internal/cli/projects/delete.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 projects
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=projects -source=delete.go
31

32
type ProjectDeleter interface {
33
        DeleteProject(string) error
34
}
35

36
type DeleteOpts struct {
37
        *cli.DeleteOpts
38
        store ProjectDeleter
39
}
40

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

49
func (opts *DeleteOpts) Run() error {
1✔
50
        return opts.Delete(opts.store.DeleteProject)
1✔
51
}
1✔
52

53
// atlas project(s) delete <ID> [--orgId orgId].
54
func DeleteBuilder() *cobra.Command {
×
55
        opts := &DeleteOpts{
×
56
                DeleteOpts: cli.NewDeleteOpts("Project '%s' deleted\n", "Project not deleted"),
×
57
        }
×
58
        cmd := &cobra.Command{
×
59
                Use:     "delete <ID>",
×
60
                Aliases: []string{"rm"},
×
61
                Short:   "Remove the specified project.",
×
62
                Long:    fmt.Sprintf(usage.RequiredRole, "Project Owner"),
×
63
                Args:    require.ExactArgs(1),
×
64
                Annotations: map[string]string{
×
65
                        "IDDesc": "Unique 24-digit string that identifies the project.",
×
66
                        "output": opts.SuccessMessage(),
×
67
                },
×
68
                Example: `  # Remove the project with the ID 5e2211c17a3e5a48f5497de3:
×
69
  atlas projects delete 5e2211c17a3e5a48f5497de3`,
×
70
                PreRunE: func(cmd *cobra.Command, args []string) error {
×
71
                        if err := opts.initStore(cmd.Context())(); err != nil {
×
72
                                return err
×
73
                        }
×
74
                        opts.Entry = args[0]
×
75
                        return opts.Prompt()
×
76
                },
77
                RunE: func(_ *cobra.Command, _ []string) error {
×
78
                        return opts.Run()
×
79
                },
×
80
        }
81

82
        cmd.Flags().BoolVar(&opts.Confirm, flag.Force, false, usage.Force)
×
83

×
84
        return cmd
×
85
}
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