Skip to content

Commit e6f2e30

Browse files
authored
Merge pull request #38 from gssbzn/golint
Enable golint and fix errors
2 parents d0530ef + 4357bba commit e6f2e30

File tree

10 files changed

+42
-92
lines changed

10 files changed

+42
-92
lines changed

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fmt:
1717

1818
lint:
1919
@echo "==> Checking source code against linters..."
20-
golangci-lint run $(TEST) -E gofmt
20+
golangci-lint run $(TEST) -E gofmt -E golint -E misspell
2121

2222
check: test lint
2323

mongodbatlas/clusters.go

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -114,61 +114,6 @@ type clustersResponse struct {
114114
TotalCount int `json:"totalCount,omitempty"`
115115
}
116116

117-
// DefaultDiskSizeGB represents the Tier and the default disk size for each one
118-
// it can be use like: DefaultDiskSizeGB["AWS"]["M10"]
119-
var DefaultDiskSizeGB map[string]map[string]float64 = map[string]map[string]float64{
120-
"TENANT": {
121-
"M2": 2,
122-
"M5": 5,
123-
},
124-
"AWS": {
125-
"M10": 10,
126-
"M20": 20,
127-
"M30": 40,
128-
"M40": 80,
129-
"R40": 80,
130-
"M40_NVME": 380,
131-
"M50": 160,
132-
"R50": 160,
133-
"M50_NVME": 760,
134-
"M60": 320,
135-
"R60": 320,
136-
"M60_NVME": 1600,
137-
"M80": 750,
138-
"R80": 750,
139-
"M80_NVME": 1600,
140-
"M140": 1000,
141-
"M200": 1500,
142-
"R200": 1500,
143-
"M200_NVME": 3100,
144-
"M300": 2000,
145-
"R300": 2000,
146-
"R400": 3000,
147-
"M400_NVME": 4000,
148-
},
149-
"GCP": {
150-
"M10": 10,
151-
"M20": 20,
152-
"M30": 40,
153-
"M40": 80,
154-
"M50": 160,
155-
"M60": 320,
156-
"M80": 750,
157-
"M200": 1500,
158-
"M300": 2200,
159-
},
160-
"AZURE": {
161-
"M10": 32,
162-
"M20": 32,
163-
"M30": 32,
164-
"M40": 128,
165-
"M50": 128,
166-
"M60": 128,
167-
"M80": 256,
168-
"M200": 256,
169-
},
170-
}
171-
172117
//List all clusters in the project associated to {GROUP-ID}.
173118
//See more: https://docs.atlas.mongodb.com/reference/api/clusters-get-all/
174119
func (s *ClustersServiceOp) List(ctx context.Context, groupID string, listOptions *ListOptions) ([]Cluster, *Response, error) {

mongodbatlas/encryptions_at_rest.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ const (
4242
// EuWest3 represents the EU_WEST_3 Europe region for AWS Configuration
4343
EuWest3 = "EU_WEST_3"
4444

45-
// Azure represents `AZURE` where the Azure account credencials reside
45+
// Azure represents `AZURE` where the Azure account credentials reside
4646
Azure = "AZURE"
47-
// AzureChina represents `AZURE_CHINA` AZURE where the Azure account credencials reside
47+
// AzureChina represents `AZURE_CHINA` AZURE where the Azure account credentials reside
4848
AzureChina = "AZURE_CHINA"
49-
// AzureGermany represents `AZURE_GERMANY` AZURE where the Azure account credencials reside
49+
// AzureGermany represents `AZURE_GERMANY` AZURE where the Azure account credentials reside
5050
AzureGermany = "AZURE_GERMANY"
5151

5252
encryptionsAtRestBasePath = "groups/%s/encryptionAtRest"
@@ -61,7 +61,7 @@ type EncryptionsAtRestService interface {
6161
Delete(context.Context, string) (*Response, error)
6262
}
6363

64-
//EncryptionsAtRestServiceOp handles communication with the DatabaseUsers related methos of the
64+
//EncryptionsAtRestServiceOp handles communication with the DatabaseUsers related methods of the
6565
//MongoDB Atlas API
6666
type EncryptionsAtRestServiceOp struct {
6767
client *Client

mongodbatlas/global_clusters_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func TestGlobalClusters_DeleteManagedNamespace(t *testing.T) {
267267
}
268268

269269
if diff := deep.Equal(globalCluster, expected); diff != nil {
270-
t.Errorf("GlobalClusters.DeleteCustomZoneMappings Reponse Body = %v", diff)
270+
t.Errorf("GlobalClusters.DeleteCustomZoneMappings Response Body = %v", diff)
271271
}
272272
}
273273

@@ -380,6 +380,6 @@ func TestGlobalClusters_DeleteCustomZoneMappings(t *testing.T) {
380380
}
381381

382382
if diff := deep.Equal(globalCluster, expected); diff != nil {
383-
t.Errorf("GlobalClusters.AddCustomZoneMappings Reponse Body = %v", diff)
383+
t.Errorf("GlobalClusters.AddCustomZoneMappings Response Body = %v", diff)
384384
}
385385
}

mongodbatlas/mongodbatlas.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type Client struct {
4444
Containers ContainersService
4545
EncryptionsAtRest EncryptionsAtRestService
4646
WhitelistAPIKeys WhitelistAPIKeysService
47-
PrivateIPMode PrivateIpModeService
47+
PrivateIPMode PrivateIPModeService
4848
MaintenanceWindows MaintenanceWindowsService
4949
Teams TeamsService
5050
AtlasUsers AtlasUsersService
@@ -154,7 +154,7 @@ func NewClient(httpClient *http.Client) *Client {
154154
c.Peers = &PeersServiceOp{client: c}
155155
c.ProjectIPWhitelist = &ProjectIPWhitelistServiceOp{client: c}
156156
c.WhitelistAPIKeys = &WhitelistAPIKeysServiceOp{client: c}
157-
c.PrivateIPMode = &PrivateIpModeServiceOp{client: c}
157+
c.PrivateIPMode = &PrivateIPModeServiceOp{client: c}
158158
c.MaintenanceWindows = &MaintenanceWindowsServiceOp{client: c}
159159
c.Teams = &TeamsServiceOp{client: c}
160160
c.AtlasUsers = &AtlasUsersServiceOp{client: c}

mongodbatlas/peers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var _ PeersService = &PeersServiceOp{}
3131
// Peer represents MongoDB peer connection.
3232
type Peer struct {
3333
AccepterRegionName string `json:"accepterRegionName,omitempty"`
34-
AWSAccountId string `json:"awsAccountId,omitempty"`
34+
AWSAccountID string `json:"awsAccountId,omitempty"`
3535
ConnectionID string `json:"connectionId,omitempty"`
3636
ContainerID string `json:"containerId,omitempty"`
3737
ErrorStateName string `json:"errorStateName,omitempty"`
@@ -42,7 +42,7 @@ type Peer struct {
4242
VpcID string `json:"vpcId,omitempty"`
4343
AtlasCIDRBlock string `json:"atlasCidrBlock,omitempty"`
4444
AzureDirectoryID string `json:"azureDirectoryId,omitempty"`
45-
AzureSubscriptionId string `json:"azureSubscriptionId,omitempty"`
45+
AzureSubscriptionID string `json:"azureSubscriptionId,omitempty"`
4646
ResourceGroupName string `json:"resourceGroupName,omitempty"`
4747
VNetName string `json:"vnetName,omitempty"`
4848
ErrorState string `json:"errorState,omitempty"`

mongodbatlas/private_ip_mode.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ import (
66
"net/http"
77
)
88

9-
const privateIpModePath = "groups/%s/privateIpMode"
9+
const privateIPModePath = "groups/%s/privateIpMode"
1010

11-
//PrivateIpModeService is an interface for interfacing with the PrivateIpMode
11+
//PrivateIPModeService is an interface for interfacing with the PrivateIpMode
1212
// endpoints of the MongoDB Atlas API.
1313
//See more: https://docs.atlas.mongodb.com/reference/api/get-private-ip-mode-for-project/
14-
type PrivateIpModeService interface {
14+
type PrivateIPModeService interface {
1515
Get(context.Context, string) (*PrivateIPMode, *Response, error)
1616
Update(context.Context, string, *PrivateIPMode) (*PrivateIPMode, *Response, error)
1717
}
1818

19-
//PrivateIpModeServiceOp handles communication with the Private IP Mode related methods
19+
//PrivateIPModeServiceOp handles communication with the Private IP Mode related methods
2020
// of the MongoDB Atlas API
21-
type PrivateIpModeServiceOp struct {
21+
type PrivateIPModeServiceOp struct {
2222
client *Client
2323
}
2424

25-
var _ PrivateIpModeService = &PrivateIpModeServiceOp{}
25+
var _ PrivateIPModeService = &PrivateIPModeServiceOp{}
2626

2727
// PrivateIPMode represents MongoDB Private IP Mode Configutation.
2828
type PrivateIPMode struct {
@@ -31,8 +31,8 @@ type PrivateIPMode struct {
3131

3232
//Get Verify Connect via Peering Only Mode from the project associated to {GROUP-ID}.
3333
//See more: https://docs.atlas.mongodb.com/reference/api/get-private-ip-mode-for-project/
34-
func (s *PrivateIpModeServiceOp) Get(ctx context.Context, groupID string) (*PrivateIPMode, *Response, error) {
35-
path := fmt.Sprintf(privateIpModePath, groupID)
34+
func (s *PrivateIPModeServiceOp) Get(ctx context.Context, groupID string) (*PrivateIPMode, *Response, error) {
35+
path := fmt.Sprintf(privateIPModePath, groupID)
3636

3737
req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil)
3838
if err != nil {
@@ -50,12 +50,12 @@ func (s *PrivateIpModeServiceOp) Get(ctx context.Context, groupID string) (*Priv
5050

5151
//Update connection via Peering Only Mode in the project associated to {GROUP-ID}
5252
//See more: https://docs.atlas.mongodb.com/reference/api/set-private-ip-mode-for-project/
53-
func (s *PrivateIpModeServiceOp) Update(ctx context.Context, groupID string, updateRequest *PrivateIPMode) (*PrivateIPMode, *Response, error) {
53+
func (s *PrivateIPModeServiceOp) Update(ctx context.Context, groupID string, updateRequest *PrivateIPMode) (*PrivateIPMode, *Response, error) {
5454
if updateRequest == nil {
5555
return nil, nil, NewArgError("updateRequest", "cannot be nil")
5656
}
5757

58-
path := fmt.Sprintf(privateIpModePath, groupID)
58+
path := fmt.Sprintf(privateIPModePath, groupID)
5959

6060
req, err := s.client.NewRequest(ctx, http.MethodPatch, path, updateRequest)
6161
if err != nil {

mongodbatlas/private_ip_mode_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ func TestPrivateIPMode_Get(t *testing.T) {
1717

1818
groupID := "6d2065c687d9d64ae7acdg41"
1919

20-
mux.HandleFunc(fmt.Sprintf("/"+privateIpModePath, groupID), func(w http.ResponseWriter, r *http.Request) {
20+
mux.HandleFunc(fmt.Sprintf("/"+privateIPModePath, groupID), func(w http.ResponseWriter, r *http.Request) {
2121
testMethod(t, r, http.MethodGet)
2222
fmt.Fprint(w, `{
2323
"enabled": true
2424
}`)
2525
})
2626

27-
privateIpMode, _, err := client.PrivateIPMode.Get(ctx, groupID)
27+
privateIPMode, _, err := client.PrivateIPMode.Get(ctx, groupID)
2828
if err != nil {
2929
t.Errorf("PrivateIPMode.Get returned error: %v", err)
3030
}
@@ -33,12 +33,12 @@ func TestPrivateIPMode_Get(t *testing.T) {
3333
Enabled: pointy.Bool(true),
3434
}
3535

36-
if diff := deep.Equal(privateIpMode, expected); diff != nil {
36+
if diff := deep.Equal(privateIPMode, expected); diff != nil {
3737
t.Error(diff)
3838
}
3939

40-
if !reflect.DeepEqual(privateIpMode, expected) {
41-
t.Errorf("PrivateIPMode.Get\n got=%#v\nwant=%#v", privateIpMode, expected)
40+
if !reflect.DeepEqual(privateIPMode, expected) {
41+
t.Errorf("PrivateIPMode.Get\n got=%#v\nwant=%#v", privateIPMode, expected)
4242
}
4343
}
4444

@@ -52,7 +52,7 @@ func TestPrivateIPMode_Update(t *testing.T) {
5252
Enabled: pointy.Bool(true),
5353
}
5454

55-
mux.HandleFunc(fmt.Sprintf("/"+privateIpModePath, groupID), func(w http.ResponseWriter, r *http.Request) {
55+
mux.HandleFunc(fmt.Sprintf("/"+privateIPModePath, groupID), func(w http.ResponseWriter, r *http.Request) {
5656
expected := map[string]interface{}{
5757
"enabled": true,
5858
}
@@ -79,12 +79,12 @@ func TestPrivateIPMode_Update(t *testing.T) {
7979
fmt.Fprint(w, jsonBlob)
8080
})
8181

82-
privateIpMode, _, err := client.PrivateIPMode.Update(ctx, groupID, updateRequest)
82+
privateIPMode, _, err := client.PrivateIPMode.Update(ctx, groupID, updateRequest)
8383
if err != nil {
8484
t.Errorf("PrivateIPMode.Update returned error: %v", err)
8585
}
8686

87-
if enabled := pointy.BoolValue(privateIpMode.Enabled, false); !enabled {
87+
if enabled := pointy.BoolValue(privateIPMode.Enabled, false); !enabled {
8888
t.Errorf("expected privateIPMode '%t', received '%t'", true, enabled)
8989
}
9090
}

mongodbatlas/projects.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ import (
77
)
88

99
const (
10-
GROUP_OWNER = "GROUP_OWNER" //GROUP_OWNER - Project Owner
11-
GROUP_READ_ONLY = "GROUP_READ_ONLY" //GROUP_READ_ONLY - Project Read Only
12-
GROUP_DATA_ACCESS_ADMIN = "GROUP_DATA_ACCESS_ADMIN" //GROUP_DATA_ACCESS_ADMIN - Project Data Access Admin
13-
GROUP_DATA_ACCESS_READ_WRITE = "GROUP_DATA_ACCESS_READ_WRITE" //GROUP_DATA_ACCESS_READ_WRITE - Project Data Access Read/Write
14-
GROUP_DATA_ACCESS_READ_ONLY = "GROUP_DATA_ACCESS_READ_ONLY" //GROUP_DATA_ACCESS_READ_ONLY - Project Data Access Read Only
15-
projectBasePath = "groups"
10+
// GroupOwner - Project Owner
11+
GroupOwner = "GROUP_OWNER"
12+
// GroupReadOnly - Project Read Only
13+
GroupReadOnly = "GROUP_READ_ONLY"
14+
// GroupDataAccessAdmin - Project Data Access Admin
15+
GroupDataAccessAdmin = "GROUP_DATA_ACCESS_ADMIN"
16+
// GroupDataAccessReadWrite - Project Data Access Read/Write
17+
GroupDataAccessReadWrite = "GROUP_DATA_ACCESS_READ_WRITE"
18+
// GroupDataAccessReadOnly - Project Data Access Read Only
19+
GroupDataAccessReadOnly = "GROUP_DATA_ACCESS_READ_ONLY"
20+
projectBasePath = "groups"
1621
)
1722

1823
// ProjectsService is an interface for interfacing with the Projects

mongodbatlas/projects_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ func TestProject_AddTeamsToProject(t *testing.T) {
330330
createRequest := &ProjectTeam{
331331
TeamID: "{TEAM-ID}",
332332
Roles: []*RoleName{
333-
{RoleName: GROUP_OWNER},
334-
{RoleName: GROUP_READ_ONLY},
333+
{RoleName: GroupOwner},
334+
{RoleName: GroupReadOnly},
335335
},
336336
}
337337

0 commit comments

Comments
 (0)