Skip to content

Commit fe6dd62

Browse files
authored
Merge pull request #269 from gssbzn/fix-linting
fix: fix golangci lint and travis
2 parents 712fa81 + 0958d85 commit fe6dd62

7 files changed

+31
-31
lines changed

.golangci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ issues:
9898
- testpackage
9999
# part of the golangci govet package is picking up things that go vet doesn't. Seems flaky, shutting that specific error off
100100

101-
# Exclude some staticcheck messages
101+
# Exclude some staticcheck messages
102102
- linters:
103103
- staticcheck
104104
text: "SA1019:" # d.GetOkExists is deprecated: usage is discouraged due to undefined behaviors and may be removed in a future version of the SDK

.travis.yml

+13-23
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
1-
dist: xenial
2-
sudo: required
3-
services:
4-
- docker
51
language: go
62

7-
env:
8-
global:
9-
GOFLAGS=-mod=vendor
10-
GOGC=10
11-
GOOPTS="-p 2"
3+
go:
4+
- 1.14.x
5+
- tip
6+
127
matrix:
138
fast_finish: true
149
allow_failures:
1510
- go: tip
1611
include:
17-
- go: "1.14.x"
18-
name: "Code Lint"
19-
script: make lint
20-
- go: "1.14.x"
21-
name: "Code UnitTest"
22-
script: make test
23-
- go: "1.14.x"
24-
name: "Website"
25-
script:
26-
#- make website-test #commented until Terraform Provider Program Validation
27-
- make website-lint
28-
29-
install:
30-
- make tools
12+
- name: "Code Lint"
13+
before_install: make tools
14+
script: make lint
15+
- name: "Website"
16+
before_install: make tools
17+
script:
18+
#- make website-test #commented until Terraform Provider Program Validation
19+
- make website-lint
20+
script: make test

GNUmakefile

+14-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@ GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
33
PKG_NAME=mongodbatlas
44
WEBSITE_REPO=github.com/hashicorp/terraform-website
55

6+
GOFLAGS=-mod=vendor
7+
GOGC=10
8+
GOOPTS="-p 2"
9+
10+
GOLANGCI_VERSION=v1.29.0
11+
12+
export PATH := ./bin:$(PATH)
13+
614
default: build
715

816
build: fmtcheck
917
go install
1018

11-
1219
test: fmtcheck
1320
go test $(TEST) -timeout=30s -parallel=4
1421

@@ -32,9 +39,12 @@ lint:
3239
# https://github.com/golangci/golangci-lint/issues/337 fixing error
3340
golangci-lint run ./$(PKG_NAME) -v --deadline=30m
3441

35-
tools:
42+
tools: ## Install dev tools
43+
@echo "==> Installing dependencies..."
3644
GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
37-
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint
45+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_VERSION)
46+
47+
check: test lint
3848

3949
test-compile:
4050
@if [ "$(TEST)" = "./..." ]; then \
@@ -62,4 +72,4 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
6272
endif
6373
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
6474

65-
.PHONY: build test testacc fmt fmtcheck lint tools test-compile website website-lint website-test
75+
.PHONY: build test testacc fmt fmtcheck lint check tools test-compile website website-lint website-test

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# MongoDB Atlas Provider
2+
[![Build Status](https://travis-ci.org/terraform-providers/terraform-provider-mongodbatlas.svg?branch=master)](https://travis-ci.org/terraform-providers/terraform-provider-mongodbatlas)
23

34
This is the repository for the Terraform MongoDB Atlas Provider, which allows one to use Terraform with MongoDB's Database as a Service offering, Atlas.
45
Learn more about Atlas at [https://www.mongodb.com/cloud/atlas](https://www.mongodb.com/cloud/atlas)

mongodbatlas/resource_mongodbatlas_cluster.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ func flattenBiConnector(biConnector *matlas.BiConnector) map[string]interface{}
10171017
}
10181018

10191019
func getInstanceSizeToInt(instanceSize string) int {
1020-
regex := regexp.MustCompile("[0-9]+")
1020+
regex := regexp.MustCompile(`\d+`)
10211021
num := regex.FindString(instanceSize)
10221022

10231023
return cast.ToInt(num) // if the string is empty it always return 0

mongodbatlas/resource_mongodbatlas_custom_db_role.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func resourceMongoDBAtlasCustomDBRole() *schema.Resource {
3737
Required: true,
3838
ForceNew: true,
3939
ValidateFunc: validation.All(
40-
validation.StringMatch(regexp.MustCompile(`[\w\d-]+`), "`role_name` can contain only letters, digits, underscores, and dashes"),
40+
validation.StringMatch(regexp.MustCompile(`[\w-]+`), "`role_name` can contain only letters, digits, underscores, and dashes"),
4141
func(v interface{}, k string) (ws []string, es []error) {
4242
value := v.(string)
4343
if strings.HasPrefix(value, "x-gen") {

tools.go

-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ package main
44

55
import (
66
_ "github.com/client9/misspell/cmd/misspell"
7-
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
87
)

0 commit comments

Comments
 (0)