diff --git a/.circleci/config.yml b/.circleci/config.yml index d9596d24..df4efa15 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ jobs: # containers with mounted volumes which isn't supported with the docker # executor (even with setup_remote_docker). machine: - image: ubuntu-2004:202201-02 + image: ubuntu-2204:current steps: - checkout - run: sudo service docker restart @@ -18,7 +18,7 @@ jobs: command: sudo rm -rf /usr/local/go # Whenever the Go version is updated here, .promu.yml should also be updated. - go/install: - version: "1.17" + version: "1.18" - run: name: Remove generated code command: make clean @@ -47,15 +47,15 @@ jobs: test: docker: # Whenever the Go version is updated here, .promu.yml should also be updated. - - image: quay.io/prometheus/golang-builder:1.17-base + - image: quay.io/prometheus/golang-builder:1.18-base # maildev containers are for running the email tests against a "real" SMTP server. # See notify/email_test.go for details. - - image: djfarrelly/maildev:1.1.0 + - image: maildev/maildev:1.1.0 name: maildev-noauth entrypoint: bin/maildev command: - -v - - image: djfarrelly/maildev:1.1.0 + - image: maildev/maildev:1.1.0 name: maildev-auth entrypoint: bin/maildev command: @@ -104,13 +104,13 @@ jobs: mixin: docker: # Whenever the Go version is updated here, .promu.yml should also be updated. - - image: quay.io/prometheus/golang-builder:1.17-base + - image: quay.io/prometheus/golang-builder:1.18-base steps: - checkout - - run: cd doc/alertmanager-mixin; go install github.com/monitoring-mixins/mixtool/cmd/mixtool@latest - - run: cd doc/alertmanager-mixin; go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest - - run: cd doc/alertmanager-mixin; go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest - - run: cd doc/alertmanager-mixin; make lint + - run: go install github.com/monitoring-mixins/mixtool/cmd/mixtool@latest + - run: go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest + - run: go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest + - run: make -C doc/alertmanager-mixin lint workflows: version: 2 alertmanager: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 266bac24..ee64fe0c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,8 +3,8 @@ updates: - package-ecosystem: "gomod" directory: "/" schedule: - interval: "weekly" + interval: "monthly" - package-ecosystem: "docker" directory: "/" schedule: - interval: "weekly" + interval: "monthly" diff --git a/.promu.yml b/.promu.yml index e9b56318..1f341c98 100644 --- a/.promu.yml +++ b/.promu.yml @@ -1,7 +1,7 @@ go: # Whenever the Go version is updated here, .travis.yml and # .circle/config.yml should also be updated. - version: 1.17 + version: 1.18 repository: path: github.com/prometheus/alertmanager build: diff --git a/config/notifiers.go b/config/notifiers.go index ab1f9548..95df28db 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -22,6 +22,8 @@ import ( "github.com/pkg/errors" commoncfg "github.com/prometheus/common/config" "github.com/prometheus/common/sigv4" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) var ( @@ -145,6 +147,8 @@ var ( Message: `{{ template "telegram.default.message" . }}`, ParseMode: "HTML", } + + normalizeTitle = cases.Title(language.AmericanEnglish) ) // NotifierConfig contains base options common across all notifier configurations. @@ -189,7 +193,7 @@ func (c *EmailConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { // Header names are case-insensitive, check for collisions. normalizedHeaders := map[string]string{} for h, v := range c.Headers { - normalized := strings.Title(h) + normalized := normalizeTitle.String(h) if _, ok := normalizedHeaders[normalized]; ok { return fmt.Errorf("duplicate header %q in email config", normalized) } diff --git a/go.mod b/go.mod index c4d3efbf..2155e1c7 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/prometheus/alertmanager +go 1.17 + require ( github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 github.com/aws/aws-sdk-go v1.43.11 @@ -37,10 +39,50 @@ require ( go.uber.org/atomic v1.9.0 golang.org/x/mod v0.5.1 golang.org/x/net v0.0.0-20220225172249-27dd8689420f + golang.org/x/text v0.3.7 golang.org/x/tools v0.1.9 gopkg.in/alecthomas/kingpin.v2 v2.2.6 gopkg.in/telebot.v3 v3.0.0 gopkg.in/yaml.v2 v2.4.0 ) -go 1.16 +require ( + github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect + github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect + github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/docker/go-units v0.4.0 // indirect + github.com/go-logfmt/logfmt v0.5.1 // indirect + github.com/go-openapi/analysis v0.21.2 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.20.0 // indirect + github.com/go-stack/stack v1.8.1 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/btree v1.0.0 // indirect + github.com/hashicorp/errwrap v1.0.0 // indirect + github.com/hashicorp/go-immutable-radix v1.0.0 // indirect + github.com/hashicorp/go-msgpack v0.5.3 // indirect + github.com/hashicorp/go-multierror v1.0.0 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/jpillora/backoff v1.0.0 // indirect + github.com/julienschmidt/httprouter v1.3.0 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/miekg/dns v1.1.26 // indirect + github.com/mitchellh/mapstructure v1.4.3 // indirect + github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/procfs v0.7.3 // indirect + github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect + go.mongodb.org/mongo-driver v1.8.3 // indirect + golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect + golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect + golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + google.golang.org/appengine v1.6.6 // indirect + google.golang.org/protobuf v1.26.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/template/template.go b/template/template.go index 2c1b62db..a85da34b 100644 --- a/template/template.go +++ b/template/template.go @@ -27,6 +27,8 @@ import ( "time" "github.com/prometheus/common/model" + "golang.org/x/text/cases" + "golang.org/x/text/language" "github.com/prometheus/alertmanager/asset" "github.com/prometheus/alertmanager/types" @@ -132,7 +134,7 @@ type FuncMap map[string]interface{} var DefaultFuncs = FuncMap{ "toUpper": strings.ToUpper, "toLower": strings.ToLower, - "title": strings.Title, + "title": cases.Title(language.AmericanEnglish).String, // join is equal to strings.Join but inverts the argument order // for easier pipelining in templates. "join": func(sep string, s []string) string {