mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2026-01-07 13:07:22 +00:00
Add extension to OpenMetadata (#11786)
* Add extension to OpenMetadata * Typo Comment * remove log
This commit is contained in:
parent
be57a6d86a
commit
79d6d0bcd3
@ -327,3 +327,5 @@ web:
|
||||
changeEventConfig:
|
||||
omUri: ${OM_URI:- "http://localhost:8585"} #openmetadata in om uri for eg http://localhost:8585
|
||||
|
||||
extensionConfiguration:
|
||||
extensions: ${OM_EXTENSIONS:-[]}
|
||||
|
||||
@ -66,6 +66,8 @@ import org.jdbi.v3.core.Jdbi;
|
||||
import org.jdbi.v3.core.statement.SqlLogger;
|
||||
import org.jdbi.v3.core.statement.StatementContext;
|
||||
import org.jdbi.v3.sqlobject.SqlObjects;
|
||||
import org.openmetadata.schema.api.configuration.extension.Extension;
|
||||
import org.openmetadata.schema.api.configuration.extension.ExtensionConfiguration;
|
||||
import org.openmetadata.schema.api.security.AuthenticationConfiguration;
|
||||
import org.openmetadata.schema.api.security.AuthorizerConfiguration;
|
||||
import org.openmetadata.schema.auth.SSOAuthMechanism;
|
||||
@ -76,6 +78,7 @@ import org.openmetadata.service.events.scheduled.ReportsHandler;
|
||||
import org.openmetadata.service.exception.CatalogGenericExceptionMapper;
|
||||
import org.openmetadata.service.exception.ConstraintViolationExceptionMapper;
|
||||
import org.openmetadata.service.exception.JsonMappingExceptionMapper;
|
||||
import org.openmetadata.service.extension.OpenMetadataExtension;
|
||||
import org.openmetadata.service.fernet.Fernet;
|
||||
import org.openmetadata.service.jdbi3.CollectionDAO;
|
||||
import org.openmetadata.service.jdbi3.locator.ConnectionAwareAnnotationSqlLocator;
|
||||
@ -209,6 +212,27 @@ public class OpenMetadataApplication extends Application<OpenMetadataApplication
|
||||
OpenMetadataAssetServlet assetServlet = new OpenMetadataAssetServlet("/assets", "/", "index.html");
|
||||
String pathPattern = "/" + '*';
|
||||
environment.servlets().addServlet("static", assetServlet).addMapping(pathPattern);
|
||||
|
||||
registerExtensions(catalogConfig, environment, jdbi);
|
||||
}
|
||||
|
||||
private void registerExtensions(OpenMetadataApplicationConfig catalogConfig, Environment environment, Jdbi jdbi) {
|
||||
ExtensionConfiguration extensionConfiguration = catalogConfig.getExtensionConfiguration();
|
||||
if (extensionConfiguration != null) {
|
||||
for (Extension extension : extensionConfiguration.getExtensions()) {
|
||||
try {
|
||||
OpenMetadataExtension omExtension =
|
||||
Class.forName(extension.getClassName())
|
||||
.asSubclass(OpenMetadataExtension.class)
|
||||
.getConstructor()
|
||||
.newInstance();
|
||||
omExtension.init(catalogConfig, environment, jdbi);
|
||||
LOG.info("[OmExtension] Registering Extension: {}", extension.getClassName());
|
||||
} catch (Exception ex) {
|
||||
LOG.error("[OmExtension] Failed in registering Extension {}", extension.getClassName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerSamlHandlers(OpenMetadataApplicationConfig catalogConfig, Environment environment)
|
||||
|
||||
@ -26,6 +26,7 @@ import lombok.Setter;
|
||||
import org.openmetadata.api.configuration.ApplicationConfiguration;
|
||||
import org.openmetadata.api.configuration.ChangeEventConfiguration;
|
||||
import org.openmetadata.schema.api.configuration.events.EventHandlerConfiguration;
|
||||
import org.openmetadata.schema.api.configuration.extension.ExtensionConfiguration;
|
||||
import org.openmetadata.schema.api.configuration.pipelineServiceClient.PipelineServiceClientConfiguration;
|
||||
import org.openmetadata.schema.api.fernet.FernetConfiguration;
|
||||
import org.openmetadata.schema.api.security.AuthenticationConfiguration;
|
||||
@ -93,6 +94,9 @@ public class OpenMetadataApplicationConfig extends Configuration {
|
||||
@JsonProperty("email")
|
||||
private SmtpSettings smtpSettings;
|
||||
|
||||
@JsonProperty("extensionConfiguration")
|
||||
private ExtensionConfiguration extensionConfiguration;
|
||||
|
||||
@Valid
|
||||
@NotNull
|
||||
@JsonProperty("web")
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2021 Collate
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,m
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openmetadata.service.extension;
|
||||
|
||||
import io.dropwizard.setup.Environment;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jdbi.v3.core.Jdbi;
|
||||
import org.openmetadata.service.OpenMetadataApplicationConfig;
|
||||
|
||||
@Slf4j
|
||||
public class NoOpExtension implements OpenMetadataExtension {
|
||||
@Override
|
||||
public void init(OpenMetadataApplicationConfig catalogConfig, Environment environment, Jdbi jdbi) {
|
||||
/* Success */
|
||||
LOG.info("Registered NoOp Extension");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package org.openmetadata.service.extension;
|
||||
|
||||
import io.dropwizard.setup.Environment;
|
||||
import org.jdbi.v3.core.Jdbi;
|
||||
import org.openmetadata.service.OpenMetadataApplicationConfig;
|
||||
|
||||
public interface OpenMetadataExtension {
|
||||
void init(OpenMetadataApplicationConfig catalogConfig, Environment environment, Jdbi jdbi);
|
||||
}
|
||||
@ -197,9 +197,12 @@ public final class CollectionRegistry {
|
||||
/** Compile a list of REST collections based on Resource classes marked with {@code Collection} annotation */
|
||||
private static List<CollectionDetails> getCollections() {
|
||||
Reflections reflections = new Reflections("org.openmetadata.service.resources");
|
||||
Reflections privateReflections = new Reflections("io.services.resources");
|
||||
|
||||
// Get classes marked with @Collection annotation
|
||||
Set<Class<?>> collectionClasses = reflections.getTypesAnnotatedWith(Collection.class);
|
||||
// Get classes marked in other
|
||||
collectionClasses.addAll(privateReflections.getTypesAnnotatedWith(Collection.class));
|
||||
List<CollectionDetails> collections = new ArrayList<>();
|
||||
for (Class<?> cl : collectionClasses) {
|
||||
CollectionDetails cd = getCollection(cl);
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
{
|
||||
"$id": "https://open-metadata.org/schema/entity/configuration/extensionConfiguration.json",
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "ExtensionConfiguration",
|
||||
"description": "This schema defines the OpenMetadata Extensions Configuration.",
|
||||
"type": "object",
|
||||
"javaType": "org.openmetadata.schema.api.configuration.extension.ExtensionConfiguration",
|
||||
"definitions": {
|
||||
"extension": {
|
||||
"javaType": "org.openmetadata.schema.api.configuration.extension.Extension",
|
||||
"description": "Extension Class to Register in OM",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"className": {
|
||||
"description": "Class Name for the Extension Service.",
|
||||
"type": "string"
|
||||
},
|
||||
"parameters": {
|
||||
"javaType": "org.openmetadata.schema.api.configuration.extension.ExtensionParameters",
|
||||
"description": "Additional parameters for extension initialization.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
".{1,}": { "type": "string" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["className"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"extensions": {
|
||||
"description": "Extension Class to Register in OM",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/extension"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user