diff --git a/app/vmauth/auth_config.go b/app/vmauth/auth_config.go index 4c7fa1527..19dc197e3 100644 --- a/app/vmauth/auth_config.go +++ b/app/vmauth/auth_config.go @@ -37,7 +37,7 @@ type UserInfo struct { Username string `yaml:"username,omitempty"` Password string `yaml:"password,omitempty"` URLPrefix *URLPrefix `yaml:"url_prefix,omitempty"` - URLMap []URLMap `yaml:"url_map,omitempty"` + URLMaps []URLMap `yaml:"url_map,omitempty"` Headers []Header `yaml:"headers,omitempty"` requests *metrics.Counter @@ -284,7 +284,7 @@ func parseAuthConfig(data []byte) (map[string]*UserInfo, error) { return nil, err } } - for _, e := range ui.URLMap { + for _, e := range ui.URLMaps { if len(e.SrcPaths) == 0 { return nil, fmt.Errorf("missing `src_paths` in `url_map`") } @@ -295,7 +295,7 @@ func parseAuthConfig(data []byte) (map[string]*UserInfo, error) { return nil, err } } - if len(ui.URLMap) == 0 && ui.URLPrefix == nil { + if len(ui.URLMaps) == 0 && ui.URLPrefix == nil { return nil, fmt.Errorf("missing `url_prefix`") } if ui.BearerToken != "" { diff --git a/app/vmauth/auth_config_test.go b/app/vmauth/auth_config_test.go index a18fffd10..d0a2f12ba 100644 --- a/app/vmauth/auth_config_test.go +++ b/app/vmauth/auth_config_test.go @@ -278,7 +278,7 @@ users: `, map[string]*UserInfo{ getAuthToken("foo", "", ""): { BearerToken: "foo", - URLMap: []URLMap{ + URLMaps: []URLMap{ { SrcPaths: getSrcPaths([]string{"/api/v1/query", "/api/v1/query_range", "/api/v1/label/[^./]+/.+"}), URLPrefix: mustParseURL("http://vmselect/select/0/prometheus"), @@ -304,7 +304,7 @@ users: }, getAuthToken("", "foo", ""): { BearerToken: "foo", - URLMap: []URLMap{ + URLMaps: []URLMap{ { SrcPaths: getSrcPaths([]string{"/api/v1/query", "/api/v1/query_range", "/api/v1/label/[^./]+/.+"}), URLPrefix: mustParseURL("http://vmselect/select/0/prometheus"), diff --git a/app/vmauth/target_url.go b/app/vmauth/target_url.go index 3df9a2e80..5f3d0df63 100644 --- a/app/vmauth/target_url.go +++ b/app/vmauth/target_url.go @@ -52,7 +52,7 @@ func createTargetURL(ui *UserInfo, uOrig *url.URL) (*url.URL, []Header, error) { // See https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1554 u.Path = "" } - for _, e := range ui.URLMap { + for _, e := range ui.URLMaps { for _, sp := range e.SrcPaths { if sp.match(u.Path) { return e.URLPrefix.mergeURLs(&u), e.Headers, nil diff --git a/app/vmauth/target_url_test.go b/app/vmauth/target_url_test.go index 84c9e681b..a942dd8ac 100644 --- a/app/vmauth/target_url_test.go +++ b/app/vmauth/target_url_test.go @@ -54,7 +54,7 @@ func TestCreateTargetURLSuccess(t *testing.T) { // Complex routing with `url_map` ui := &UserInfo{ - URLMap: []URLMap{ + URLMaps: []URLMap{ { SrcPaths: getSrcPaths([]string{"/api/v1/query"}), URLPrefix: mustParseURL("http://vmselect/0/prometheus"), @@ -86,7 +86,7 @@ func TestCreateTargetURLSuccess(t *testing.T) { // Complex routing regexp paths in `url_map` ui = &UserInfo{ - URLMap: []URLMap{ + URLMaps: []URLMap{ { SrcPaths: getSrcPaths([]string{"/api/v1/query(_range)?", "/api/v1/label/[^/]+/values"}), URLPrefix: mustParseURL("http://vmselect/0/prometheus"), @@ -132,7 +132,7 @@ func TestCreateTargetURLFailure(t *testing.T) { } f(&UserInfo{}, "/foo/bar") f(&UserInfo{ - URLMap: []URLMap{ + URLMaps: []URLMap{ { SrcPaths: getSrcPaths([]string{"/api/v1/query"}), URLPrefix: mustParseURL("http://foobar/baz"),