class CatalogsController
Manages catalogs: the external systems whose iceberg tables are tracked. Provides the usual CRUD plus sync (re-scan metadata) and verify (test the connection). Every action authorizes with Pundit.
Public Instance Methods
Source
# File app/controllers/catalogs_controller.rb, line 31 def create authorize Catalog @catalog = Catalog.new(catalog_params) if @catalog.save redirect_to @catalog, notice: t("catalogs.notices.created") else @catalog.build_catalog_credential if @catalog.catalog_credential.nil? render :new, status: :unprocessable_content end end
Creates a catalog and redirects to it, or re-renders the form on failure.
Source
# File app/controllers/catalogs_controller.rb, line 59 def destroy authorize @catalog @catalog.destroy redirect_to catalogs_path, notice: t("catalogs.notices.destroyed") end
Destroys the catalog and redirects to the catalogs index.
Source
# File app/controllers/catalogs_controller.rb, line 44 def edit authorize @catalog end
Renders the edit form for a catalog.
Source
# File app/controllers/catalogs_controller.rb, line 8 def index authorize Catalog @catalogs = Catalog.order(:name) end
Lists all catalogs ordered by name.
Source
# File app/controllers/catalogs_controller.rb, line 24 def new authorize Catalog @catalog = Catalog.new @catalog.build_catalog_credential end
Renders the form for creating a catalog, with a fresh credential object.
Source
# File app/controllers/catalogs_controller.rb, line 15 def show authorize @catalog @open_error_count = ErrorEvent.open.catalog_events(@catalog).count tables = @catalog.iceberg_tables tables = tables.active unless params[:inactive].present? @tables = tables.order(:namespace, :name) end
Shows a catalog with its open error count and tables. Active tables by default; the operator can include inactive ones.
Source
# File app/controllers/catalogs_controller.rb, line 66 def sync authorize @catalog MaintenanceOrchestrator.sync_catalog(@catalog.id) redirect_to @catalog, notice: t("catalogs.notices.sync_enqueued") end
Enqueues a metadata re-sync for the catalog and redirects to it.
Source
# File app/controllers/catalogs_controller.rb, line 74 def sync_all authorize Catalog, :sync? Catalog.find_each { |catalog| MaintenanceOrchestrator.sync_catalog(catalog.id) } redirect_to catalogs_path, notice: t("catalogs.notices.sync_all_enqueued") end
Enqueues a metadata re-sync for every catalog. Admin-only (touches every catalog). Stays on the catalog list so the operator keeps their context.
Source
# File app/controllers/catalogs_controller.rb, line 49 def update authorize @catalog if @catalog.update(catalog_params) redirect_to @catalog, notice: t("catalogs.notices.updated") else render :edit, status: :unprocessable_content end end
Updates the catalog and redirects to it, or re-renders the form on failure.
Source
# File app/controllers/catalogs_controller.rb, line 82 def verify authorize @catalog result = @catalog.verify_connection! if result[:ok] redirect_to @catalog, notice: t("catalogs.verify.ok", count: result[:namespace_count], tables: result[:table_count]) else redirect_to @catalog, alert: t("catalogs.verify.failed", error: result[:error]) end end
Verifies the catalog connection and redirects with the outcome as notice or alert.
Source
# File app/controllers/catalogs_controller.rb, line 95 def verify_draft authorize Catalog catalog = Catalog.new(catalog_params) catalog.build_catalog_credential(catalog_params[:catalog_credential_attributes]) if catalog_params[:catalog_credential_attributes] result = catalog.verify_connection! if result[:ok] redirect_back fallback_location: catalogs_path, notice: t("catalogs.verify.ok", count: result[:namespace_count], tables: result[:table_count]) else redirect_back fallback_location: catalogs_path, alert: t("catalogs.verify.failed", error: result[:error]) end end
Tests a catalog connection from form params without persisting. Used by the new/edit form “Test connection” button.