• 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

26.67
/internal/cli/streams/instance/update.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/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
        atlasv2 "go.mongodb.org/atlas-sdk/v20250312018/admin"
29
)
30

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

33
type StreamsUpdater interface {
34
        UpdateStream(string, string, *atlasv2.StreamsTenantUpdateRequest) (*atlasv2.StreamsTenant, error)
35
}
36

37
type UpdateOpts struct {
38
        cli.ProjectOpts
39
        cli.OutputOpts
40
        cli.InputOpts
41
        name     string
42
        provider string
43
        region   string
44
        store    StreamsUpdater
45
}
46

47
const (
48
        updateTemplate = "Atlas Streams Processor Instance '{{.Name}}' successfully updated.\n"
49
)
50

51
func (opts *UpdateOpts) Run() error {
1✔
52
        updateRequest := opts.streamsUpdateRequest()
1✔
53
        r, err := opts.store.UpdateStream(opts.ProjectID, opts.name, updateRequest)
1✔
54

1✔
55
        if err != nil {
1✔
56
                return err
×
57
        }
×
58

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

62
func (opts *UpdateOpts) streamsUpdateRequest() *atlasv2.StreamsTenantUpdateRequest {
1✔
63
        request := atlasv2.NewStreamsTenantUpdateRequestWithDefaults()
1✔
64

1✔
65
        if opts.provider != "" {
2✔
66
                request.CloudProvider = &opts.provider
1✔
67
        }
1✔
68

69
        if opts.region != "" {
2✔
70
                request.Region = &opts.region
1✔
71
        }
1✔
72

73
        return request
1✔
74
}
75

76
func (opts *UpdateOpts) initStore(ctx context.Context) func() error {
×
77
        return func() error {
×
78
                var err error
×
79
                opts.store, err = store.New(store.AuthenticatedPreset(config.Default()), store.WithContext(ctx))
×
80
                return err
×
81
        }
×
82
}
83

84
// CreateBuilder
85
// atlas streams instance update [name]
86
// --provider AWS
87
// --region VIRGINIA_USA.
88
func UpdateBuilder() *cobra.Command {
×
89
        opts := &UpdateOpts{}
×
90
        cmd := &cobra.Command{
×
91
                Use:   "update <name>",
×
92
                Short: "Updates an Atlas Stream Processing instance for your project.",
×
93
                Long: `Before updating an Atlas Streams Processing instance, you must first stop all processes associated with it.
×
94
` + fmt.Sprintf(usage.RequiredRole, "Project Owner"),
×
95
                Args: require.ExactArgs(1),
×
96
                Annotations: map[string]string{
×
97
                        "nameDesc": "Name of the Atlas Stream Processing instance. After creation, you can't change the name of the instance. The name can contain ASCII letters, numbers, and hyphens.",
×
98
                        "output":   updateTemplate,
×
99
                },
×
100
                Example: `  # Modify the Atlas Stream Processing instance configuration with the name MyInstance:
×
101
  atlas streams instance update MyInstance --provider AWS --region VIRGINIA_USA`,
×
102
                PreRunE: func(cmd *cobra.Command, args []string) error {
×
103
                        opts.name = args[0]
×
104

×
105
                        return opts.PreRunE(
×
106
                                opts.ValidateProjectID,
×
107
                                opts.initStore(cmd.Context()),
×
108
                                opts.InitOutput(cmd.OutOrStdout(), updateTemplate),
×
109
                        )
×
110
                },
×
111
                RunE: func(_ *cobra.Command, _ []string) error {
×
112
                        return opts.Run()
×
113
                },
×
114
        }
115

116
        cmd.Flags().StringVar(&opts.provider, flag.Provider, "AWS", usage.StreamsProvider)
×
117
        cmd.Flags().StringVarP(&opts.region, flag.Region, flag.RegionShort, "", usage.StreamsRegion)
×
118

×
119
        opts.AddProjectOptsFlags(cmd)
×
120
        opts.AddOutputOptFlags(cmd)
×
121

×
122
        _ = cmd.MarkFlagRequired(flag.Provider)
×
123
        _ = cmd.MarkFlagRequired(flag.Region)
×
124

×
125
        return cmd
×
126
}
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