Download and store Planet order metadata on startup #120
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-119-planet-order-sync"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #119
Adds support for downloading Planet order metadata from the Orders API and persisting it to the nidus-sync database.
Changes
db/migrations/00173_planet_order.sql— newplanet_ordertable with the full JSON response from the Planet API alongside core metadata columns (id, name, state, source_type, created_on, last_modified, error_hints, last_message). UsesON CONFLICTupsert for safe re-syncing.planet/client.go—Syncerstruct wrapping the go-planet client. ReadsPLANET_API_TOKENfrom the environment.ListOrders()calls the same Orders API endpoint as the CLIorder listcommand.StartSync()is the top-level entry point called from main.go.planet/store.go—StorerwithUpsertOrderfor a single row andSyncAllfor full refresh. On sync it first lists orders, then callsGetOrderon each for the full detail response (including products, tools, hosting config, etc.) and stores the raw JSON.main.go— wiresplanet.StartSyncas a short-lived background goroutine afterplatform.StartAll.go.mod/go.sum— addedreplacedirective pointing to the local./go-planetdirectory.Notes
PLANET_API_TOKENis unset, the code skips initialization gracefully.ListOrders,GetOrder) — no changes to go-planet were required for this first draft.Future considerations
Looks like this PR got dirty from some proposed other changes you made in other work. You should drop the changes in the PR around flake.nix and go.mod and rebase what remains on the current main.
627e210e0a90d437a45cDone — I dropped the toolchain upgrade and golint CI commits and rebased the planet feature commit cleanly on current main.
Here is what changed:
db/migrations/00173_planet_order.sql,planet/client.go,planet/store.go,main.gowiringgo 1.25.0→go 1.26.3— this is required because the go-planet module itself declaresgo 1.26.3in its go.mod. Not a thing that can be avoided without changes to go-planet.Only 5 files touched, 265 insertions, 1 deletion.
d1e7809852d865fe0b88Updated — pulled the latest go-planet which now declares
go 1.25.0, so there's zero go.mod diff and zero flake.nix changes now. Only 4 actual files changed for the feature plus the go-planet submodule pointer.