-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify config file path by env and fixing arm release (#557)
* Implementing env config file path option * fixing compiling errors * fixing test * fixing test * testing * updating the docs * [Gradle Release Plugin] - new version commit: '3.26.0-snapshot'. * release notes * fixing arm build mirror and ajusting test * new mirrors * formatting * refactoring * clean code
- Loading branch information
Showing
19 changed files
with
318 additions
and
89 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
version=3.25.14-snapshot | ||
version=3.26.0-snapshot |
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
39 changes: 39 additions & 0 deletions
39
src/main/java/com/mageddo/dnsproxyserver/config/application/ConfigFileFinderService.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,39 @@ | ||
package com.mageddo.dnsproxyserver.config.application; | ||
|
||
import com.mageddo.dnsproxyserver.config.dataprovider.ConfigDAOCmdArgs; | ||
import com.mageddo.dnsproxyserver.config.dataprovider.ConfigDAOEnv; | ||
import com.mageddo.dnsproxyserver.config.dataprovider.vo.ConfigEnv; | ||
import com.mageddo.dnsproxyserver.config.dataprovider.vo.ConfigFlag; | ||
import com.mageddo.dnsproxyserver.utils.ObjectUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
import java.nio.file.Path; | ||
|
||
@Slf4j | ||
@Singleton | ||
@RequiredArgsConstructor(onConstructor = @__({@Inject})) | ||
public class ConfigFileFinderService { | ||
|
||
private final ConfigDAOEnv configDAOEnv; | ||
private final ConfigDAOCmdArgs configDAOCmdArgs; | ||
|
||
public Path findPath(){ | ||
final var envConfig = this.configDAOEnv.findRaw(); | ||
final var argsConfig = this.configDAOCmdArgs.findRaw(); | ||
|
||
final var configFilePath = this.findConfigFilePath(envConfig, argsConfig); | ||
|
||
final var workDir = envConfig.getWorkingDir(); | ||
return ConfigPathMapper.build(workDir, configFilePath); | ||
} | ||
|
||
private Path findConfigFilePath(ConfigEnv envConfig, ConfigFlag argsConfig) { | ||
return ObjectUtils.firstNonNullRequiring( | ||
envConfig.getConfigFilePath(), | ||
argsConfig.getConfigFileAsPath() | ||
); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/mageddo/dnsproxyserver/config/application/ConfigPathMapper.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,48 @@ | ||
package com.mageddo.dnsproxyserver.config.application; | ||
|
||
import com.mageddo.dnsproxyserver.config.dataprovider.vo.ConfigFlag; | ||
import com.mageddo.utils.Files; | ||
import com.mageddo.utils.Runtime; | ||
import com.mageddo.utils.Tests; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.nio.file.Path; | ||
|
||
@Slf4j | ||
class ConfigPathMapper { | ||
|
||
public static Path build(Path workDir, Path configFilePath) { | ||
final var path = build0(workDir, configFilePath); | ||
log.debug("status=configPathBuilt, path={}", path); | ||
return path; | ||
} | ||
|
||
private static Path build0(Path workDir, Path configPath) { | ||
if (runningInTestsAndNoCustomConfigPath(configPath)) { | ||
final var file = Files.createTempFileDeleteOnExit("dns-proxy-server-junit", ".json"); | ||
log.trace("status=runningInTests, usingEmptyFile={}", file); | ||
return file; | ||
} | ||
if (workDir != null) { | ||
return workDir | ||
.resolve(configPath) | ||
.toAbsolutePath() | ||
; | ||
} | ||
final var confRelativeToCurrDir = configPath.toAbsolutePath(); | ||
if (Files.exists(confRelativeToCurrDir)) { | ||
return confRelativeToCurrDir; | ||
} | ||
return Runtime.getRunningDir() | ||
.resolve(configPath) | ||
.toAbsolutePath(); | ||
} | ||
|
||
private static boolean runningInTestsAndNoCustomConfigPath(Path configPath) { | ||
return isDefaultConfigFilePath(configPath) && Tests.inTest(); | ||
} | ||
|
||
private static boolean isDefaultConfigFilePath(Path configPath) { | ||
return ConfigFlag.DEFAULT_CONFIG_FILE_AS_PATH.equals(configPath); | ||
} | ||
} |
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
40 changes: 0 additions & 40 deletions
40
src/main/java/com/mageddo/dnsproxyserver/config/dataprovider/ConfigPathBuilder.java
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.