• 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.38
/internal/cli/streams/instance/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 instance
16

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

22
        "github.com/mongodb/atlas-cli-core/config"
23
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli"
24
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/require"
25
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/flag"
26
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store"
27
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/usage"
28
        "github.com/spf13/cobra"
29
)
30

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

33
type StreamsDeleter interface {
34
        DeleteStream(string, string) error
35
}
36

37
type DeleteOpts struct {
38
        cli.ProjectOpts
39
        *cli.DeleteOpts
40
        store StreamsDeleter
41
}
42

43
func (opts *DeleteOpts) Run() error {
1✔
44
        return opts.Delete(opts.store.DeleteStream, opts.ConfigProjectID(), opts.Entry)
1✔
45
}
1✔
46

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

55
// DeleteBuilder
56
// atlas streams instance delete [name].
57
func DeleteBuilder() *cobra.Command {
×
58
        opts := &DeleteOpts{
×
59
                DeleteOpts: cli.NewDeleteOpts("Atlas Streams processor instance '%s' deleted\n", "Atlas Streams processor instance not deleted"),
×
60
        }
×
61
        cmd := &cobra.Command{
×
62
                Use:   "delete <name>",
×
63
                Short: "Delete an Atlas Stream Processing instance.",
×
64
                Long: `The command prompts you to confirm the operation when you run the command without the --force option.
×
65

×
66
Before deleting an Atlas Streams Processing instance, you must first stop all processes associated with it.
×
67
` + fmt.Sprintf(usage.RequiredRole, "Project Owner"),
×
68
                Example: `  # Remove an Atlas Stream Processing instance after prompting for a confirmation:
×
69
  atlas streams instance delete myProcessorInstance
×
70

×
71
  # Remove an Atlas Stream Processing instance named myProcessorInstance without requiring confirmation:
×
72
  atlas streams instance delete myProcessorInstance --force`,
×
73
                Aliases: []string{"rm"},
×
74
                Args:    require.ExactArgs(1),
×
75
                Annotations: map[string]string{
×
76
                        "nameDesc": "Name of the Atlas Streams instance.",
×
77
                        "output":   opts.SuccessMessage(),
×
78
                },
×
79
                PreRunE: func(cmd *cobra.Command, args []string) error {
×
80
                        if len(args) == 0 {
×
81
                                return errors.New("the Atlas Streams Processor instance name is missing")
×
82
                        }
×
83

84
                        if err := opts.PreRunE(opts.ValidateProjectID, opts.initStore(cmd.Context())); err != nil {
×
85
                                return err
×
86
                        }
×
87
                        opts.Entry = args[0]
×
88
                        return opts.Prompt()
×
89
                },
90
                RunE: func(_ *cobra.Command, _ []string) error {
×
91
                        return opts.Run()
×
92
                },
×
93
        }
94

95
        opts.AddProjectOptsFlags(cmd)
×
96
        cmd.Flags().BoolVar(&opts.Confirm, flag.Force, false, usage.Force)
×
97

×
98
        return cmd
×
99
}
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