MCPcopy Create free account
hub / github.com/PostHog/duckgres / getWarehouseStatus

Method getWarehouseStatus

controlplane/provisioning/api.go:405–444  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

403 effectiveTeamID := req.DefaultTeamID
404 if req.TeamID != 0 {
405 effectiveTeamID = req.TeamID
406 }
407 if req.SchemaName != "" {
408 if effectiveTeamID == 0 {
409 c.JSON(http.StatusBadRequest, gin.H{"error": "schema_name requires team_id"})
410 return
411 }
412 if err := configstore.ValidateOrgTeamSchemaName(req.SchemaName); err != nil {
413 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
414 return
415 }
416 }
417
418 // The catalog is decoupled from the metadata backend: a duckling runs
419 // DuckLake on any of the metadata stores. It must be enabled (a warehouse
420 // without a catalog has nothing to attach).
421 ducklakeEnabled := req.DuckLake != nil && req.DuckLake.Enabled
422 if !ducklakeEnabled {
423 c.JSON(http.StatusBadRequest, gin.H{"error": "ducklake.enabled must be true"})
424 return
425 }
426
427 ds, derr := resolveDataStore(req.DataStore)
428 if derr != nil {
429 c.JSON(http.StatusBadRequest, gin.H{"error": derr.Error()})
430 return
431 }
432
433 // Control-plane-owned bucket naming: for a fresh per-org bucket (s3bucket
434 // with no caller-supplied name) compute the name here, once, and pin it on
435 // the warehouse. It flows to the Duckling CR's spec.dataStore.bucketName
436 // (so the composition provisions exactly this bucket instead of deriving
437 // one) and back to the caller in the response below — so nothing downstream
438 // re-derives the name. No-op when bucketSuffix is unset (the composition
439 // derives, legacy behavior) or when the caller passed an explicit name.
440 if ds.Kind == "s3bucket" && ds.BucketName == "" {
441 ds.BucketName = configstore.DucklingBucketName(orgID, h.bucketSuffix)
442 }
443
444 warehouse := &configstore.ManagedWarehouse{
445 DataStore: ds,
446 DuckLake: configstore.ManagedWarehouseDuckLake{Enabled: ducklakeEnabled},
447 // Stamp the authoritative Duckling CR name: the org ID verbatim. Org IDs

Callers

nothing calls this directly

Calls 3

GetManagedWarehouseMethod · 0.65
GetOrgMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected