-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/improve-docker-email-setting' in…
…to improve-docker-email-setting # Conflicts: # streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/SettingAlertEmailConfigParams.java # streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/SettingDockerConfigParams.java # streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/SettingController.java # streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/SettingService.java # streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/SettingServiceImpl.java # streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/bean/SettingAlertEmailConfigParamsTest.java # streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/bean/SettingDockerConfigParamsTest.java # streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/SettingServiceTest.java
- Loading branch information
Showing
2 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...k-console-service/src/main/java/org/apache/streampark/console/core/bean/DockerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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.streampark.console.core.bean; | ||
|
||
import org.apache.streampark.console.core.service.SettingService; | ||
|
||
import lombok.Data; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
/** | ||
* The DockerConfig class represents the configuration for an email system. It holds the SMTP host, | ||
* port, from address, username, password, and whether SSL is enabled. | ||
* | ||
* <p>This class also provides a static factory method to create an DockerConfig object from a map | ||
* of settings. | ||
*/ | ||
@Data | ||
@Slf4j | ||
public class DockerConfig { | ||
|
||
private String address; | ||
private String user; | ||
private String password; | ||
private String namespace; | ||
|
||
public static DockerConfig fromSetting() { | ||
try { | ||
DockerConfig dockerConfig = new DockerConfig(); | ||
|
||
dockerConfig.setAddress( | ||
SettingService.SETTINGS | ||
.get(SettingService.KEY_DOCKER_REGISTER_ADDRESS) | ||
.getSettingValue()); | ||
|
||
dockerConfig.setUser( | ||
SettingService.SETTINGS.get(SettingService.KEY_DOCKER_REGISTER_USER).getSettingValue()); | ||
|
||
dockerConfig.setPassword( | ||
SettingService.SETTINGS | ||
.get(SettingService.KEY_DOCKER_REGISTER_PASSWORD) | ||
.getSettingValue()); | ||
|
||
dockerConfig.setNamespace( | ||
SettingService.SETTINGS | ||
.get(SettingService.KEY_DOCKER_REGISTER_NAMESPACE) | ||
.getSettingValue()); | ||
|
||
return dockerConfig; | ||
} catch (Exception e) { | ||
log.warn("Failed to create DockerConfig from settings", e); | ||
} | ||
return null; | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
...rk-console-service/src/main/java/org/apache/streampark/console/core/bean/MavenConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* 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.streampark.console.core.bean; | ||
|
||
import org.apache.streampark.common.conf.CommonConfig; | ||
import org.apache.streampark.common.conf.InternalConfigHolder; | ||
import org.apache.streampark.console.core.entity.Setting; | ||
import org.apache.streampark.console.core.service.SettingService; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import lombok.Data; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* This class represents the Maven configuration for the application. It provides methods to | ||
* retrieve the various Maven configuration options. | ||
*/ | ||
@Data | ||
public class MavenConfig { | ||
|
||
/** File path for Maven settings. */ | ||
private String mvnSettings; | ||
|
||
/** Repository URL for Maven. */ | ||
private String mvnRepository; | ||
|
||
/** User for Maven authentication. */ | ||
private String mvnAuthUser; | ||
|
||
/** Password for Maven authentication. */ | ||
private String mvnAuthPassword; | ||
|
||
/** */ | ||
public static MavenConfig fromSetting() { | ||
MavenConfig mavenConfig = new MavenConfig(); | ||
Map<String, Setting> settings = SettingService.SETTINGS; | ||
if (settings.containsKey(CommonConfig.MAVEN_SETTINGS_PATH().key())) { | ||
mavenConfig.setMvnSettings( | ||
settings.get(CommonConfig.MAVEN_SETTINGS_PATH().key()).getSettingValue()); | ||
} | ||
|
||
if (settings.containsKey(CommonConfig.MAVEN_REMOTE_URL().key())) { | ||
mavenConfig.setMvnRepository( | ||
settings.get(CommonConfig.MAVEN_REMOTE_URL().key()).getSettingValue()); | ||
} | ||
|
||
if (settings.containsKey(CommonConfig.MAVEN_AUTH_USER().key())) { | ||
mavenConfig.setMvnAuthUser( | ||
settings.get(CommonConfig.MAVEN_AUTH_USER().key()).getSettingValue()); | ||
} | ||
|
||
if (settings.containsKey(CommonConfig.MAVEN_AUTH_PASSWORD().key())) { | ||
mavenConfig.setMvnAuthPassword( | ||
settings.get(CommonConfig.MAVEN_AUTH_PASSWORD().key()).getSettingValue()); | ||
} | ||
|
||
return mavenConfig; | ||
} | ||
|
||
/** | ||
* Updates the internal configuration of Maven based on the assigned instance variables. If the | ||
* instance variables mvnSettings, mvnRepository, mvnAuthUser, or mvnAuthPassword have non-empty | ||
* values, they will be updated in the internal configuration. | ||
*/ | ||
public void updateConfig() { | ||
|
||
if (StringUtils.isNotBlank(mvnSettings)) { | ||
InternalConfigHolder.set(CommonConfig.MAVEN_SETTINGS_PATH(), mvnSettings); | ||
} | ||
|
||
if (StringUtils.isNotBlank(mvnRepository)) { | ||
InternalConfigHolder.set(CommonConfig.MAVEN_REMOTE_URL(), mvnRepository); | ||
} | ||
|
||
if (StringUtils.isNotBlank(mvnAuthUser)) { | ||
InternalConfigHolder.set(CommonConfig.MAVEN_AUTH_USER(), mvnAuthUser); | ||
} | ||
|
||
if (StringUtils.isNotBlank(mvnAuthPassword)) { | ||
InternalConfigHolder.set(CommonConfig.MAVEN_AUTH_PASSWORD(), mvnAuthPassword); | ||
} | ||
} | ||
} |