Skip to content

Commit

Permalink
Create and drop GCS secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
raghunandanbhat committed Jan 7, 2025
1 parent 8d3575c commit 7c3522d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions sql/pg_mooncake--0.0.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,23 @@ BEGIN
))
);
PERFORM nextval('mooncake.secrets_table_seq');
ELSIF type = 'GCS' THEN
keys := ARRAY(SELECT jsonb_object_keys(extra_params));
invalid_keys := ARRAY(SELECT unnest(keys));
IF array_length(invalid_keys, 1) IS NOT NULL THEN
RAISE EXCEPTION 'Invalid extra parameters: %', array_to_string(invalid_keys, ', ')
USING HINT = 'No extra parameters allowed.';
END IF;
INSERT INTO mooncake.secrets VALUES (
name,
type,
coalesce(extra_params->>'SCOPE', ''),
format('CREATE SECRET "duckdb_secret_%s" (TYPE %s, KEY_ID %L SECRET %L', name, type, key_id, secret)||
CASE WHEN extra_params->>'SCOPE' IS NULL THEN '' ELSE format(', SCOPE %L', extra_params->>'SCOPE') END ||
');',
jsonb_build_object('GCS_ACCESS_KEY_ID', key_id, 'GCS_SECRET_ACCESS_KEY', secret)
);
PERFORM nextval('mooncake.secrets_table_seq');
ELSE
RAISE EXCEPTION 'Unsupported secret type: %', type
USING HINT = 'Only secrets of type S3 are supported.';
Expand Down

0 comments on commit 7c3522d

Please sign in to comment.