Skip to content

Commit

Permalink
Fix issue #18
Browse files Browse the repository at this point in the history
- Fix issue with golang lint
- Update project golang version to 1.18
- Add built-in golangci.yml
- Update project golangci.yml
- Update built-in Makefile versions
- Update project Makefile versions
  • Loading branch information
insidieux committed Jun 20, 2022
1 parent caeeb9d commit d603152
Show file tree
Hide file tree
Showing 25 changed files with 718 additions and 429 deletions.
45 changes: 43 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
run:
timeout: 5m
tests: false
skip-dirs:
- vendor
modules-download-mode: vendor
linters:
enable:
- cyclop
- decorder
- dupl
- gocognit
- godot
- gosec
- grouper
- ifshort
- revive
- wrapcheck
linters-settings:
decorder:
dec-order:
- type
- const
- var
- func
disable-dec-order-check: false
disable-init-func-first-check: false
disable-dec-num-check: false
gosec:
exclude-generated: true
grouper:
const-require-single-const: true
const-require-grouping: true
import-require-single-import: true
import-require-grouping: true
type-require-single-type: true
type-require-grouping: true
var-require-single-var: true
var-require-grouping: true
revive:
rules:
- name: exported
- name: context-as-argument
wrapcheck:
ignoreSigRegexps: []
issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-use-default: false
38 changes: 16 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
override APP_NAME=inizio
override GO_VERSION=1.16
override GOLANGCI_LINT_VERSION=v1.39.0
override SECUREGO_GOSEC_VERSION=v2.7.0
override HADOLINT_VERSION=v2.2.0
override GO_VERSION=1.18
override GOLANGCI_LINT_VERSION=v1.46.2
override SECUREGO_GOSEC_VERSION=2.12.0
override HADOLINT_VERSION=v2.10.0
override WIRE_VERSION=v0.5.0
override PROTOC_VERSION=3.1.33
override MOCKERY_VERSION=v2.7.4
override PROTOC_VERSION=3.3.0
override MOCKERY_VERSION=v2.13.1
override CHANGELOG_GENERATOR_VERSION=1.15.2

GOOS?=$(shell go env GOOS || echo linux)
Expand All @@ -31,14 +31,16 @@ cleanup:
@rm ${PWD}/coverage.out || true
@rm -r ${PWD}/vendor || true

.PHONY: vendor
vendor:
@rm -r ${PWD}/vendor || true
.PHONY: tidy
tidy:
@docker run --rm \
-v ${PWD}:/project \
-w /project \
golang:${GO_VERSION} \
go mod tidy

.PHONY: vendor
vendor:
@docker run --rm \
-v ${PWD}:/project \
-w /project \
Expand All @@ -53,16 +55,6 @@ lint-golangci-lint:
golangci/golangci-lint:${GOLANGCI_LINT_VERSION} \
golangci-lint run -v

.PHONY: lint-golint
lint-golint:
@docker run --rm \
-v ${PWD}:/project \
cytopia/golint \
--set_exit_status \
/project/cmd/...\
/project/internal/...\
/project/pkg/...

.PHONY: lint-gosec
lint-gosec:
@docker run --rm \
Expand All @@ -83,7 +75,6 @@ lint-dockerfile:
.PHONY: lint
lint:
@make lint-golangci-lint
@make lint-golint
@make lint-gosec
@make lint-dockerfile

Expand Down Expand Up @@ -141,9 +132,12 @@ protoc: $(shell find api/protobuf -type f -name "*.proto")
docker run --rm \
-v ${PWD}:/project \
-w /project \
thethingsindustries/protoc:${PROTOC_VERSION} \
rvolosatovs/protoc:${PROTOC_VERSION} \
--proto_path /project \
--go_out=paths=source_relative,plugins=grpc:/project/pkg \
--go_out /project/pkg \
--go_opt=paths=source_relative \
--go-grpc_out=/project/pkg \
--go-grpc_opt=paths=source_relative \
$${file}; \
done

Expand Down
23 changes: 8 additions & 15 deletions build/docker/cmd/inizio/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
ARG GO_VERSION=1.16
ARG ALPINE_VERSION=3.12

