Skip to content

fix: config parsing so viper works#294

Merged
gusfcarvalho merged 1 commit intomainfrom
gc-fix-config-parsing
Dec 23, 2025
Merged

fix: config parsing so viper works#294
gusfcarvalho merged 1 commit intomainfrom
gc-fix-config-parsing

Conversation

@gusfcarvalho
Copy link
Contributor

No description provided.

Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
Copilot AI review requested due to automatic review settings December 23, 2025 17:06
@gusfcarvalho gusfcarvalho enabled auto-merge (squash) December 23, 2025 17:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Providers from []SSOProviderConfig to map[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.

Comment on lines +84 to 88
for _, v := range c.Providers {
if v.Name == name {
return &v
}
}
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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
}

Copilot uses AI. Check for mistakes.
@gusfcarvalho gusfcarvalho merged commit 595560e into main Dec 23, 2025
10 checks passed
@gusfcarvalho gusfcarvalho deleted the gc-fix-config-parsing branch December 23, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants