Commit c5f4546
authored
Resolve Lakebase .env values in non-interactive
## Summary
- Extract `ResolvePostgresValues()` from `PromptForPostgres()` so it can
be called from the non-interactive code path
- After `--set` values are merged in flags mode, resolve derived
postgres fields (host, databaseName, endpointPath) by calling
`ListPostgresEndpoints` and `ListPostgresDatabases`
- Fixes empty `PGHOST`, `PGDATABASE`, and `LAKEBASE_ENDPOINT` values in
`.env` when using `databricks apps init` with `--set` flags
## Repro command
Rebuild the CLI and run:
```bash
dbx apps init --name event-registration \
--features lakebase \
--set "lakebase.postgres.branch=projects/4de10316-dd6f-4606-878e-fdf3189f6766/branches/br-divine-term-y10rpplr" \
--set "lakebase.postgres.database=projects/4de10316-dd6f-4606-878e-fdf3189f6766/branches/br-divine-term-y10rpplr/databases/db-5vqi-xormgdrr0m" \
--description "Event registration app with Lakebase" \
--run none --profile DEFAULT --version 0.20.0
```
Then see if .env has filled `PGHOST`, `PGDATABASE`, and
`LAKEBASE_ENDPOINT`:
```
DATABRICKS_CONFIG_PROFILE=DEFAULT
PGDATABASE=databricks_postgres
LAKEBASE_ENDPOINT=projects/4de10316-dd6f-4606-878e-fdf3189f6766/branches/br-divine-term-y10rpplr/endpoints/primary
PGHOST=ep-small-sunset-y12mao90.database.us-west-2.staging.cloud.databricks.com
PGPORT=5432
PGSSLMODE=require
DATABRICKS_APP_PORT=8000
DATABRICKS_APP_NAME=event-registration
FLASK_RUN_HOST=localhost
```
## Test plan
- [x] Existing unit tests pass (`go test ./libs/apps/prompt/...
./cmd/apps/...`)
- [x] Manual test: run the repro command above and verify `.env` has
populated values for `PGHOST`, `PGDATABASE`, `LAKEBASE_ENDPOINT`
- [x] Verify interactive mode still works unchanged
This pull request was AI-assisted by Isaac.apps init (#4740)1 parent a228b67 commit c5f4546
File tree
4 files changed
+360
-33
lines changed- cmd/apps
- libs/apps/prompt
4 files changed
+360
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
717 | 717 | | |
718 | 718 | | |
719 | 719 | | |
720 | | - | |
| 720 | + | |
721 | 721 | | |
722 | 722 | | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
723 | 746 | | |
724 | 747 | | |
725 | 748 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
564 | 565 | | |
565 | 566 | | |
566 | 567 | | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | 568 | | |
591 | 569 | | |
592 | 570 | | |
| |||
605 | 583 | | |
606 | 584 | | |
607 | 585 | | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | 586 | | |
616 | 587 | | |
617 | 588 | | |
618 | 589 | | |
619 | 590 | | |
620 | 591 | | |
621 | | - | |
622 | | - | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
623 | 635 | | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
624 | 657 | | |
625 | 658 | | |
626 | 659 | | |
| |||
0 commit comments