Conversation
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the SSO configuration to use a map-based structure for providers instead of an array, enabling proper parsing with Viper. The changes remove custom environment variable expansion logic in favor of Viper's built-in functionality.
- Changed
Providersfrom[]SSOProviderConfigtomap[string]SSOProviderConfig - Replaced custom environment variable expansion with Viper's native binding mechanism using custom key delimiters
- Updated configuration file format and tests to reflect the new map-based structure
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| sso.yaml | Restructured providers from array to map format, sanitized example email address, and added quotes to client credentials |
| internal/config/sso.go | Changed Providers to map type, removed custom env expansion logic, added Viper key delimiter and env binding functions |
| internal/service/sso/service_test.go | Updated test fixtures to use map-based provider configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for _, v := range c.Providers { | ||
| if v.Name == name { | ||
| return &v | ||
| } | ||
| } |
There was a problem hiding this comment.
Returning a pointer to the loop variable v is problematic because the address of the loop variable remains the same across iterations. The returned pointer will point to the last value assigned to v after the loop completes, not the matched provider. Since Providers is now a map, you can directly return a pointer to the map value using &c.Providers[name] or use a different approach to safely return the provider.
| for _, v := range c.Providers { | |
| if v.Name == name { | |
| return &v | |
| } | |
| } | |
| if c == nil { | |
| return nil | |
| } | |
| if p, ok := c.Providers[name]; ok { | |
| return &p | |
| } |
No description provided.