Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

dolmen
Copy link
Contributor

@dolmen dolmen commented May 12, 2025

Prerequisite: fix CI to run also on Go 1.24. See #3080.

Description

Upgrade module github.com/spf13/viper to v1.20.1

Note that this upgrade also implied to upgrade github.com/mitchellh/mapstructure (nowadays unmaintained: see https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc) to github.com/go-viper/mapstructure/v2.

Motivation and Context

Dependency cleanup.

Module github.com/mitchellh/mapstructure is nowadays unmaintained. See https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc

How Has This Been Tested?

$ go test ./...

Checklist:

  • My change requires a change to the documentation or CHANGELOG.
  • I have updated the documentation/CHANGELOG accordingly.
  • I have created a feature (non-master) branch for my PR.
  • I have written tests for my code changes.

@dolmen dolmen requested a review from a team as a code owner May 12, 2025 13:19
@github-actions github-actions bot added dependencies Pull requests that update a dependency file go labels May 12, 2025
@dolmen dolmen force-pushed the deps-upgrade-viper branch from ae1fbd3 to 1301dd6 Compare May 26, 2025 08:25
@dolmen
Copy link
Contributor Author

dolmen commented May 26, 2025

@tuunit Rebased.

@dolmen dolmen mentioned this pull request May 26, 2025
4 tasks
@dolmen dolmen force-pushed the deps-upgrade-viper branch 2 times, most recently from 0e17dae to 47e9993 Compare May 26, 2025 11:23
@dolmen dolmen marked this pull request as draft May 26, 2025 11:35
@github-actions github-actions bot added the tests label May 26, 2025
@dolmen
Copy link
Contributor Author

dolmen commented May 26, 2025

The remaining test failure is due to a behaviour change between go1.23 and go1.24: this cause a little difference in error output for embedded structs.

Here is the field for which the issue is triggered:

TestOptionSubStruct `yaml:",inline,squash"`

The change required to make the test pass on Go 1.24 (but triggers failure on 1.23): deccea8#diff-e0441f424d3ef336366a50166b308954ebd83d417448de015ae4243f1aab8387R474

I suppose that the go1.24 change comes from CL 606956.

@tuunit Any suggestion on how to handle this?
What about just skipping those tests on Go below 1.24 by adding a //go:build go1.24 at the top of the file (with a verbose comment pointing here)?

@dolmen
Copy link
Contributor Author

dolmen commented May 26, 2025

See also #2628 which was started long ago but got recent commits related to mapstructure.

@tuunit
Copy link
Member

tuunit commented May 26, 2025

@dolmen lets use this PR to upgrade to go1.24 as well. As it now has been out a couple months and has seen its third patch. We should be able to upgrade to go1.24 without unexpected issues.

@dolmen
Copy link
Contributor Author

dolmen commented May 26, 2025

We could instead just disable go 1.23 in CI.

dolmen added 3 commits May 26, 2025 23:46
Note that this upgrade also implied to upgrade github.com/mitchellh/mapstructure
(nowadays unmaintained: https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc)
to github.com/go-viper/mapstructure/v2.
Add a compile guard for Go < 1.24 for the pkg/apis/options/load_test.go
because the LoadYAML test depends on error messages produced by
encoding/json that changed slightly (names of embedded structs are now
reported). As we updated the test for go1.24, the test now fails on
1.23, but just for a slight difference, so we disable the test there.
@tuunit
Copy link
Member

tuunit commented Jul 13, 2025

Replaced by #3116 I added you as a Co-Author

@tuunit tuunit closed this Jul 13, 2025
@dolmen dolmen deleted the deps-upgrade-viper branch August 1, 2025 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file go tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants