-
Notifications
You must be signed in to change notification settings - Fork 33
Support for parsing custom scopes in config file #581
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
Changes from all commits
42aef75
30e93a3
b2ed955
1a694e9
1962e8e
0730918
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ public class DatabricksConfig { | |
| @ConfigAttribute(env = "DATABRICKS_CLIENT_SECRET", auth = "oauth", sensitive = true) | ||
| private String clientSecret; | ||
|
|
||
| @ConfigAttribute(env = "DATABRICKS_SCOPES", auth = "oauth") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It actually wasn't possible to pass scopes through environment variable because Lists weren't parsed correctly, so removing this is not a breaking change. |
||
| @ConfigAttribute(auth = "oauth") | ||
| private List<String> scopes; | ||
|
|
||
| @ConfigAttribute(env = "DATABRICKS_REDIRECT_URL", auth = "oauth") | ||
|
|
@@ -204,6 +204,7 @@ private synchronized DatabricksConfig innerResolve() { | |
| try { | ||
| ConfigLoader.resolve(this); | ||
| ConfigLoader.validate(this); | ||
| sortScopes(); | ||
| ConfigLoader.fixHostIfNeeded(this); | ||
| initHttp(); | ||
| return this; | ||
|
|
@@ -212,6 +213,13 @@ private synchronized DatabricksConfig innerResolve() { | |
| } | ||
| } | ||
|
|
||
| // Sort scopes in-place for better de-duplication in the refresh token cache. | ||
| private void sortScopes() { | ||
| if (scopes != null && !scopes.isEmpty()) { | ||
| java.util.Collections.sort(scopes); | ||
| } | ||
| } | ||
|
|
||
| private void initHttp() { | ||
| if (httpClient != null) { | ||
| return; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question about this big if-else block. This block doesn't have a default else, which throws an error when an unexpected type appears in the config. So is the current code simply ignoring those types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it silently ignores those types. I can't think of a good reason for it to be this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We considered adding a default block that would fail for unexpected types, but rejected it for this PR, as it could lead to breaking changes.