-
Notifications
You must be signed in to change notification settings - Fork 0
feat(queueconfig): add YAML-backed Store and wire gateway Land validation #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
behinddwalls
merged 4 commits into
main
from
wua/yaml-queueconfig-and-gateway-validation
May 28, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Example queue configurations consumed by the gateway YAML store. | ||
| # The gateway loads this file at startup; QUEUE_CONFIG_PATH must point | ||
| # at it. Each entry maps a queue name to the VCS repository + target | ||
| # branch and selects the extension implementations used downstream. | ||
| queues: | ||
| - name: test-queue | ||
| vcs_type: git | ||
| vcs_address: git@github.com:uber/submitqueue.git | ||
| target: main | ||
| build_runner: buildkite.com/uber/submitqueue-ci | ||
| change_provider: github | ||
| merge_checker: github | ||
| land_provider: github | ||
|
|
||
| - name: e2e-test-queue | ||
| vcs_type: git | ||
| vcs_address: git@github.com:uber/submitqueue.git | ||
| target: main | ||
| build_runner: buildkite.com/uber/submitqueue-ci | ||
| change_provider: github | ||
| merge_checker: github | ||
| land_provider: github |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| load("@rules_go//go:def.bzl", "go_library") | ||
|
|
||
| go_library( | ||
| name = "mock", | ||
| srcs = ["queueconfig_mock.go"], | ||
| importpath = "github.com/uber/submitqueue/extension/queueconfig/mock", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| "//entity", | ||
| "@org_uber_go_mock//gomock", | ||
| ], | ||
| ) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| load("@rules_go//go:def.bzl", "go_library", "go_test") | ||
|
|
||
| go_library( | ||
| name = "yaml", | ||
| srcs = ["yaml.go"], | ||
| importpath = "github.com/uber/submitqueue/extension/queueconfig/yaml", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| "//entity", | ||
| "//extension/queueconfig", | ||
| "@in_gopkg_yaml_v3//:yaml_v3", | ||
| ], | ||
| ) | ||
|
|
||
| go_test( | ||
| name = "yaml_test", | ||
| srcs = ["yaml_test.go"], | ||
| embed = [":yaml"], | ||
| deps = [ | ||
| "//extension/queueconfig", | ||
| "@com_github_stretchr_testify//assert", | ||
| "@com_github_stretchr_testify//require", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // Copyright (c) 2025 Uber Technologies, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| // Package yaml provides a YAML-file-backed implementation of | ||
| // queueconfig.Store. The file is read once at construction time and held | ||
| // in memory; the file is not watched for changes. | ||
| package yaml | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/uber/submitqueue/entity" | ||
| "github.com/uber/submitqueue/extension/queueconfig" | ||
| yamlv3 "gopkg.in/yaml.v3" | ||
| ) | ||
|
|
||
| // fileContents is the top-level YAML schema. A configuration file is a | ||
| // single document with a "queues" key holding a list of QueueConfig. | ||
| type fileContents struct { | ||
| Queues []entity.QueueConfig `yaml:"queues"` | ||
| } | ||
|
|
||
| // Store is a queueconfig.Store backed by an in-memory snapshot of a YAML | ||
| // file. Construct via NewStore. Safe for concurrent reads. | ||
| type Store struct { | ||
| byName map[string]entity.QueueConfig | ||
| all []entity.QueueConfig | ||
| } | ||
|
|
||
| // NewStore reads queue configurations from the YAML file at path and | ||
| // returns a Store. If the file omits the top-level "queues" key, it is | ||
| // treated as an empty queue list. | ||
| // Returns an error if the file is unreadable, malformed, contains a queue | ||
| // with an empty name, or contains duplicate queue names. | ||
| func NewStore(path string) (Store, error) { | ||
| data, err := os.ReadFile(path) | ||
| if err != nil { | ||
| return Store{}, fmt.Errorf("failed to read queue config file %q: %w", path, err) | ||
| } | ||
|
|
||
| var contents fileContents | ||
| if err := yamlv3.Unmarshal(data, &contents); err != nil { | ||
| return Store{}, fmt.Errorf("failed to parse queue config file %q: %w", path, err) | ||
| } | ||
|
albertywu marked this conversation as resolved.
|
||
|
|
||
| byName := make(map[string]entity.QueueConfig, len(contents.Queues)) | ||
| for _, q := range contents.Queues { | ||
| if q.Name == "" { | ||
| return Store{}, fmt.Errorf("queue config in %q has empty name", path) | ||
| } | ||
| if _, dup := byName[q.Name]; dup { | ||
| return Store{}, fmt.Errorf("queue config in %q has duplicate name %q", path, q.Name) | ||
| } | ||
| byName[q.Name] = q | ||
| } | ||
|
|
||
| all := make([]entity.QueueConfig, len(contents.Queues)) | ||
| copy(all, contents.Queues) | ||
|
|
||
| return Store{byName: byName, all: all}, nil | ||
| } | ||
|
|
||
| // Get returns the configuration for the named queue, or queueconfig.ErrNotFound. | ||
| func (s Store) Get(_ context.Context, name string) (entity.QueueConfig, error) { | ||
| cfg, ok := s.byName[name] | ||
| if !ok { | ||
| return entity.QueueConfig{}, queueconfig.ErrNotFound | ||
| } | ||
| return cfg, nil | ||
| } | ||
|
|
||
| // List returns a copy of all configured queues in file order. | ||
| func (s Store) List(_ context.Context) ([]entity.QueueConfig, error) { | ||
| out := make([]entity.QueueConfig, len(s.all)) | ||
| copy(out, s.all) | ||
| return out, nil | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.