Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[I-57] Upgrade to Go 1.18 #58

Merged
merged 5 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
echo "VERSION=$VERSION" >> $GITHUB_ENV
- uses: actions/setup-go@v2
with:
go-version: '1.17'
go-version: '1.18'
- name: Get OS and arch info
run: |
GOOSARCH=${{matrix.goosarch}}
Expand Down
33 changes: 20 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ^1.17
go-version: ^1.18
id: go

- name: Checkout code
Expand All @@ -33,36 +33,43 @@ jobs:
path-to-lcov: coverage.lcov

vet:
name: go vet and lint
name: go vet and statuscheck
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ^1.16
go-version: ^1.18
id: go

- name: Checkout code
uses: actions/checkout@v3

- name: Get dependencies
- name: go vet
run: |
go get -v -t -d ./...
go get -u golang.org/x/lint/golint
- name: go vet
run: go vet ./...
go vet ./...

- name: go lint
run: golint -set_exit_status ./...
- name: go staticcheck
uses: dominikh/staticcheck-action@v1.1.0
with:
version: "2022.1"
install-go: false

golangci:
name: golangci lint check
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ^1.18
id: go

- name: Checkout code
uses: actions/checkout@v3

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.43.0
version: v1.45.2
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.16-alpine3.12
ARG GO_VERSION=1.18-alpine3.15
ARG FROM_IMAGE=alpine:3.15

FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS builder
Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ else
endif

BASE_PACKAGE_NAME = github.com/omegion/ssh-manager
LDFLAGS = -ldflags "-X $(BASE_PACKAGE_NAME)/internal/info.Version=$(GIT_VERSION)"
LDFLAGS = -ldflags "-buildid=$(GIT_VERSION)"
BUFFER := $(shell mktemp)
REPORT_DIR = dist/report
COVER_PROFILE = $(REPORT_DIR)/coverage.out
Expand All @@ -25,11 +25,15 @@ lint:
gofmt -l . | tee $(BUFFER)
@! test -s $(BUFFER)
go vet ./...
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0

# golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
@golangci-lint --version
golangci-lint run
go get -u golang.org/x/lint/golint
golint -set_exit_status ./...

# Statuscheck
go install honnef.co/go/tools/cmd/staticcheck@2022.1
staticcheck ./...

.PHONY: test
test:
Expand All @@ -45,7 +49,7 @@ cut-tag:
git push origin $(version)

.PHONY: release
release: build-for-container
release:
@echo "Releasing $(GIT_VERSION)"
docker build -t ssh-manager .
docker tag ssh-manager:latest omegion/ssh-manager:$(GIT_VERSION)
Expand Down
15 changes: 10 additions & 5 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package cmd

import (
"fmt"

"github.com/go-asset/build"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/omegion/ssh-manager/internal/info"
)

// AppName is the name of the Application.
var AppName = "ssh-manager" //nolint:gochecknoglobals // versioning

// Version prints version/build.
func Version() *cobra.Command {
cmd := &cobra.Command{
Use: "version",
Short: "Print the version/build number",
RunE: func(cmd *cobra.Command, args []string) error {
log.Infoln(fmt.Sprintf("%s %s\n", info.AppName, info.Version))
version, err := build.ReadVersion(AppName)
if err != nil {
return err
}

log.Infoln(version)

return nil
},
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module github.com/omegion/ssh-manager

go 1.17
go 1.18

require (
github.com/aws/aws-sdk-go-v2 v1.16.2
github.com/aws/aws-sdk-go-v2/config v1.15.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.26.3
github.com/go-asset/build v0.0.1
github.com/golang/mock v1.6.0
github.com/omegion/cobra-commander v0.10.0
github.com/omegion/go-aws-v2-interface v0.3.0
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.4.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.1
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704
)

Expand Down Expand Up @@ -59,7 +60,7 @@ require (
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.63.0 // indirect
Expand Down