Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
05efa96950 | |||
46d1c2fa1a | |||
9b1db3f461 |
@ -12,8 +12,8 @@ jobs:
|
||||
name: Main Process
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GO_VERSION: 1.17
|
||||
GOLANGCI_LINT_VERSION: v1.46.2
|
||||
GO_VERSION: 1.19
|
||||
GOLANGCI_LINT_VERSION: v1.49.0
|
||||
CGO_ENABLED: 0
|
||||
|
||||
steps:
|
2
.github/workflows/go-cross.yml
vendored
2
.github/workflows/go-cross.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [ 1.17, 1.x ]
|
||||
go-version: [ 1.19, 1.x ]
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
|
||||
steps:
|
||||
|
21
.github/workflows/release.yml
vendored
21
.github/workflows/release.yml
vendored
@ -9,7 +9,7 @@ jobs:
|
||||
name: Release Process
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GO_VERSION: 1.17
|
||||
GO_VERSION: 1.19
|
||||
SEIHON_VERSION: v0.9.0
|
||||
CGO_ENABLED: 0
|
||||
|
||||
@ -27,12 +27,6 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Install Docker image multi-arch builder
|
||||
- name: Install seihon ${{ env.SEIHON_VERSION }}
|
||||
run: |
|
||||
curl -sSfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sh -s -- -b $(go env GOPATH)/bin ${SEIHON_VERSION}
|
||||
seihon --version
|
||||
|
||||
- name: Docker Login
|
||||
env:
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
@ -40,5 +34,14 @@ jobs:
|
||||
run: |
|
||||
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
|
||||
|
||||
- name: Deploy Docker Images (seihon)
|
||||
run: make publish-images
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
# https://goreleaser.com/ci/actions/
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO }}
|
||||
|
@ -1,48 +1,93 @@
|
||||
run:
|
||||
deadline: 2m
|
||||
timeout: 2m
|
||||
skip-files: []
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
check-shadowing: true
|
||||
enable-all: true
|
||||
disable:
|
||||
- fieldalignment
|
||||
gocyclo:
|
||||
min-complexity: 12
|
||||
min-complexity: 16
|
||||
goconst:
|
||||
min-len: 3
|
||||
min-occurrences: 3
|
||||
misspell:
|
||||
locale: US
|
||||
funlen:
|
||||
lines: -1
|
||||
statements: 40
|
||||
gofumpt:
|
||||
extra-rules: true
|
||||
depguard:
|
||||
list-type: blacklist
|
||||
include-go-root: false
|
||||
packages:
|
||||
- github.com/pkg/errors
|
||||
godox:
|
||||
keywords:
|
||||
- FIXME
|
||||
gocritic:
|
||||
enabled-tags:
|
||||
- diagnostic
|
||||
- style
|
||||
- performance
|
||||
disabled-checks:
|
||||
- sloppyReassign
|
||||
- rangeValCopy
|
||||
- octalLiteral
|
||||
- paramTypeCombine # already handle by gofumpt.extra-rules
|
||||
settings:
|
||||
hugeParam:
|
||||
sizeThreshold: 100
|
||||
forbidigo:
|
||||
forbid:
|
||||
- '^print(ln)?$'
|
||||
- '^panic$'
|
||||
- '^spew\.Print(f|ln)?$'
|
||||
- '^spew\.Dump$'
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- deadcode # deprecated
|
||||
- exhaustivestruct # deprecated
|
||||
- golint # deprecated
|
||||
- scopelint # deprecated
|
||||
- ifshort # deprecated
|
||||
- interfacer # deprecated
|
||||
- maligned # deprecated
|
||||
- lll
|
||||
- gosec
|
||||
- nosnakecase # deprecated
|
||||
- scopelint # deprecated
|
||||
- scopelint # deprecated
|
||||
- structcheck # deprecated
|
||||
- varcheck # deprecated
|
||||
- execinquery # not relevant (SQL)
|
||||
- rowserrcheck # not relevant (SQL)
|
||||
- sqlclosecheck # not relevant (SQL)
|
||||
- cyclop # duplicate of gocyclo
|
||||
- dupl
|
||||
- prealloc
|
||||
- exhaustive
|
||||
- exhaustruct
|
||||
- forbidigo
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
- gomnd
|
||||
- wsl
|
||||
- nlreturn
|
||||
- testpackage
|
||||
- paralleltest
|
||||
- tparallel
|
||||
- goerr113
|
||||
- wrapcheck
|
||||
- exhaustive
|
||||
- exhaustivestruct
|
||||
- forbidigo
|
||||
- varnamelen
|
||||
- gomnd
|
||||
- gosec
|
||||
- lll
|
||||
- nilnil
|
||||
- ifshort
|
||||
- exhaustruct
|
||||
- nlreturn
|
||||
- paralleltest
|
||||
- prealloc
|
||||
- testpackage
|
||||
- tparallel
|
||||
- varnamelen
|
||||
- wrapcheck
|
||||
- wsl
|
||||
|
||||
issues:
|
||||
exclude-use-default: false
|
||||
max-per-linter: 0
|
||||
max-same-issues: 0
|
||||
exclude: []
|
||||
exclude:
|
||||
- 'package-comments: should have a package comment'
|
||||
|
78
.goreleaser.yml
Normal file
78
.goreleaser.yml
Normal file
@ -0,0 +1,78 @@
|
||||
project_name: whoami
|
||||
|
||||
builds:
|
||||
- binary: whoami
|
||||
goos:
|
||||
- windows
|
||||
- darwin
|
||||
- linux
|
||||
- freebsd
|
||||
- openbsd
|
||||
goarch:
|
||||
- amd64
|
||||
- '386'
|
||||
- arm
|
||||
- arm64
|
||||
goarm:
|
||||
- '7'
|
||||
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: '386'
|
||||
- goos: openbsd
|
||||
goarch: arm
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^doc:'
|
||||
- '^chore:'
|
||||
- '^chore(deps):'
|
||||
- '^test:'
|
||||
- '^tests:'
|
||||
|
||||
archives:
|
||||
- id: whoami
|
||||
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm}}v{{ .Arm }}{{ end }}'
|
||||
format: tar.gz
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
files:
|
||||
- LICENSE
|
||||
|
||||
dockers:
|
||||
- use: buildx
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
dockerfile: buildx.Dockerfile
|
||||
image_templates:
|
||||
- 'traefik/whoami:dev-amd64'
|
||||
- 'traefik/whoami:latest-amd64'
|
||||
- 'traefik/whoami:{{ .Tag }}-amd64'
|
||||
- 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-amd64'
|
||||
build_flag_templates:
|
||||
- '--pull'
|
||||
- '--label=org.opencontainers.image.created={{.Date}}'
|
||||
- '--label=org.opencontainers.image.title={{.ProjectName}}'
|
||||
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
|
||||
- '--label=org.opencontainers.image.version={{.Version}}'
|
||||
|
||||
- use: buildx
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
dockerfile: buildx.Dockerfile
|
||||
image_templates:
|
||||
- 'traefik/whoami:dev-arm64'
|
||||
- 'traefik/whoami:latest-arm64'
|
||||
- 'traefik/whoami:{{ .Tag }}-arm64'
|
||||
- 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-arm64'
|
||||
build_flag_templates:
|
||||
- '--pull'
|
||||
- '--label=org.opencontainers.image.created={{.Date}}'
|
||||
- '--label=org.opencontainers.image.title={{.ProjectName}}'
|
||||
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
|
||||
- '--label=org.opencontainers.image.version={{.Version}}'
|
||||
|
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
||||
.PHONY: default build image check publish-images
|
||||
.PHONY: default check test build image publish-images
|
||||
|
||||
TAG_NAME := $(shell git tag -l --contains HEAD)
|
||||
|
||||
|
5
app.go
5
app.go
@ -7,7 +7,6 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
@ -85,7 +84,7 @@ func main() {
|
||||
}
|
||||
|
||||
func setupMutualTLS(ca string) *tls.Config {
|
||||
clientCACert, err := ioutil.ReadFile(ca)
|
||||
clientCACert, err := os.ReadFile(ca)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -312,7 +311,7 @@ func healthHandler(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
func getEnv(key, fallback string) string {
|
||||
value := os.Getenv(key)
|
||||
if len(value) == 0 {
|
||||
if value == "" {
|
||||
return fallback
|
||||
}
|
||||
return value
|
||||
|
@ -1,25 +1,17 @@
|
||||
# syntax=docker/dockerfile:1.2
|
||||
FROM golang:1-alpine as builder
|
||||
|
||||
RUN apk --no-cache --no-progress add git ca-certificates tzdata make \
|
||||
&& update-ca-certificates \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
WORKDIR /go/whoami
|
||||
|
||||
# Download go modules
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
RUN GO111MODULE=on GOPROXY=https://proxy.golang.org go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN GOARCH={{ .GoARCH }} GOARM={{ .GoARM }} make build
|
||||
|
||||
# syntax=docker/dockerfile:1.2
|
||||
# Create a minimal container to run a Golang static binary
|
||||
FROM scratch
|
||||
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /go/whoami/whoami .
|
||||
COPY whoami /
|
||||
|
||||
ENTRYPOINT ["/whoami"]
|
||||
EXPOSE 80
|
Reference in New Issue
Block a user