Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
dec1ed84e3 | |||
a7324d7c32 | |||
c081c06239 | |||
87f25fc35b |
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -12,21 +12,21 @@ jobs:
|
|||||||
name: Main Process
|
name: Main Process
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
GO_VERSION: '1.20'
|
GO_VERSION: stable
|
||||||
GOLANGCI_LINT_VERSION: v1.53.3
|
GOLANGCI_LINT_VERSION: v1.58.0
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
# https://github.com/marketplace/actions/checkout
|
# https://github.com/marketplace/actions/checkout
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
# https://github.com/marketplace/actions/setup-go-environment
|
# https://github.com/marketplace/actions/setup-go-environment
|
||||||
- name: Set up Go ${{ env.GO_VERSION }}
|
- name: Set up Go ${{ env.GO_VERSION }}
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
|
6
.github/workflows/go-cross.yml
vendored
6
.github/workflows/go-cross.yml
vendored
@ -15,17 +15,17 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [ 1.19, 1.x ]
|
go-version: [ stable, oldstable ]
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# https://github.com/marketplace/actions/checkout
|
# https://github.com/marketplace/actions/checkout
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# https://github.com/marketplace/actions/setup-go-environment
|
# https://github.com/marketplace/actions/setup-go-environment
|
||||||
- name: Set up Go ${{ matrix.go-version }}
|
- name: Set up Go ${{ matrix.go-version }}
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
|
|
||||||
|
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@ -9,47 +9,47 @@ jobs:
|
|||||||
name: Release Process
|
name: Release Process
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
GO_VERSION: '1.20'
|
GO_VERSION: stable
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
# https://github.com/marketplace/actions/checkout
|
# https://github.com/marketplace/actions/checkout
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
# https://github.com/marketplace/actions/setup-go-environment
|
# https://github.com/marketplace/actions/setup-go-environment
|
||||||
- name: Set up Go ${{ env.GO_VERSION }}
|
- name: Set up Go ${{ env.GO_VERSION }}
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
- name: dockerhub-login
|
- name: dockerhub-login
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: ghcr-login
|
- name: ghcr-login
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: traefiker
|
username: traefiker
|
||||||
password: ${{ secrets.GHCR_TOKEN }}
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
# https://goreleaser.com/ci/actions/
|
# https://goreleaser.com/ci/actions/
|
||||||
- name: Run GoReleaser
|
- name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: goreleaser/goreleaser-action@v5
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: release --rm-dist
|
args: release --clean
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO }}
|
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO }}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
run:
|
run:
|
||||||
timeout: 2m
|
timeout: 2m
|
||||||
skip-files: []
|
|
||||||
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
govet:
|
govet:
|
||||||
@ -74,7 +73,8 @@ linters:
|
|||||||
- forbidigo
|
- forbidigo
|
||||||
- gochecknoglobals
|
- gochecknoglobals
|
||||||
- gochecknoinits
|
- gochecknoinits
|
||||||
- goerr113
|
- err113
|
||||||
|
- mnd
|
||||||
- gomnd
|
- gomnd
|
||||||
- gosec
|
- gosec
|
||||||
- lll
|
- lll
|
||||||
@ -90,7 +90,7 @@ linters:
|
|||||||
|
|
||||||
issues:
|
issues:
|
||||||
exclude-use-default: false
|
exclude-use-default: false
|
||||||
max-per-linter: 0
|
max-issues-per-linter: 0
|
||||||
max-same-issues: 0
|
max-same-issues: 0
|
||||||
exclude:
|
exclude:
|
||||||
- 'package-comments: should have a package comment'
|
- 'package-comments: should have a package comment'
|
||||||
|
@ -20,7 +20,7 @@ The optional `env` query parameter can be set to `true` to add the environment v
|
|||||||
|
|
||||||
#### `/api`
|
#### `/api`
|
||||||
|
|
||||||
Returns the whoami information as JSON.
|
Returns the whoami information (and some extra information) as JSON.
|
||||||
|
|
||||||
The optional `env` query parameter can be set to `true` to add the environment variables to the response.
|
The optional `env` query parameter can be set to `true` to add the environment variables to the response.
|
||||||
|
|
||||||
|
8
app.go
8
app.go
@ -31,7 +31,7 @@ const (
|
|||||||
var upgrader = websocket.Upgrader{
|
var upgrader = websocket.Upgrader{
|
||||||
ReadBufferSize: 1024,
|
ReadBufferSize: 1024,
|
||||||
WriteBufferSize: 1024,
|
WriteBufferSize: 1024,
|
||||||
CheckOrigin: func(r *http.Request) bool {
|
CheckOrigin: func(_ *http.Request) bool {
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ func init() {
|
|||||||
flag.StringVar(&cert, "cert", "", "give me a certificate")
|
flag.StringVar(&cert, "cert", "", "give me a certificate")
|
||||||
flag.StringVar(&key, "key", "", "give me a key")
|
flag.StringVar(&key, "key", "", "give me a key")
|
||||||
flag.StringVar(&ca, "cacert", "", "give me a CA chain, enforces mutual TLS")
|
flag.StringVar(&ca, "cacert", "", "give me a CA chain, enforces mutual TLS")
|
||||||
flag.StringVar(&port, "port", getEnv("WHOAMI_PORT_NUMBER", "8080"), "give me a port number")
|
flag.StringVar(&port, "port", getEnv("WHOAMI_PORT_NUMBER", "80"), "give me a port number")
|
||||||
flag.StringVar(&name, "name", os.Getenv("WHOAMI_NAME"), "give me a name")
|
flag.StringVar(&name, "name", os.Getenv("WHOAMI_NAME"), "give me a name")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ func main() {
|
|||||||
Handler: mux,
|
Handler: mux,
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ca) > 0 {
|
if ca != "" {
|
||||||
server.TLSConfig = setupMutualTLS(ca)
|
server.TLSConfig = setupMutualTLS(ca)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ func whoamiHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
queryParams := r.URL.Query()
|
queryParams := r.URL.Query()
|
||||||
|
|
||||||
wait := queryParams.Get("wait")
|
wait := queryParams.Get("wait")
|
||||||
if len(wait) > 0 {
|
if wait != "" {
|
||||||
duration, err := time.ParseDuration(wait)
|
duration, err := time.ParseDuration(wait)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
time.Sleep(duration)
|
time.Sleep(duration)
|
||||||
|
6
go.mod
6
go.mod
@ -1,5 +1,7 @@
|
|||||||
module github.com/traefik/whoami
|
module github.com/traefik/whoami
|
||||||
|
|
||||||
go 1.20
|
go 1.21
|
||||||
|
|
||||||
require github.com/gorilla/websocket v1.4.2
|
require github.com/gorilla/websocket v1.5.1
|
||||||
|
|
||||||
|
require golang.org/x/net v0.25.0 // indirect
|
||||||
|
6
go.sum
6
go.sum
@ -1,2 +1,4 @@
|
|||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
|
||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
|
||||||
|
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||||
|
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||||
|
Reference in New Issue
Block a user