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

mongodb / mongodb-atlas-cli / 16671521771

01 Aug 2025 09:28AM UTC coverage: 57.953% (-7.1%) from 65.017%
16671521771

push

github

web-flow
chore: remove unit tag from tests (#4071)

23613 of 40745 relevant lines covered (57.95%)

2.74 hits per line

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

42.31
/internal/cli/commonerrors/errors.go
1
// Copyright 2022 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 commonerrors
16

17
import (
18
        "errors"
19

20
        "go.mongodb.org/atlas-sdk/v20250312005/admin"
21
)
22

23
var (
24
        errClusterUnsupported         = errors.New("atlas supports this command only for M10+ clusters. You can upgrade your cluster by running the 'atlas cluster upgrade' command")
25
        errOutsideVPN                 = errors.New("forbidden action outside access allow list, if you are a MongoDB employee double check your VPN connection")
26
        errAsymmetricShardUnsupported = errors.New("trying to run a cluster wide scaling command on an independent shard scaling cluster. Use --autoScalingMode 'independentShardScaling' instead")
27
)
28

29
const (
30
        asymmetricShardUnsupportedErrorCode = "ASYMMETRIC_SHARD_UNSUPPORTED"
31
)
32

33
func Check(err error) error {
1✔
34
        if err == nil {
2✔
35
                return nil
1✔
36
        }
1✔
37

38
        apiError, ok := admin.AsError(err)
1✔
39
        if ok {
1✔
40
                switch apiError.GetErrorCode() {
×
41
                case "TENANT_CLUSTER_UPDATE_UNSUPPORTED":
×
42
                        return errClusterUnsupported
×
43
                case "GLOBAL_USER_OUTSIDE_SUBNET":
×
44
                        return errOutsideVPN
×
45
                case asymmetricShardUnsupportedErrorCode:
×
46
                        return errAsymmetricShardUnsupported
×
47
                }
48
        }
49
        return err
1✔
50
}
51

52
func IsAsymmetricShardUnsupported(err error) bool {
×
53
        apiError, ok := admin.AsError(err)
×
54
        if !ok {
×
55
                return false
×
56
        }
×
57
        return apiError.GetErrorCode() == asymmetricShardUnsupportedErrorCode
×
58
}
59

60
func IsCannotUseFlexWithClusterApis(err error) bool {
1✔
61
        apiError, ok := admin.AsError(err)
1✔
62
        if !ok {
1✔
63
                return false
×
64
        }
×
65
        return apiError.GetErrorCode() == "CANNOT_USE_FLEX_CLUSTER_IN_CLUSTER_API"
1✔
66
}
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