-
Notifications
You must be signed in to change notification settings - Fork 906
[#12297] feat(secret): Add catalog and schema create-time secrets #12420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 12 commits
b946bd2
0ef0553
e0384fd
b557334
abfc6a0
28d1fff
63a9fb2
cf541f8
4b78ba1
08a4387
bf9ecc9
c9da34a
c32ecdb
4c28c10
761d125
fea00d9
796cd50
c136a49
c44237e
2010fc8
300f240
d5e8785
b4dce2a
b55fc93
e24fe73
b5af53d
603b947
e0b681e
78d2bb9
3527020
6422be2
accb66c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,12 +20,15 @@ | |
|
|
||
| package org.apache.gravitino; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.Map; | ||
| import org.apache.gravitino.annotation.Evolving; | ||
| import org.apache.gravitino.exceptions.NoSuchCatalogException; | ||
| import org.apache.gravitino.exceptions.NoSuchSchemaException; | ||
| import org.apache.gravitino.exceptions.NonEmptySchemaException; | ||
| import org.apache.gravitino.exceptions.SchemaAlreadyExistsException; | ||
| import org.apache.gravitino.secret.SecretBinding; | ||
| import org.apache.gravitino.secret.SecretReference; | ||
|
|
||
| /** | ||
| * The client interface to support schema operations. The server side should use the other one with | ||
|
|
@@ -93,15 +96,48 @@ default boolean schemaExists(String schemaName) { | |
| * need the schema with default values applied, use the {@link #loadSchema(String)} method after | ||
| * creation. | ||
| * | ||
| * <p>Delegates to {@link #createSchema(String, String, Map, Map, Map)} with empty secret maps. | ||
| * | ||
| * @param schemaName The name of the schema. | ||
| * @param comment The comment of the schema. | ||
| * @param properties The properties of the schema. | ||
| * @return The schema as defined by the caller, without all default values. | ||
| * @throws NoSuchCatalogException If the catalog does not exist. | ||
| * @throws SchemaAlreadyExistsException If the schema already exists. | ||
| */ | ||
| default Schema createSchema(String schemaName, String comment, Map<String, String> properties) | ||
| throws NoSuchCatalogException, SchemaAlreadyExistsException { | ||
| return createSchema( | ||
| schemaName, comment, properties, Collections.emptyMap(), Collections.emptyMap()); | ||
| } | ||
|
|
||
| /** | ||
| * Creates a schema with optional secret maps. | ||
| * | ||
| * <p>The default implementation rejects create-time secrets. Implementations that support secrets | ||
| * must override this method. | ||
| * | ||
| * @param schemaName The name of the schema. | ||
| * @param comment The comment of the schema. | ||
| * @param properties The properties of the schema. | ||
| * @param secretBindings optional property key → binding ({@code provider} + {@code plaintext}) | ||
| * for write-through | ||
| * @param secretReferences optional property key → secret locator ({@code provider} plus | ||
| * provider-specific attributes) | ||
| * @return The schema as defined by the caller, without all default values. | ||
| * @throws NoSuchCatalogException If the catalog does not exist. | ||
| * @throws SchemaAlreadyExistsException If the schema already exists. | ||
| * @throws UnsupportedOperationException if create-time secrets are not supported | ||
| */ | ||
| Schema createSchema(String schemaName, String comment, Map<String, String> properties) | ||
| throws NoSuchCatalogException, SchemaAlreadyExistsException; | ||
| default Schema createSchema( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got. Use 'Creating xxx with secrets is not supported' instead.(Consistent with the original code of the project) |
||
| String schemaName, | ||
| String comment, | ||
| Map<String, String> properties, | ||
| Map<String, SecretBinding> secretBindings, | ||
| Map<String, SecretReference> secretReferences) | ||
| throws NoSuchCatalogException, SchemaAlreadyExistsException { | ||
| throw new UnsupportedOperationException("Not implemented"); | ||
| } | ||
|
|
||
| /** | ||
| * Load metadata properties for a schema. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,8 @@ | |
| import org.apache.gravitino.dto.responses.DropResponse; | ||
| import org.apache.gravitino.dto.responses.EntityListResponse; | ||
| import org.apache.gravitino.dto.responses.SchemaResponse; | ||
| import org.apache.gravitino.dto.secret.SecretBindingDTO; | ||
| import org.apache.gravitino.dto.secret.SecretReferenceDTO; | ||
| import org.apache.gravitino.exceptions.NoSuchCatalogException; | ||
| import org.apache.gravitino.exceptions.NoSuchPolicyException; | ||
| import org.apache.gravitino.exceptions.NoSuchSchemaException; | ||
|
|
@@ -56,6 +58,8 @@ | |
| import org.apache.gravitino.policy.Policy; | ||
| import org.apache.gravitino.policy.SupportsPolicies; | ||
| import org.apache.gravitino.rest.RESTUtils; | ||
| import org.apache.gravitino.secret.SecretBinding; | ||
| import org.apache.gravitino.secret.SecretReference; | ||
| import org.apache.gravitino.tag.SupportsTags; | ||
| import org.apache.gravitino.tag.Tag; | ||
|
|
||
|
|
@@ -167,20 +171,35 @@ public String[] listSchemas(String parentSchema) | |
| } | ||
|
|
||
| /** | ||
| * Create a new schema with specified identifier, comment and metadata. | ||
| * Create a new schema with specified identifier, comment, properties, and optional secret maps. | ||
| * | ||
| * @param schemaName The name identifier of the schema. | ||
| * @param comment The comment of the schema. | ||
| * @param properties The properties of the schema. | ||
| * @param secretBindings Optional property key → binding ({@code provider} + {@code plaintext}) | ||
| * for write-through. | ||
| * @param secretReferences Optional property key → secret locator ({@code provider} plus | ||
| * provider-specific attributes). | ||
| * @return The created {@link Schema}. | ||
| * @throws NoSuchCatalogException if the catalog with specified namespace does not exist. | ||
| * @throws SchemaAlreadyExistsException if the schema with specified identifier already exists. | ||
| */ | ||
| @Override | ||
| public Schema createSchema(String schemaName, String comment, Map<String, String> properties) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do u modify the method signature? We should keep backwards compatibility.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your review. This issue has been fixed. |
||
| public Schema createSchema( | ||
| String schemaName, | ||
| String comment, | ||
| Map<String, String> properties, | ||
| Map<String, SecretBinding> secretBindings, | ||
| Map<String, SecretReference> secretReferences) | ||
| throws NoSuchCatalogException, SchemaAlreadyExistsException { | ||
|
|
||
| SchemaCreateRequest req = new SchemaCreateRequest(schemaName, comment, properties); | ||
| SchemaCreateRequest req = | ||
| new SchemaCreateRequest( | ||
| schemaName, | ||
| comment, | ||
| properties, | ||
| SecretBindingDTO.fromSecretBindings(secretBindings), | ||
| SecretReferenceDTO.fromSecretReferences(secretReferences)); | ||
| req.validate(); | ||
|
|
||
| SchemaResponse resp = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,8 @@ | |
| import org.apache.gravitino.policy.PolicyChange; | ||
| import org.apache.gravitino.policy.PolicyContent; | ||
| import org.apache.gravitino.policy.PolicyOperations; | ||
| import org.apache.gravitino.secret.SecretBinding; | ||
| import org.apache.gravitino.secret.SecretReference; | ||
| import org.apache.gravitino.tag.Tag; | ||
| import org.apache.gravitino.tag.TagChange; | ||
| import org.apache.gravitino.tag.TagOperations; | ||
|
|
@@ -137,9 +139,13 @@ public Catalog createCatalog( | |
| Catalog.Type type, | ||
| String provider, | ||
| String comment, | ||
| Map<String, String> properties) | ||
| Map<String, String> properties, | ||
| Map<String, SecretBinding> secretBindings, | ||
| Map<String, SecretReference> secretReferences) | ||
| throws NoSuchMetalakeException, CatalogAlreadyExistsException { | ||
| return getMetalake().createCatalog(catalogName, type, provider, comment, properties); | ||
| return getMetalake() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your review. This issue has been fixed. |
||
| .createCatalog( | ||
| catalogName, type, provider, comment, properties, secretBindings, secretReferences); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could u use complete error message here? For example.
xxxx is not implemented.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got. Use 'Creating xxx with secrets is not supported' instead.(Consistent with the original code of the project)