• 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

62.07
/internal/cli/api/command_request.go
1
// Copyright 2024 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 api
16

17
import (
18
        "io"
19

20
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/api"
21
        shared_api "github.com/mongodb/mongodb-atlas-cli/atlascli/tools/shared/api"
22
        "github.com/spf13/cobra"
23
        "github.com/spf13/pflag"
24
)
25

26
func NewCommandRequestFromCobraCommand(cobraCommand *cobra.Command, apiCommand shared_api.Command, content io.Reader, format string, version shared_api.Version) (*api.CommandRequest, error) {
×
27
        return &api.CommandRequest{
×
28
                Command:    apiCommand,
×
29
                Content:    content,
×
30
                Format:     format,
×
31
                Parameters: cobraFlagsToRequestParameters(cobraCommand),
×
32
                Version:    version,
×
33
        }, nil
×
34
}
×
35

36
func cobraFlagsToRequestParameters(cobraCommand *cobra.Command) map[string][]string {
1✔
37
        parameters := make(map[string][]string)
1✔
38
        var flagsToIgnore = map[string]struct{}{
1✔
39
                "file":    {},
1✔
40
                "version": {},
1✔
41
        }
1✔
42

1✔
43
        cobraCommand.LocalFlags().VisitAll(func(flag *pflag.Flag) {
2✔
44
                if _, ignoreFlag := flagsToIgnore[flag.Name]; ignoreFlag {
1✔
45
                        return
×
46
                }
×
47

48
                // If the flag has not been set, don't set the value
49
                // Doing this would cause the request to contain all default values and might set not required values to not desired values
50
                if !flag.Changed {
2✔
51
                        return
1✔
52
                }
1✔
53

54
                if values, ok := flag.Value.(pflag.SliceValue); ok {
2✔
55
                        parameters[flag.Name] = values.GetSlice()
1✔
56
                } else {
2✔
57
                        parameters[flag.Name] = []string{flag.Value.String()}
1✔
58
                }
1✔
59
        })
60

61
        return parameters
1✔
62
}
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