Skip to content

Commit

Permalink
fix: Fix issues with inputs of provisioners
Browse files Browse the repository at this point in the history
* Provisioners were handled incorrectly, so after the change
in provisioners' source files task was still marked
as up-to-date

* Chef `encrypted_data_bag_secret_path` configuration
is a file, not directory

Closes #14
  • Loading branch information
grv87 committed Mar 16, 2017
1 parent 68c82bf commit 9eed898
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/main/groovy/org/fidata/gradle/packer/GradlePackerPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -239,20 +239,22 @@ class GradlePackerPlugin implements Plugin<Project> {

if (InputJSON.containsKey('provisioners'))
for (p in InputJSON['provisioners']) {
processedTasks = [:]
if (p.containsKey('only'))
if (p.containsKey('only')) {
processedTasks = [:]
for (buildName in p['only'])
processedTasks[buildName] = ts[buildName]
else if (p.containsKey('except')) {
for (t in ts)
processedTasks[t.key] = t.value
for (buildName in p['except'])
processedTasks.remove buildName
}
else {
processedTasks = new HashMap(ts)
if (p.containsKey('except'))
for (buildName in p['except'])
processedTasks.remove buildName
}
for (t in processedTasks.values()) {
Map provisioner = new HashMap(p)
for (override in provisioner['override'])
provisioner[override.key] = override.value
if (provisioner.containsKey('override'))
for (override in provisioner['override'][t.buildName])
provisioner[override.key] = override.value
provisioner.remove 'override'

// Shell provisioner
Expand All @@ -274,7 +276,7 @@ class GradlePackerPlugin implements Plugin<Project> {
if (provisioner.containsKey('data_bags_path'))
t.inputs.dir parseString(provisioner['data_bags_path'], variables)
if (provisioner.containsKey('encrypted_data_bag_secret_path'))
t.inputs.dir parseString(provisioner['encrypted_data_bag_secret_path'], variables)
t.inputs.file parseString(provisioner['encrypted_data_bag_secret_path'], variables)
if (provisioner.containsKey('environments_path'))
t.inputs.dir parseString(provisioner['environments_path'], variables)
if (provisioner.containsKey('roles_path'))
Expand All @@ -285,13 +287,13 @@ class GradlePackerPlugin implements Plugin<Project> {
}
if (InputJSON.containsKey('post-processors')) {
Closure processPostProcessors = { p ->
processedTasks = [:]
if (p.containsKey('only'))
if (p.containsKey('only')) {
processedTasks = [:]
for (buildName in p['only'])
processedTasks[buildName] = ts[buildName]
}
else {
for (t in ts)
processedTasks[t.key] = t.value
processedTasks = new HashMap(ts)
if (p.containsKey('except'))
for (buildName in p['except'])
processedTasks.remove buildName
Expand Down

0 comments on commit 9eed898

Please sign in to comment.