Skip to content
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

The configured key is in uppercase and is converted to lowercase #411

Closed
wpecker opened this issue Nov 7, 2017 · 4 comments
Closed

The configured key is in uppercase and is converted to lowercase #411

wpecker opened this issue Nov 7, 2017 · 4 comments

Comments

@wpecker
Copy link

wpecker commented Nov 7, 2017

The configured key is in uppercase and is converted to lowercase
E.g:

[greenSDK]
   roleArn = "aaaa"
   accessKey = "xxxx"
   accessSecret = "yyyy"

If you pass the following test is normal,

roleArn = viper.GetString ("greenSDK.roleArn")
accessKey = viper.GetString ("greenSDK.accessKey")
accessSecret = viper.GetString ("greenSDK.accessSecret")

If the following way to directly access the map, found in the map key all converted to lowercase
BCfg = viper.GetStringMapString ("greenSDK")

the value is :

map[string]string{"accesssecret":"yyyy", "rolearn":"aaaa", "accesskey":"xxxx"}
@gbbr
Copy link
Contributor

gbbr commented Mar 4, 2019

Nobody cares 😭

gbbr added a commit to DataDog/datadog-agent that referenced this issue Mar 4, 2019
This change makes `apm_config.analyzed_rate_by_service` and
`apm_config.analyzed_spans` entries case insensitive. The reasoning
behind this is that Viper always lower-cases keys in the yaml file, make
it impossible to compare against the orginal value. See spf13/viper#411.
gbbr added a commit to DataDog/datadog-agent that referenced this issue Mar 5, 2019
This change makes `apm_config.analyzed_rate_by_service` and
`apm_config.analyzed_spans` entries case insensitive. The reasoning
behind this is that Viper always lower-cases keys in the yaml file, make
it impossible to compare against the orginal value. See spf13/viper#411.
gbbr added a commit to DataDog/datadog-agent that referenced this issue Mar 5, 2019
…3113)

* pkg/trace/event: make event service & operation matchin insensitive

This change makes `apm_config.analyzed_rate_by_service` and
`apm_config.analyzed_spans` entries case insensitive. The reasoning
behind this is that Viper always lower-cases keys in the yaml file, make
it impossible to compare against the orginal value. See spf13/viper#411.
truthbk pushed a commit to DataDog/datadog-agent that referenced this issue Mar 6, 2019
…3113)

* pkg/trace/event: make event service & operation matchin insensitive

This change makes `apm_config.analyzed_rate_by_service` and
`apm_config.analyzed_spans` entries case insensitive. The reasoning
behind this is that Viper always lower-cases keys in the yaml file, make
it impossible to compare against the orginal value. See spf13/viper#411.
@jose-sanchezm
Copy link

I just discovered this behaviour and I find it very annoying and somewhat weird. Part of my yaml configuration file is a map of key-values that I want to check against:

---
testing:
  enabled: true
  variables:
    myVar1: val1
    myVar2: val2

I expect to get the values of the yaml sub-tree testing.variables as a map and it seems that I can do it with viper.GetStringMapString("testing.variables") however, since it sets them to lowercase I receive an unexpected set of variables. I would say that GetStringMapString should retain the same keys as it finds because if not the configuration file that I'm reading with viper is not at all the configuration file I have in disk.

@sagikazarmark
Copy link
Collaborator

Viper is case-insensitive by default, because this is the way it can match flags, env vars and file keys.

Consider the following: you want TESTING_VARIABLES_MYVAR1 to override the matching key in your config file. But which one do you map it to if you have the following in your file:

testing:
  variables:
    myVar1: val1
    myvar1: val1
    mYvar1: val2

Ultimately config is supposed to be accessed directly by viper.Get commands, or mapped to structs, but I understand that there are cases when case-sensitivity is required.

I've recently hit the same wall as well. I can't really promise anything on this front, except that I will work on it and try to find a solution. PRs and help is always welcome, although in this case I hardly think a PR would be accepted as is 🙂

storjBuildBot pushed a commit to storj/storj that referenced this issue May 19, 2020
Viper has a feature/bug where all YAML config keys are cast
to lowercase (see spf13/viper#260
and spf13/viper#411).
Since we use Viper to load our config values, it doesn't seem
like there's an easy way to preserve case sensitivity for the
access names chosen by users right now. Adding this prompt
should help user experience by clarifying that all access
names must be lowercase.

Change-Id: I47e8344bb0ca7e78458405496f20e78e3c9f9a88
sgsullivan added a commit to liquidweb/liquidweb-cli that referenced this issue Jun 19, 2020
spf13/viper#411

fixes an issue where contexts created with uppercase characters cannot
later be modified.
@sagikazarmark
Copy link
Collaborator

Duplicate of #1014

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

No branches or pull requests

4 participants