feat(env): add LookupEnv to Reader interface#72
Merged
Conversation
Introduces a new config/server package with LoadIDPConfig to read OIDC IDP settings (issuer, audience, required scope) from environment variables. Implements absent-vs-empty semantics for CONFIG_SERVER_REQUIRED_SCOPE via an optional lookupEnvReader extension of env.Reader, as needed by the config server. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lookupEnvReader interface and mapReader test double were using Lookupenv (lowercase e), not matching OSReader.LookupEnv — so production readers never satisfied the interface. Fixes the method name to LookupEnv. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Allows *OSReader to satisfy the optional lookupEnvReader interface used by packages that need absent-vs-empty semantics for environment variables (e.g. config/server.LoadIDPConfig). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adding LookupEnv to env.Reader removes the need for a private lookupEnvReader type-assertion in callers. config/server.LoadIDPConfig and its tests are simplified accordingly, and the mock is regenerated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Will live in the enterprise/private repo instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers present variable, present-but-empty, and absent variable to verify absent-vs-empty semantics of the new Reader.LookupEnv method. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
LookupEnv(key string) (string, bool)to theenv.Readerinterface, allowing callers to distinguish an absent variable from one explicitly set to an empty stringOSReaderalready implementedLookupEnvviaos.LookupEnv; the method is now part of the contractenv/mocks/mock_reader.gowith the new methodTest plan
go test ./env/...passesMockReadersatisfiesenv.Reader🤖 Generated with Claude Code