Hisoka-X commented on code in PR #9688: URL: https://github.com/apache/seatunnel/pull/9688#discussion_r2365629044
########## seatunnel-api/src/main/java/org/apache/seatunnel/api/metalake/MetalakeConfigUtils.java: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seatunnel.api.metalake; + +import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.JsonNode; +import org.apache.seatunnel.shade.com.typesafe.config.Config; +import org.apache.seatunnel.shade.com.typesafe.config.ConfigList; +import org.apache.seatunnel.shade.com.typesafe.config.ConfigObject; +import org.apache.seatunnel.shade.com.typesafe.config.ConfigValue; +import org.apache.seatunnel.shade.com.typesafe.config.ConfigValueFactory; +import org.apache.seatunnel.shade.com.typesafe.config.ConfigValueType; + +import org.apache.seatunnel.common.utils.PlaceholderUtils; + +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Slf4j +public class MetalakeConfigUtils { + + public static Config getMetalakeConfig(Config jobConfigTmp) { + Config envConfig = jobConfigTmp.getConfig("env"); + boolean metalakeEnabled = + envConfig.hasPath("metalake_enabled") + ? envConfig.getBoolean("metalake_enabled") + : Boolean.parseBoolean( + System.getenv().getOrDefault("METALAKE_ENABLED", "false")); + if (!metalakeEnabled) return jobConfigTmp; + + Config update = jobConfigTmp; + try { + ConfigList sourceList = jobConfigTmp.getList("source"); + update = + update.withValue( + "source", + ConfigValueFactory.fromIterable( + replaceConfigList(sourceList, envConfig))); + } catch (IOException e) { + log.error("Fail to get MetaInfo", e); + } + + try { + ConfigList sinkList = jobConfigTmp.getList("sink"); + update = + update.withValue( + "sink", + ConfigValueFactory.fromIterable( + replaceConfigList(sinkList, envConfig))); + } catch (IOException e) { + log.error("Fail to get MetaInfo", e); + } + + try { + ConfigList sinkList = jobConfigTmp.getList("transform"); + update = + update.withValue( + "transform", + ConfigValueFactory.fromIterable( + replaceConfigList(sinkList, envConfig))); + } catch (IOException e) { + log.error("Fail to get MetaInfo", e); + } Review Comment: I found this part can be refactor too. ########## seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/PlaceholderUtils.java: ########## @@ -48,4 +50,18 @@ public static String replacePlaceholders( matcher.appendTail(result); return result.toString(); } + + public static String replacePlaceholders(String input, JsonNode json) { Review Comment: ```suggestion public static String replacePlaceholders(String input, JsonNode supportedValues) { ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
