Skip to content

Commit f78f5dd

Browse files
committedOct 29, 2019
Refactor
1 parent 8e79d7a commit f78f5dd

13 files changed

+351
-275
lines changed
 

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ vendor/
22
.idea/
33
cover.out
44
temp/
5-
dist/
5+
dist/
6+
aws-mfa

‎.golangci.toml

+38-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
[run]
2-
deadline = "5m"
2+
timeout = "5m"
3+
skip-files = []
34

45
[linters-settings]
56

67
[linters-settings.govet]
78
check-shadowing = true
89

9-
[linters-settings.golint]
10-
min-confidence = 0.0
11-
1210
[linters-settings.gocyclo]
13-
min-complexity = 15.0
11+
min-complexity = 13.0
1412

1513
[linters-settings.maligned]
1614
suggest-new = true
@@ -25,12 +23,44 @@
2523
[linters]
2624
enable-all = true
2725
disable = [
26+
"maligned",
2827
"lll",
2928
"gas",
3029
"dupl",
3130
"prealloc",
32-
"maligned",
33-
"gochecknoinits",
34-
"gochecknoglobals",
3531
"scopelint",
32+
"funlen",
33+
"godox",
34+
"stylecheck",
35+
"wsl",
3636
]
37+
38+
[issues]
39+
exclude-use-default = false
40+
max-per-linter = 0
41+
max-same-issues = 0
42+
exclude = []
43+
[[issues.exclude-rules]]
44+
path = "annotations.go"
45+
text = "`(compatibilityMapping)` is a global variable"
46+
47+
[[issues.exclude-rules]]
48+
path = ".*_test.go"
49+
text = "`(updateExpected)` is a global variable"
50+
51+
[[issues.exclude-rules]]
52+
path = "main.go"
53+
text = "`(Version|ShortCommit|Date)` is a global variable"
54+
55+
[[issues.exclude-rules]]
56+
path = "main.go"
57+
text = "exported var `(Version|ShortCommit|Date)` should have comment or be unexported"
58+
59+
[[issues.exclude-rules]]
60+
path = "ingress/annotations.go"
61+
text = "`getBoolValue` - `defaultValue` always receives `false`"
62+
63+
[[issues.exclude-rules]]
64+
path = "static/v1.go"
65+
text = "exported type `(.+)` should have comment or be unexported"
66+

‎.goreleaser.yml

+22-15
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,31 @@ project_name: aws-mfa
22

33
builds:
44
- binary: aws-mfa
5-
ldflags:
6-
- -s -w -X github.com/mmatur/aws-mfa/cmd/version.version={{.Version}} -X github.com/mmatur/aws-mfa/cmd/version.commit={{.Commit}} -X github.com/mmatur/aws-mfa/cmd/version.date={{.Date}}
5+
main: ./main.go
6+
77
goos:
8-
- windows
9-
- darwin
108
- linux
9+
- darwin
10+
- windows
1111
- freebsd
1212
- openbsd
1313
goarch:
1414
- amd64
1515
- 386
1616
- arm
1717
- arm64
18+
- ppc64le
1819
goarm:
1920
- 7
20-
21+
- 6
22+
- 5
2123
ignore:
2224
- goos: darwin
2325
goarch: 386
2426
- goos: openbsd
2527
goarch: arm
28+
- goos: freebsd
29+
goarch: arm
2630

2731
changelog:
2832
sort: asc
@@ -31,17 +35,20 @@ changelog:
3135
- '^docs:'
3236
- '^doc:'
3337
- '^chore:'
38+
- '^chore(deps):'
3439
- '^test:'
3540
- '^tests:'
3641

