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

.NET Core provider: Selecting only empty label key-values is unclear. #6

Closed
jimmyca15 opened this issue Jan 24, 2019 · 10 comments
Closed
Assignees
Labels
.NET Config Provider Issues related to the AppConfig .NET Core configuration provider.
Milestone

Comments

@jimmyca15
Copy link
Member

Some of the key-values in my configuration store's have multiple labels. For example I have the key-value "abc" which exists with an empty label and also with a label named "someLabel".

I wanted to use the .NET Core config provider to query the key-values with an empty label. For some reason I was expecting key-values with a null label to always take priority. What I found was that when I accessed configuration["abc"] it returned the value of the abc key-value in the "someLabel" label.

Then I tried to figure out how to query only empty label key-values with the provider but it wasn't as easy as I would have liked. I need to call

            builder.AddAzconfig(o => {
                o.ConnectWithManagedIdentity("https://mystore.azconfig.io");
                o.Use("*", "\0"); // This selects key-values with the empty label.
            });

I believe we need to make the empty label filter a constant within the provider and perhaps add documentation to the method which describes that this constant should be used to select only key-values that have the empty label.

@jimmyca15 jimmyca15 added the .NET Config Provider Issues related to the AppConfig .NET Core configuration provider. label Jan 24, 2019
@zhenlan
Copy link
Contributor

zhenlan commented Jan 25, 2019

This is because we load everything by default and while we put them in a dictionary, the last one wins.

Don't o.Use("*", "") or o.Use("*", null) work for empty label?

Yes, we should have predefined KeyFilter.Any and LabelFilter.Empty.

Do we like to have a helper function below too?

public AzconfigOptions UseLabel(string labelFilter, DateTimeOffset? preferredDateTime = null)

@zhenlan
Copy link
Contributor

zhenlan commented Jan 25, 2019

@yijiamicrosoft probably can help on this.

@jimmyca15
Copy link
Member Author

I think the helper function might just overpopulate the code. I would opt for the LabelFilter.Empty and a mention in the method's documentation of when to use that constant.

@zhenlan
Copy link
Contributor

zhenlan commented Jan 25, 2019

Sounds good. And KeyFilter.Any?

@jimmyca15
Copy link
Member Author

@zhenlan I like that idea.

@zhenlan
Copy link
Contributor

zhenlan commented Jan 25, 2019

We have a weird behavior currently

  • If a user does not call Use(...) at all, we default to load all labels.
  • If a user simply calls Use("*"), we default to load empty label only.

I think this partially contributes to the unexpected results @jimmyca15 described at the beginning of this thread. From users' perspective, it's not very useful to let different labels just step on each other and have an underminstic result.

Therefore, I think we should change our default behavior to only load empty label when Use(...) is not called. Thoughts?

@Yiming-Jia
Copy link
Contributor

@jimmyca15 @zhenlan I'll send out a PR to change default behavior (user doesn't call Use(...)) to load \0 labels.

@jimmyca15
Copy link
Member Author

I'm not opposed to that. We can also describe that behavior in the method summary.

Another concern is that we currently don't allow "*" in label filters. We throw an ArgumentException if any character is a "*". This might be outdated, and we should probably support the ability to do .Use(KeyFilter.Any, LabelFilter.Any)

@jimmyca15 jimmyca15 reopened this Jan 26, 2019
@Yiming-Jia
Copy link
Contributor

Yiming-Jia commented Jan 26, 2019

Talked with @zhenlan, if we put LabelFilter.Any, the behavior becomes unpredictable right now. We might want to constrain user not using *.

@zhenlan zhenlan added this to the Preview milestone Jan 29, 2019
@zhenlan
Copy link
Contributor

zhenlan commented Feb 5, 2019

This is fixed.

@zhenlan zhenlan closed this as completed Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Config Provider Issues related to the AppConfig .NET Core configuration provider.
Projects
None yet
Development

No branches or pull requests

3 participants