Commit 8f000b1
authored
Wire HostMetadata discovery into DatabricksConfig (#680)
## 🥞 Stacked PR
Use this
[link](https://github.com/databricks/databricks-sdk-java/pull/680/files)
to review incremental changes.
-
[**stack/config-auto-complete-3**](#680)
[[Files
changed](https://github.com/databricks/databricks-sdk-java/pull/680/files)]
---------
## Summary
Wires host metadata discovery into `DatabricksConfig` via a new
package-private `resolveHostMetadata()` helper, mirroring
`Config._resolve_host_metadata()` in the Python SDK.
## Why
Users configuring the SDK today have no way to let it auto-discover
`accountId`, `workspaceId`, or the OIDC endpoint from the host — they
must supply each field manually. The `discoveryUrl` config property
already allows providing a direct OIDC discovery URL;
`resolveHostMetadata()` completes the picture by deriving all three
fields automatically from the host's `/.well-known/databricks-config`
endpoint.
## What changed
### Interface changes
- **`DatabricksConfig.resolveHostMetadata()` (package-private)** — Calls
`getHostMetadata()` on the configured host and back-fills `accountId`,
`workspaceId`, and `discoveryUrl` (with any `{account_id}` placeholder
substituted) if those fields are not already set. Throws
`DatabricksException` if `accountId` cannot be resolved or if no
`oidc_endpoint` is present in the metadata.
### Behavioral changes
- `resolveHostMetadata()` is not called automatically — it is opt-in.
- Existing fields are never overwritten.
### Internal changes
Tests in `DatabricksConfigTest`:
- `testResolveHostMetadataWorkspacePopulatesAllFields` — workspace
populates all three fields.
- `testResolveHostMetadataAccountSubstitutesAccountId` — account host
substitutes `{account_id}` in the OIDC endpoint.
- `testResolveHostMetadataDoesNotOverwriteExistingFields` — existing
fields are not overwritten.
- `testResolveHostMetadataRaisesWhenAccountIdUnresolvable` — raises when
`accountId` cannot be resolved.
- `testResolveHostMetadataRaisesWhenOidcEndpointMissing` — raises when
`oidc_endpoint` is absent.
- `testResolveHostMetadataRaisesOnHttpError` — raises when the
well-known endpoint returns an error.
## How is this tested?
Unit tests in `DatabricksConfigTest` using `FixtureServer`.
NO_CHANGELOG=true1 parent da6adf7 commit 8f000b1
2 files changed
Lines changed: 138 additions & 0 deletions
File tree
- databricks-sdk-java/src
- main/java/com/databricks/sdk/core
- test/java/com/databricks/sdk/core
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
827 | 827 | | |
828 | 828 | | |
829 | 829 | | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
830 | 869 | | |
831 | 870 | | |
832 | 871 | | |
| |||
Lines changed: 99 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
483 | 582 | | |
484 | 583 | | |
485 | 584 | | |
| |||
0 commit comments