Skip to content

Commit

Permalink
feat: get current LogLevel from project.logging.level if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
grv87 committed Apr 2, 2017
1 parent d8928be commit cb07082
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/groovy/org/fidata/gradle/packer/GradlePackerPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ class PackerPluginExtension {
}
static Pattern httpFileNamePattern = ~$/http://\{\{\s*.HTTPIP\s*\}\}(?::\{\{\s*.HTTPPort\s*\}\})?\/([^\s<]*)/$

def List<String> packerLogLevelArgs(project) {
(project.logging.level ?: project.gradle.startParameter.logLevel) <= LogLevel.DEBUG ? ['-debug'] : []
}
def List<String> awsLogLevelArgs(project) {
(project.logging.level ?: project.gradle.startParameter.logLevel) <= LogLevel.DEBUG ? ['--debug'] : []
}

def List findAMI(project, awsEnvironment, region, owners, filters) {
new ByteArrayOutputStream().withStream { os ->
project.exec {
Expand All @@ -63,7 +70,7 @@ class PackerPluginExtension {
[
'aws'
] +
(project.gradle.startParameter.logLevel <= LogLevel.DEBUG ? ['--debug'] : []) +
awsLogLevelArgs(project) +
[
'ec2', 'describe-images',
'--region', region
Expand Down Expand Up @@ -147,7 +154,7 @@ class PackerPluginExtension {
"-only=$buildName"
] +
customVariablesCmdLine +
(project.gradle.startParameter.logLevel <= LogLevel.DEBUG ? ['-debug'] : []) +
packerLogLevelArgs(project) +
[
fileName
]
Expand Down Expand Up @@ -283,7 +290,7 @@ class PackerPluginExtension {
[
'aws'
] +
(project.gradle.startParameter.logLevel <= LogLevel.DEBUG ? ['--debug'] : []) +
awsLogLevelArgs(project) +
[
'ec2', 'deregister-image',
'--region', region,
Expand Down Expand Up @@ -444,7 +451,7 @@ class PackerPluginExtension {
'build',
] +
customVariablesCmdLine +
(project.gradle.startParameter.logLevel <= LogLevel.DEBUG ? ['-debug'] : []) +
packerLogLevelArgs(project) +
[
fileName
]
Expand Down

0 comments on commit cb07082

Please sign in to comment.