Skip to content

Commit

Permalink
chore: regular properties instead of raw fields used (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
augi authored Aug 2, 2021
1 parent 0e0da0b commit ce81795
Show file tree
Hide file tree
Showing 12 changed files with 232 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ class ComposeExecutor {
void executeWithCustomOutput(OutputStream os, Boolean ignoreExitValue, Boolean noAnsi, Boolean captureStderr, String... args) {
def settings = this.settings
def er = exec.exec { ExecSpec e ->
if (settings.dockerComposeWorkingDirectory) {
e.setWorkingDir(settings.dockerComposeWorkingDirectory)
if (settings.dockerComposeWorkingDirectory.isPresent()) {
e.setWorkingDir(settings.dockerComposeWorkingDirectory.get().asFile)
}
e.environment = settings.environment
def finalArgs = [settings.executable]
finalArgs.addAll(settings.composeAdditionalArgs)
e.environment = settings.environment.get()
def finalArgs = [settings.executable.get()]
finalArgs.addAll(settings.composeAdditionalArgs.get())
if (noAnsi) {
if (version >= VersionNumber.parse('1.28.0')) {
finalArgs.addAll(['--ansi', 'never'])
} else if (version >= VersionNumber.parse('1.16.0')) {
finalArgs.add('--no-ansi')
}
}
finalArgs.addAll(settings.useComposeFiles.collectMany { ['-f', it].asCollection() })
finalArgs.addAll(settings.useComposeFiles.get().collectMany { ['-f', it].asCollection() })
String pn = settings.projectName
if (pn) {
finalArgs.addAll(['-p', pn])
Expand All @@ -73,7 +73,7 @@ class ComposeExecutor {
}
if (!ignoreExitValue && er.exitValue != 0) {
def stdout = os != null ? os.toString().trim() : "N/A"
throw new RuntimeException("Exit-code ${er.exitValue} when calling ${settings.executable}, stdout: $stdout")
throw new RuntimeException("Exit-code ${er.exitValue} when calling ${settings.executable.get()}, stdout: $stdout")
}
}

Expand Down Expand Up @@ -149,20 +149,20 @@ class ComposeExecutor {
}

Iterable<String> getServiceNames() {
if (!settings.startedServices.empty) {
if(settings.includeDependencies)
if (!settings.startedServices.get().empty) {
if(settings.includeDependencies.get())
{
def dependentServices = getDependentServices(settings.startedServices).toList()
[*settings.startedServices, *dependentServices].unique()
def dependentServices = getDependentServices(settings.startedServices.get()).toList()
[*settings.startedServices.get(), *dependentServices].unique()
}
else
{
settings.startedServices
settings.startedServices.get()
}
} else if (version >= VersionNumber.parse('1.6.0')) {
execute('config', '--services').readLines()
} else {
def composeFiles = settings.useComposeFiles.empty ? getStandardComposeFiles() : getCustomComposeFiles()
def composeFiles = settings.useComposeFiles.get().empty ? getStandardComposeFiles() : getCustomComposeFiles()
composeFiles.collectMany { composeFile ->
def compose = (Map<String, Object>) (new Yaml().load(fileOps.file(composeFile).text))
// if there is 'version' on top-level then information about services is in 'services' sub-tree
Expand Down Expand Up @@ -193,7 +193,7 @@ class ComposeExecutor {
}

Iterable<File> getCustomComposeFiles() {
settings.useComposeFiles.collect {
settings.useComposeFiles.get().collect {
def f = fileOps.file(it)
if (!f.exists()) {
throw new IllegalArgumentException("Custom Docker Compose file not found: $f")
Expand Down
Loading

0 comments on commit ce81795

Please sign in to comment.