### Vendor
FROM golang:${GO_VERSION} as vendor
COPY . /project
WORKDIR /project
RUN go mod tidy && \
go mod vendor
ARG GO_VERSION=1.18
ARG ALPINE_VERSION=3.16

### Build binary
FROM golang:${GO_VERSION} as build-binary
COPY . /project
COPY --from=vendor /project/vendor /project/vendor
WORKDIR /project
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build \
-v \
-mod vendor \
-o /project/bin/inizio \
/project/cmd/inizio
RUN go mod vendor \
&& GOOS=linux GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build \
-v \
-mod vendor \
-o /project/bin/inizio \
/project/cmd/inizio

### Image
FROM alpine:${ALPINE_VERSION} as image
Expand Down
12 changes: 7 additions & 5 deletions build/docker/utils/wire/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
ARG GO_VERSION=1.16

### Image
ARG GO_VERSION=1.18
FROM golang:${GO_VERSION}
ARG WIRE_VERSION=v0.5.0
RUN go get -u -t github.com/google/wire/cmd/wire@${WIRE_VERSION}

RUN go install github.com/google/wire/cmd/[email protected]

ENV GO111MODULE=on
ENV GOFLAGS="-mod=vendor"

ENTRYPOINT ["/go/bin/wire"]
2 changes: 1 addition & 1 deletion cmd/inizio/internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/spf13/cobra"
)

// NewCommand create cobra.Command for main process
// NewCommand create cobra.Command for main process.
func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: `inizio`,
Expand Down
12 changes: 10 additions & 2 deletions cmd/inizio/internal/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ func provideLoggerLevel(v *viper.Viper) (logrus.Level, error) {
if level == `` {
level = logrus.InfoLevel.String()
}
return logrus.ParseLevel(level)
parsed, err := logrus.ParseLevel(level)
if err != nil {
return logrus.InfoLevel, errors.Wrap(err, `failed to parse looger level`)
}
return parsed, nil
}

func provideLogger(level logrus.Level) logrus.FieldLogger {
Expand Down Expand Up @@ -124,7 +128,11 @@ func provideRegistryClients(ctx context.Context, loader *plugins.Loader, path pl
if path == `` {
return nil, errors.New(`plugins path parameter is empty`)
}
return loader.Load(ctx, string(path))
items, err := loader.Load(ctx, string(path))
if err != nil {
return nil, errors.Wrap(err, `failed to load plugins`)
}
return items, nil
}

func provideRegistryFailFast(v *viper.Viper) registryFailFast {
Expand Down
74 changes: 54 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,33 +1,67 @@
module github.com/insidieux/inizio

go 1.16
go 1.18

require (
github.com/AlecAivazis/survey/v2 v2.2.9
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/AlecAivazis/survey/v2 v2.3.5
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/blang/semver/v4 v4.0.0
github.com/drone/envsubst v1.0.2
github.com/golang/protobuf v1.4.3
github.com/drone/envsubst v1.0.3
github.com/golang/protobuf v1.5.2
github.com/google/wire v0.5.0
github.com/hashicorp/go-hclog v0.15.0
github.com/hashicorp/go-plugin v1.4.0
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/mitchellh/copystructure v1.1.1 // indirect
github.com/hashicorp/go-hclog v1.2.1
github.com/hashicorp/go-plugin v1.4.4
github.com/pkg/errors v0.9.1
github.com/rhysd/abspath v0.0.0-20200817132137-9532ba017882
github.com/sirupsen/logrus v1.8.1
github.com/spf13/afero v1.5.1
github.com/spf13/cast v1.3.1
github.com/spf13/cobra v1.1.3
github.com/spf13/afero v1.8.2
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.7.0
github.com/thoas/go-funk v0.7.0
golang.org/x/mod v0.4.2
google.golang.org/grpc v1.36.0
google.golang.org/protobuf v1.25.0
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.7.2
github.com/thoas/go-funk v0.9.2
golang.org/x/mod v0.5.1
google.golang.org/grpc v1.47.0
google.golang.org/protobuf v1.28.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/stretchr/objx v0.1.0 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit d603152

Please sign in to comment.