MINOR: Fix Hive Metastore Password Encryption (#15329)

This commit is contained in:
Mayur Singal 2024-02-27 16:56:17 +05:30 committed by GitHub
parent e8c0b017ba
commit f00c679f51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 43 additions and 1 deletions

View File

@ -47,6 +47,7 @@ public final class ClassConverterFactory {
Map.entry(BigTableConnection.class, new BigTableConnectionClassConverter()), Map.entry(BigTableConnection.class, new BigTableConnectionClassConverter()),
Map.entry(DatalakeConnection.class, new DatalakeConnectionClassConverter()), Map.entry(DatalakeConnection.class, new DatalakeConnectionClassConverter()),
Map.entry(MysqlConnection.class, new MysqlConnectionClassConverter()), Map.entry(MysqlConnection.class, new MysqlConnectionClassConverter()),
Map.entry(HiveConnection.class, new HiveConnectionClassConverter()),
Map.entry(TrinoConnection.class, new TrinoConnectionClassConverter()), Map.entry(TrinoConnection.class, new TrinoConnectionClassConverter()),
Map.entry(PostgresConnection.class, new PostgresConnectionClassConverter()), Map.entry(PostgresConnection.class, new PostgresConnectionClassConverter()),
Map.entry(DbtGCSConfig.class, new DbtGCSConfigClassConverter()), Map.entry(DbtGCSConfig.class, new DbtGCSConfigClassConverter()),

View File

@ -0,0 +1,41 @@
/*
* 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,
* 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.secrets.converter;
import java.util.List;
import org.openmetadata.schema.services.connections.database.HiveConnection;
import org.openmetadata.schema.services.connections.database.MysqlConnection;
import org.openmetadata.schema.services.connections.database.PostgresConnection;
import org.openmetadata.service.util.JsonUtils;
/** Converter class to get an `DatalakeConnection` object. */
public class HiveConnectionClassConverter extends ClassConverter {
private static final List<Class<?>> CONFIG_SOURCE_CLASSES =
List.of(MysqlConnection.class, PostgresConnection.class);
public HiveConnectionClassConverter() {
super(HiveConnection.class);
}
@Override
public Object convert(Object object) {
HiveConnection hiveConnection = (HiveConnection) JsonUtils.convertValue(object, this.clazz);
tryToConvert(hiveConnection.getMetastoreConnection(), CONFIG_SOURCE_CLASSES)
.ifPresent(hiveConnection::setMetastoreConnection);
return hiveConnection;
}
}

View File

@ -58,6 +58,6 @@ public class ClassConverterFactoryTest {
@Test @Test
void testClassConvertedMapIsNotModified() { void testClassConvertedMapIsNotModified() {
assertEquals(19, ClassConverterFactory.getConverterMap().size()); assertEquals(20, ClassConverterFactory.getConverterMap().size());
} }
} }