Skip to content

Commit

Permalink
Fix default file creation on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmorley committed Oct 26, 2016
1 parent 9bff81b commit 883f40b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 97 deletions.
24 changes: 17 additions & 7 deletions lib/workup/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
12 changes: 7 additions & 5 deletions lib/workup/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
85 changes: 0 additions & 85 deletions omnibus/Gemfile.lock

This file was deleted.

0 comments on commit 883f40b

Please sign in to comment.