Repository navigation
feat: add ParseComputePlatform and ComputePlatforms - #1187
Merged
panavenue merged 1 commit intoOct 22, 2026
Merged
Conversation
Go "enums" (a named type plus typed constants) are not closed: a string conversion such as ComputePlatform(s) compiles for any s and is only rejected later by NewDialer. Clients that take the platform as a string, notably the Auth Proxy's --compute-platform flag, should not have to copy the list of valid values. - ComputePlatforms() returns all valid values in a stable order (a copy), for help text. - ParseComputePlatform(s) trims whitespace, matches case-insensitively, and returns an error listing the valid values otherwise. - WithComputePlatform stays strict (exact constants only) and its error now lists the valid values too. All three read from one unexported slice. - TestComputePlatformsMatchesInternalSet fails if the public list and internal/tel's allowed label values drift apart. - README mentions the helpers.
kgala2
approved these changes
Oct 22, 2026
panavenue
merged commit Oct 22, 2026
f91dca7
into
feature/client-side-metrics
14 of 15 checks passed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds two small helpers around
ComputePlatformso clients that receive the platform as a string (the Auth Proxy's upcoming--compute-platformflag, config files, env vars) don't have to duplicate the list of valid values.Intended proxy usage:
Why
ComputePlatformfollows the idiomatic Go enum pattern (named type + typed constants). Go enums are not closed:ComputePlatform("anything")and evenWithComputePlatform("anything")compile, and are only rejected whenNewDialervalidates. That runtime check keeps the label's value set closed, but a string-accepting client would otherwise have to hard-code the valid list and keep it in sync by hand. With these helpers the connector stays the single source of truth.Changes
options.go: one unexportedcomputePlatformsslice now backsComputePlatforms(),ParseComputePlatform(), andWithComputePlatform's validation.WithComputePlatformstays strict (exact constants;"AI_STUDIO"is still rejected there) and its error now lists the valid values.ParseComputePlatformis the lenient entry point for user input (trim + case-insensitive).README.md: one paragraph pointing string-accepting clients at the helpers.TestParseComputePlatform: every valid value, case/whitespace variants, rejection of"",unknown,ai-studio,aws; errors list all valid values; every parsed value is accepted byWithComputePlatform.TestComputePlatformsMatchesInternalSet: the public list must equalinternal/tel's allowed label values (excludingunknown), so adding a platform in one place but not the other fails CI (verified: removingai_studiofrom the public list fails with a clear diff). Also checksComputePlatforms()returns a copy.Testing
go test -short -race ./...andgolangci-lint v2.14.0(0 issues).