Add Sync Option in OpenmetadataOperations (#17089)

This commit is contained in:
Mohit Yadav 2024-07-19 01:17:12 +05:30 committed by GitHub
parent c7710481b5
commit 8561022c70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,6 +44,8 @@ import org.openmetadata.schema.ServiceEntityInterface;
import org.openmetadata.schema.entity.app.App;
import org.openmetadata.schema.entity.app.AppRunRecord;
import org.openmetadata.schema.entity.services.ingestionPipelines.IngestionPipeline;
import org.openmetadata.schema.settings.Settings;
import org.openmetadata.schema.settings.SettingsType;
import org.openmetadata.schema.system.EventPublisherJob;
import org.openmetadata.schema.type.Include;
import org.openmetadata.sdk.PipelineServiceClientInterface;
@ -60,6 +62,7 @@ import org.openmetadata.service.jdbi3.EntityRepository;
import org.openmetadata.service.jdbi3.IngestionPipelineRepository;
import org.openmetadata.service.jdbi3.ListFilter;
import org.openmetadata.service.jdbi3.MigrationDAO;
import org.openmetadata.service.jdbi3.SystemRepository;
import org.openmetadata.service.jdbi3.locator.ConnectionAwareAnnotationSqlLocator;
import org.openmetadata.service.jdbi3.locator.ConnectionType;
import org.openmetadata.service.migration.api.MigrationWorkflow;
@ -160,6 +163,26 @@ public class OpenMetadataOperations implements Callable<Integer> {
}
}
@Command(
name = "syncEmailFromEnv",
description = "Sync the email configuration from environment variables")
public Integer syncEmailFromEnv() {
try {
parseConfig();
Entity.setCollectionDAO(jdbi.onDemand(CollectionDAO.class));
SystemRepository systemRepository = new SystemRepository();
Settings updatedSettings =
new Settings()
.withConfigType(SettingsType.EMAIL_CONFIGURATION)
.withConfigValue(config.getSmtpSettings());
systemRepository.createOrUpdate(updatedSettings);
return 0;
} catch (Exception e) {
LOG.error("Email Sync failed due to ", e);
return 1;
}
}
@Command(
name = "check-connection",
description =