fix(api): update json package

This commit is contained in:
Lukasz Mierzwa
2026-05-26 11:25:23 +01:00
committed by Łukasz Mierzwa
parent 2bbf868795
commit cb208a487a
3 changed files with 31 additions and 14 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ require (
github.com/fvbommel/sortorder v1.1.0
github.com/go-chi/chi/v5 v5.2.5
github.com/go-chi/cors v1.2.2
github.com/go-json-experiment/json v0.0.0-20260504200034-64a0a05799db
github.com/go-json-experiment/json v0.0.0-20260520185125-572e7c383686
github.com/go-viper/mapstructure/v2 v2.5.0
github.com/google/go-cmp v0.7.0
github.com/hashicorp/golang-lru/v2 v2.0.7
+2 -2
View File
@@ -20,8 +20,8 @@ github.com/go-chi/chi/v5 v5.2.5 h1:Eg4myHZBjyvJmAFjFvWgrqDTXFyOzjj7YIm3L3mu6Ug=
github.com/go-chi/chi/v5 v5.2.5/go.mod h1:X7Gx4mteadT3eDOMTsXzmI4/rwUpOwBHLpAfupzFJP0=
github.com/go-chi/cors v1.2.2 h1:Jmey33TE+b+rB7fT8MUy1u0I4L+NARQlK6LhzKPSyQE=
github.com/go-chi/cors v1.2.2/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
github.com/go-json-experiment/json v0.0.0-20260504200034-64a0a05799db h1:EWTZKWQtY8ZehowJ8hV1E0GJEBiL2a0eJ7Zd/CU448w=
github.com/go-json-experiment/json v0.0.0-20260504200034-64a0a05799db/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg=
github.com/go-json-experiment/json v0.0.0-20260520185125-572e7c383686 h1:NZBJxCpbHS1gzS6xAmyxbJznosZIIPk9IB42v62UvKA=
github.com/go-json-experiment/json v0.0.0-20260520185125-572e7c383686/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg=
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
+28 -11
View File
@@ -3,6 +3,9 @@ package config
import (
"regexp"
"time"
jsonv2 "github.com/go-json-experiment/json"
"github.com/go-json-experiment/json/jsontext"
)
type AlertmanagerCORS struct {
@@ -217,16 +220,30 @@ type configSchema struct {
DefaultAlertmanagers []string `yaml:"defaultAlertmanagers" koanf:"defaultAlertmanagers"`
} `yaml:"silenceForm" koanf:"silenceForm"`
// nolint: maligned
UI struct {
Refresh time.Duration `json:",format:nano"`
HideFiltersWhenIdle bool `yaml:"hideFiltersWhenIdle" koanf:"hideFiltersWhenIdle"`
ColorTitlebar bool `yaml:"colorTitlebar" koanf:"colorTitlebar"`
Theme string `yaml:"theme" koanf:"theme"`
Animations bool `yaml:"animations" koanf:"animations"`
MinimalGroupWidth int `yaml:"minimalGroupWidth" koanf:"minimalGroupWidth"`
AlertsPerGroup int `yaml:"alertsPerGroup" koanf:"alertsPerGroup"`
CollapseGroups string `yaml:"collapseGroups" koanf:"collapseGroups"`
MultiGridLabel string `yaml:"multiGridLabel" koanf:"multiGridLabel"`
MultiGridSortReverse bool `yaml:"multiGridSortReverse" koanf:"multiGridSortReverse"`
UI UIConfig
}
type UIConfig struct {
Refresh time.Duration `json:"Refresh"`
HideFiltersWhenIdle bool `yaml:"hideFiltersWhenIdle" koanf:"hideFiltersWhenIdle"`
ColorTitlebar bool `yaml:"colorTitlebar" koanf:"colorTitlebar"`
Theme string `yaml:"theme" koanf:"theme"`
Animations bool `yaml:"animations" koanf:"animations"`
MinimalGroupWidth int `yaml:"minimalGroupWidth" koanf:"minimalGroupWidth"`
AlertsPerGroup int `yaml:"alertsPerGroup" koanf:"alertsPerGroup"`
CollapseGroups string `yaml:"collapseGroups" koanf:"collapseGroups"`
MultiGridLabel string `yaml:"multiGridLabel" koanf:"multiGridLabel"`
MultiGridSortReverse bool `yaml:"multiGridSortReverse" koanf:"multiGridSortReverse"`
}
func (ui UIConfig) MarshalJSON() ([]byte, error) {
type uiAlias UIConfig
aux := struct {
uiAlias
Refresh int64 `json:"Refresh"`
}{
uiAlias: uiAlias(ui),
Refresh: int64(ui.Refresh),
}
return jsonv2.Marshal(aux, jsontext.EscapeForHTML(true))
}