Skip to content

fix: mixed case labels in configmap store#144

Open
nobbs wants to merge 2 commits into
gepaplexx:mainfrom
nobbs:fix/mixed-case-labels-from-configmap
Open

fix: mixed case labels in configmap store#144
nobbs wants to merge 2 commits into
gepaplexx:mainfrom
nobbs:fix/mixed-case-labels-from-configmap

Conversation

@nobbs

@nobbs nobbs commented Jun 11, 2025

Copy link
Copy Markdown

This PR extends the config map labelstore tests with some mixed case labels. As reported in #136 and possibly also in #133 the multena-proxy does not handle mixed case labels correctly - the spf13/viper library's Unmarshal function simply converts all keys to lower case, thus making it impossible to match against mixed case labels.

This PR fixes the issue by using the Unmarshal function of the go.yaml.in/yaml/v3 library instead of the spf13/viper library's built-in Unmarshal function. Code changes are minimal, so no breaking changes should occur.

Copilot AI review requested due to automatic review settings June 11, 2025 20:26

This comment was marked as outdated.

@nobbs nobbs requested a review from Copilot June 11, 2025 21:32

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes the issue with mixed case labels in the config map by switching from Viper’s built-in unmarshal to the go.yaml.in/yaml/v3 unmarshal method.

  • Added new tests in labelstore_test.go to cover mixed case labels.
  • Updated labelstore.go to use direct file reading and YAML unmarshalling.
  • Updated go.mod and configs/labels.yaml to support the new behavior.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

File Description
labelstore_test.go Added tests for handling mixed case labels.
labelstore.go Refactored config file unmarshalling to use yaml/v3.
go.mod Added yaml/v3 dependency and adjusted dependency ordering.
configs/labels.yaml Introduced mixed case label values for testing.

Comment thread labelstore.go
Comment on lines +70 to 72
err = yaml.Unmarshal(cfgBytes, &c.labels)
if err != nil {
log.Fatal().Err(err).Msg("Error while unmarshalling config file")

Copilot AI Jun 11, 2025

Copy link

Choose a reason for hiding this comment

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

The YAML unmarshalling logic is duplicated in both the Connect method and the OnConfigChange callback. Consider extracting it into a helper function to reduce code duplication and improve maintainability.

Suggested change
err = yaml.Unmarshal(cfgBytes, &c.labels)
if err != nil {
log.Fatal().Err(err).Msg("Error while unmarshalling config file")
err = c.loadLabelsFromConfig(cfg)
if err != nil {
log.Fatal().Err(err).Msg("Error while loading labels from config")

Copilot uses AI. Check for mistakes.
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