From 883f40bb206cd6b4cd8852f203e5c00e364a6166 Mon Sep 17 00:00:00 2001 From: "Morley, Jonathan" Date: Wed, 26 Oct 2016 13:46:54 -0400 Subject: [PATCH] Fix default file creation on windows --- lib/workup/application.rb | 24 +++++++---- lib/workup/helpers.rb | 12 +++--- omnibus/Gemfile.lock | 85 --------------------------------------- 3 files changed, 24 insertions(+), 97 deletions(-) delete mode 100644 omnibus/Gemfile.lock diff --git a/lib/workup/application.rb b/lib/workup/application.rb index b48c6f9..ce86b9b 100644 --- a/lib/workup/application.rb +++ b/lib/workup/application.rb @@ -44,6 +44,19 @@ def initialize(*args) super(*args) end + no_commands do + def chef_lib(description) + log.info description + return_code = Workup::Helpers.silence { yield } + if return_code.zero? + log.debug "OK\n" + else + log.error "Failure\n" + exit return_code + end + end + end + desc 'default', 'Default task' def default chef_zero @@ -53,19 +66,16 @@ def default desc 'chef_zero', 'Create the chef-zero directory' def chef_zero Workup::Helpers.initialize_files(options[:workup_dir]) - policy_path = File.join(options[:workup_dir], 'Policyfile.rb') chefzero_path = File.join(options[:workup_dir], 'chef-zero') - log.info 'Updating lock file... ' - Workup::Helpers.silence { ChefDK::Command::Update.new.run([policy_path]) } - log.debug "OK\n" + chef_lib('Updating lock file... ') do + ChefDK::Command::Update.new.run([policy_path]) + end - log.info 'Creating chef-zero directory... ' - Workup::Helpers.silence do + chef_lib('Creating chef-zero directory... ') do ChefDK::Command::Export.new.run(['--force', policy_path, chefzero_path]) end - log.debug "OK\n" end desc 'workup', 'Run workup' diff --git a/lib/workup/helpers.rb b/lib/workup/helpers.rb index fa4b300..659e604 100755 --- a/lib/workup/helpers.rb +++ b/lib/workup/helpers.rb @@ -55,11 +55,13 @@ def chef_client(client_rb, dry_run = false) end def chef_apply(recipe, dry_run = false) - cmd = [chef_bin('chef-apply'), - '--log_level', 'fatal', - '--minimal-ohai', - '--execute', recipe] + cmd = [chef_bin('chef-apply'), '--log_level', 'fatal', '--minimal-ohai'] cmd << '--why-run' if dry_run + if Gem.win_platform? + cmd.concat(['--execute', "\"#{recipe.gsub(/\n/, ';')}\""]) + else + cmd.concat(['--execute', recipe]) + end execute(*cmd, live_stdout: STDOUT, live_stderr: STDERR) end @@ -73,7 +75,7 @@ def initialize_files(workup_dir) .each do |f| chef_apply %(file '#{File.join(workup_dir, File.basename(f))}' do action :create_if_missing - content %q(#{IO.read(f)}) + content IO.read('#{f}') end) end end diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock deleted file mode 100644 index ec7df24..0000000 --- a/omnibus/Gemfile.lock +++ /dev/null @@ -1,85 +0,0 @@ -GIT - remote: git://github.com/chef/omnibus-software.git - revision: d042e24fa3053ab926bb6a7c066c80e76ad72c94 - branch: ksubrama/ruby23 - specs: - omnibus-software (4.0.0) - chef-sugar (>= 3.4.0) - omnibus (>= 5.5.0) - -GIT - remote: git://github.com/chef/omnibus.git - revision: 61b50f5a20f0930ee977e54cabaff8fe02d3b731 - branch: ksubrama/gcc_investigate - specs: - omnibus (5.5.0) - aws-sdk (~> 2) - chef-sugar (~> 3.3) - cleanroom (~> 1.0) - ffi-yajl (~> 2.2) - license_scout - mixlib-shellout (~> 2.0) - mixlib-versioning - ohai (~> 8.0) - ruby-progressbar (~> 1.7) - thor (~> 0.18) - -GEM - remote: http://rubygems.org/ - specs: - addressable (2.4.0) - aws-sdk (2.6.12) - aws-sdk-resources (= 2.6.12) - aws-sdk-core (2.6.12) - jmespath (~> 1.0) - aws-sdk-resources (2.6.12) - aws-sdk-core (= 2.6.12) - chef-config (12.15.19) - addressable - fuzzyurl - mixlib-config (~> 2.0) - mixlib-shellout (~> 2.0) - chef-sugar (3.4.0) - cleanroom (1.0.0) - ffi (1.9.14) - ffi-yajl (2.3.0) - libyajl2 (~> 1.2) - fuzzyurl (0.9.0) - ipaddress (0.8.3) - jmespath (1.3.1) - libyajl2 (1.2.0) - license_scout (0.1.3) - ffi-yajl (~> 2.2) - mixlib-shellout (~> 2.2) - mixlib-cli (1.7.0) - mixlib-config (2.2.4) - mixlib-log (1.7.1) - mixlib-shellout (2.2.7) - mixlib-versioning (1.1.0) - ohai (8.21.0) - chef-config (>= 12.5.0.alpha.1, < 13) - ffi (~> 1.9) - ffi-yajl (~> 2.2) - ipaddress - mixlib-cli - mixlib-config (~> 2.0) - mixlib-log (>= 1.7.1, < 2.0) - mixlib-shellout (~> 2.0) - plist (~> 3.1) - systemu (~> 2.6.4) - wmi-lite (~> 1.0) - plist (3.2.0) - ruby-progressbar (1.8.1) - systemu (2.6.5) - thor (0.19.1) - wmi-lite (1.0.0) - -PLATFORMS - ruby - -DEPENDENCIES - omnibus! - omnibus-software! - -BUNDLED WITH - 1.13.1