-
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
Conversation
54ffcc4 to
782d3c9
Compare
782d3c9 to
f1b8d08
Compare
f1b8d08 to
42aef75
Compare
| @ConfigAttribute(env = "DATABRICKS_CLIENT_SECRET", auth = "oauth", sensitive = true) | ||
| private String clientSecret; | ||
|
|
||
| @ConfigAttribute(env = "DATABRICKS_SCOPES", auth = "oauth") |
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.
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.
Removing the environment variable attribute for consistency with the other SDKs where we are not supporting setting scopes via environment variables.
|
|
||
| @ConfigAttribute(env = "DATABRICKS_SCOPES", auth = "oauth") | ||
| @ConfigAttribute(auth = "oauth") | ||
| private List<String> scopes; |
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.
This is a backward-incompatible change. What's the rationale for removing this environment variable?
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've explained the rationale in this comment: #581 (comment)
databricks-sdk-java/src/main/java/com/databricks/sdk/core/ConfigAttributeAccessor.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/ConfigAttributeAccessor.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/ConfigAttributeAccessor.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/ConfigAttributeAccessor.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/main/java/com/databricks/sdk/core/DatabricksConfig.java
Outdated
Show resolved
Hide resolved
databricks-sdk-java/src/test/java/com/databricks/sdk/core/DatabricksConfigTest.java
Show resolved
Hide resolved
databricks-sdk-java/src/test/java/com/databricks/sdk/core/DatabricksConfigTest.java
Outdated
Show resolved
Hide resolved
| field.set(cfg, seconds > 0 ? Duration.ofSeconds(seconds) : null); | ||
| } else if (field.getType() == ProxyConfig.ProxyAuthType.class) { | ||
| field.set(cfg, ProxyConfig.ProxyAuthType.valueOf(value)); | ||
| } else if (List.class.isAssignableFrom(field.getType())) { | ||
| // Handle List<String> fields (e.g., scopes) |
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.
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
Summary
The Java SDK already had support for custom scopes in all three OAuth flows. It only lacked support for configuring scopes in a config file. This PR covers that gap.
Testing
Tested by loading configurations from a test config file and resolving them.
NO_CHANGELOG=true