37-
archive:
38-
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm}}v{{ .Arm }}{{ end }}'
39-
format: tar.gz
40-
format_overrides:
41-
- goos: windows
42-
format: zip
43-
files:
44-
- LICENSE
42+
archives:
43+
- id: aws-mfa
44+
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
45+
format: tar.gz
46+
format_overrides:
47+
- goos: windows
48+
format: zip
49+
files:
50+
- docs/*.md
51+
- LICENSE
4552

46-
#release:
47-
# disable: true
53+
checksum:
54+
name_template: "{{ .ProjectName }}_v{{ .Version }}_checksums.txt"

‎.travis.yml

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
language: go
22

33
go:
4-
- 1.13.x
4+
- "1.x"
55

6-
sudo: false
7-
8-
env:
9-
- GO111MODULE=on
6+
cache:
7+
directories:
8+
- $GOPATH/pkg/mod
109

1110
notifications:
1211
email:
1312
on_success: never
1413
on_failure: change
1514

15+
env:
16+
- GO111MODULE=on
17+
1618
before_install:
1719
# Install linters and misspell
18-
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.21.0
20+
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin ${GOLANGCI_LINT_VERSION}
1921
- golangci-lint --version
2022

2123
install:
22-
- echo "TRAVIS_GO_VERSION=$TRAVIS_GO_VERSION"
23-
- make dependencies
24+
- go mod tidy
25+
- git diff --exit-code go.mod
26+
- git diff --exit-code go.sum
27+
- go mod download
2428

2529
deploy:
2630
- provider: script
2731
skip_cleanup: true
2832
script: curl -sL https://git.io/goreleaser | bash
2933
on:
3034
tags: true
31-
condition: $TRAVIS_GO_VERSION =~ ^1\.x$

‎Makefile

+18-30
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,32 @@
1-
BINARY_NAME = aws-mfa
2-
DIST_DIR = $(CURDIR)/dist
3-
DIST_DIR_AWS_MFA = $(DIST_DIR)/$(BINARY_NAME)
4-
5-
TAG_NAME := $(shell git tag -l --contains HEAD)
6-
SHA := $(shell git rev-parse --short HEAD)
7-
VERSION := $(if $(TAG_NAME),$(TAG_NAME),$(SHA))
8-
BUILD_DATE := $(shell date -u '+%Y-%m-%d_%I:%M:%S%p')
1+
.PHONY: check clean test build package package-snapshot docs
92

103
export GO111MODULE=on
114

12-
GOFILES := $(shell git ls-files '*.go' | grep -v '^vendor/')
13-
14-
default: clean check test build
5+
TAG_NAME := $(shell git tag -l --contains HEAD)
6+
SHA := $(shell git rev-parse HEAD)
7+
VERSION := $(if $(TAG_NAME),$(TAG_NAME),$(SHA))
8+
DATE := $(shell date +'%Y-%m-%d %H:%M:%S')
159

16-
$(DIST_DIR):
17-
mkdir -p $(DIST_DIR)
10+
default: check test build
1811

19-
dependencies:
20-
go mod download
12+
test:
13+
go test -v -cover ./...
2114

2215
clean:
23-
rm -rf dist/ cover.out
24-
25-
test: clean
26-
go test -v -cover ./...
16+
rm -rf dist/
2717

28-
build:
29-
CGO_ENABLED=0 go build -o ${DIST_DIR_AWS_MFA} -ldflags="-s -w \
30-
-X github.com/mmatur/$(BINARY_NAME)/cmd/version.version=$(VERSION) \
31-
-X github.com/mmatur/$(BINARY_NAME)/cmd/version.commit=$(SHA) \
32-
-X github.com/mmatur/$(BINARY_NAME)/cmd/version.date=$(BUILD_DATE)" \
33-
$(CURDIR)/cmd/$(BINARY_NAME)/*.go
18+
build: clean
19+
@echo Version: $(VERSION)
20+
go build -v -ldflags '-X "main.Version=${VERSION}" -X "main.ShortCommit=${SHA}" -X "main.Date=${DATE}"' .
3421

3522
check:
3623
golangci-lint run
3724

38-
fmt:
39-
@gofmt -s -l -w $(GOFILES)
25+
doc:
26+
go run . doc
4027

41-
imports:
42-
@goimports -w $(GOFILES)
28+
package:
29+
goreleaser --skip-publish --skip-validate --rm-dist
4330

44-
.PHONY: clean check test build dependencies fmt imports
31+
package-snapshot:
32+
goreleaser --skip-publish --skip-validate --rm-dist --snapshot

‎cmd/aws-mfa/aws-mfa.go

-9
This file was deleted.

0 commit comments

Comments
 (0)