class TrinoCatalogProjection
Mirrors catalogs -> trino_catalog_registry, in the format the plugin reads.
Reference: baleia-trino-catalog-store v0.2.1 Database.java (SELECT_ALL), CatalogRow.java (validation), docker/initdb/01-schema.sql (CHECKs).
Constants
- SENSITIVE_KEYS
- WRITER
Public Class Methods
Source
# File app/services/trino_catalog_projection.rb, line 50 def self.native_nessie?(catalog) catalog.catalog_type == "nessie" && catalog.nessie_api_mode == "native" end
Whether this Nessie catalog uses the native /api/v2 access model.
A class method because sensitive_property_values (also class-level) needs it to decide whether a bearer token applies.
@param catalog [Catalog] the catalog being projected @return [Boolean]
# File app/services/trino_catalog_projection.rb, line 64 def initialize(cluster_name: ENV.fetch("TRINO_CLUSTER_NAME", "default")) @cluster_name = cluster_name end
Creates the projection for a cluster name.
@param cluster_name [String] the Trino cluster name
# File app/services/trino_catalog_projection.rb, line 57 def self.secret_file_name(catalog, property_key) "catalog-#{catalog.id}-#{property_key.gsub('.', '_')}" end
File name mounted by baleia — MUST match the ref in #connector_properties byte-for-byte. Derived from the same key the ref uses (dot→underscore, hyphen preserved).
# File app/services/trino_catalog_projection.rb, line 23 def self.sensitive_property_values(catalog) values = {} credential = catalog.catalog_credential if credential&.oauth2? values["iceberg.rest-catalog.oauth2.credential"] = "#{credential.client_id}:#{credential.secret}" end # A native-Nessie catalog authenticates with a bearer token. It goes # through the same masking path as every other secret, so the plaintext # never reaches the registry's JSON column. if native_nessie?(catalog) && credential&.auth_method == "bearer_static" values["iceberg.nessie-catalog.authentication.token"] = credential.secret end # The .select on SENSITIVE_KEYS below drops a blank token, so the type and # the token cannot diverge: nessie_bearer? gates the type on exactly the # same "bearer_static with a present secret" condition. values.merge!(catalog.resolve_s3_credentials) values.select { |key, value| SENSITIVE_KEYS.include?(key) && value.present? } .transform_values(&:to_s) end
Sensitive {trino_property_key => plaintext_value} for a catalog, BEFORE masking. Single source of truth for what goes into the Secret mounted by baleia: #connector_properties masks each entry as @baleia-secret and TrinoSecretMaterializer writes each entry under #secret_file_name —refs and Secret keys can no longer diverge. STS calls AssumeRole here (session credentials are always fresh).
Public Instance Methods
Source
# File app/services/trino_catalog_projection.rb, line 69 def sync_all! cluster_id = ensure_cluster! active = Catalog.includes(:catalog_credential).map do |catalog| upsert(cluster_id, catalog) catalog.trino_catalog_name end # A catalog removed from the application becomes a soft delete, like the # plugin's DROP CATALOG. Deleting the row would leave Trino without a trace # of the catalog. TrinoCatalogRegistry .where(cluster_id: cluster_id, enabled: true) .where.not(catalog_name: active) .update_all(enabled: false, updated_by: WRITER, updated_at: Time.current) end
Upserts every catalog into the registry and soft-deletes removed ones.