Skip to content

Backport config type fixes to 1.20.x #2005

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
merged 2 commits into from
Mar 26, 2025
Merged

Conversation

sagikazarmark
Copy link
Collaborator

@sagikazarmark sagikazarmark commented Mar 26, 2025

See #2003
See #2007

@sagikazarmark sagikazarmark added the kind/bug Something isn't working label Mar 26, 2025
@sagikazarmark sagikazarmark marked this pull request as ready for review March 26, 2025 17:26
@sagikazarmark sagikazarmark requested a review from Copilot March 26, 2025 17:26
Copy link

@Copilot 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 backports config type fixes to the 1.20.x branch by changing how the configuration type is determined and how configurations are read and merged. Key changes include:

  • Removing explicit checks for config type in ReadConfig and MergeConfig and deferring this to unmarshalReader.
  • Replacing direct assignment of a new map with reading into a temporary config map.
  • Introducing new tests that set a dummy config file to infer configuration type from its file extension.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
viper.go Refactors ReadConfig, MergeConfig, and unmarshalReader to improve config type handling.
viper_test.go Adds tests for ReadConfig and MergeConfig when a config file is set to derive config type.
Comments suppressed due to low confidence (1)

viper.go:1673

  • Consider checking the error returned by buf.ReadFrom(in) to handle potential read failures.
buf.ReadFrom(in)

@sagikazarmark sagikazarmark merged commit 9568cfc into v1.20.x Mar 26, 2025
43 checks passed
@sagikazarmark sagikazarmark deleted the fix-config-type-backport branch March 26, 2025 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants