Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: 'en-US'
early_access: false
reviews:
profile: 'chill'
request_changes_workflow: false
high_level_summary: true
poem: false
review_status: false
collapse_walkthrough: false
auto_review:
enabled: false
drafts: false
chat:
auto_reply: true
3 changes: 3 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'dependencies':
- changed-files:
- any-glob-to-any-file: [go.mod, go.sum, flake.lock, flake.nix]
46 changes: 46 additions & 0 deletions .github/workflows/auto-label.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 'Pull Request Labeler'
on:
pull_request:
types:
- opened
- edited
- synchronize

jobs:
path_labeler:
runs-on: ['ubuntu-24.04']
permissions:
contents: 'read'
pull-requests: 'write'

steps:
- name: 'assign path based labels'
uses: 'actions/labeler@v5'

commit_labeler:
runs-on: ['ubuntu-24.04']
permissions:
contents: 'read'
pull-requests: 'write'

steps:
- name: 'assign commit based labels'
uses: mauroalderete/action-assign-labels@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
maintain-labels-not-matched: true
apply-changes: true
conventional-commits: |
conventional-commits:
- type: 'bug'
nouns: ['FIX', 'Fix', 'fix']
labels: ['bug']
- type: 'feature'
nouns: ['FEAT', 'Feat', 'feat']
labels: ['feature']
- type: 'chore'
nouns: ['CHORE', 'Chore', 'chore']
labels: ['chore']
- type: 'docs'
nouns: ['DOCS', 'Docs', 'docs']
labels: ['documentation']
6 changes: 6 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ jobs:
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
- uses: actions/setup-go@v6
with:
go-version: '^1.21.0'
- run: |
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
go install golang.org/x/tools/cmd/goimports@latest
- uses: pre-commit/action@v3.0.1
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ repos:
hooks:
- id: go-fmt
- id: go-imports
- id: go-lint
- id: golangci-lint
- id: go-mod-tidy
- id: go-critic
29 changes: 23 additions & 6 deletions config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,31 @@ func Read(envPrefix, configFile string) {
viper.AutomaticEnv()

// Allow reading from command line flags
viperAutomaticFlags()
err := viperAutomaticFlags()

// Setup global loglevel
logging.SetLogLevel(viper.GetString(ArgLogLevel))

if err != nil {
log.Error().Err(err).Msg("Failed to process command line arguments.")
}

// Make application cgroups aware
// Needs to happen after the logger has been set up.
maxprocs.Set(maxprocs.Logger(func(format string, a ...interface{}) {
_, err = maxprocs.Set(maxprocs.Logger(func(format string, a ...interface{}) {
log.Info().Msgf(format, a...)
}))

if err != nil {
log.Error().Err(err).Msg("Failed to configure maxprocs to match container CPU quota.")
}
}

// viperAutomaticFlags converts all keys with a default value into command line
// flags. Each flag supports a shorthand form, using the first character. If
// two flags have the same first character, the first flag will have a short
// form, the second one will not.
func viperAutomaticFlags() {
func viperAutomaticFlags() error {
usedShorts := map[string]struct{}{}
getShort := func(k string) string {
short := k[0:1]
Expand Down Expand Up @@ -123,8 +131,17 @@ func viperAutomaticFlags() {
log.Debug().Msgf("%s = %v", key, viper.Get(key))
}

flagSet.Parse(os.Args[1+SkipArgs:])
viper.BindPFlags(flagSet)
defer func() {
ExtraArgs = flagSet.Args()
}()

if err := flagSet.Parse(os.Args[1+SkipArgs:]); err != nil {
return err
}

if err := viper.BindPFlags(flagSet); err != nil {
return err
}

ExtraArgs = flagSet.Args()
return nil
}
3 changes: 1 addition & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
just
graphviz
gotools
go-critic
golint
golangci-lint
];
};
}
Expand Down
56 changes: 31 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,54 +1,60 @@
module github.com/trivago/go-bootstrap

go 1.23.0

toolchain go1.23.4
go 1.24.0

require (
github.com/gin-gonic/gin v1.10.1
github.com/gin-gonic/gin v1.11.0
github.com/rs/zerolog v1.34.0
github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/pflag v1.0.6
github.com/spf13/viper v1.20.1
github.com/stretchr/testify v1.10.0
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
go.uber.org/automaxprocs v1.6.0
)

require (
github.com/bytedance/sonic v1.13.3 // indirect
github.com/bytedance/sonic/loader v0.2.4 // indirect
github.com/cloudwego/base64x v0.1.5 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.14.1 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.26.0 // indirect
github.com/go-viper/mapstructure/v2 v2.3.0 // indirect
github.com/go-playground/validator/v10 v10.27.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/goccy/go-yaml v1.18.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sagikazarmark/locafero v0.9.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.14.0 // indirect
github.com/spf13/cast v1.9.2 // indirect
github.com/quic-go/qpack v0.5.1 // indirect
github.com/quic-go/quic-go v0.54.1 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.3.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.18.0 // indirect
golang.org/x/crypto v0.39.0 // indirect
golang.org/x/net v0.41.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.26.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
go.uber.org/mock v0.6.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/arch v0.21.0 // indirect
golang.org/x/crypto v0.42.0 // indirect
golang.org/x/mod v0.28.0 // indirect
golang.org/x/net v0.44.0 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.29.0 // indirect
golang.org/x/tools v0.37.0 // indirect
google.golang.org/protobuf v1.36.9 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading