Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

NodeConfigCommand should create node_path directory when generating json file #253

Merged
merged 1 commit into from
May 28, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/knife-solo/node_config_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module KnifeSolo
module NodeConfigCommand

def self.load_deps
require 'fileutils'
require 'pathname'
end

Expand Down Expand Up @@ -51,6 +52,7 @@ def generate_node_config
Chef::Log.debug "Node config '#{node_config}' already exists"
else
ui.msg "Generating node config '#{node_config}'..."
FileUtils.mkdir_p(node_config.dirname)
File.open(node_config, 'w') do |f|
attributes = config[:json_attributes] || config[:first_boot_attributes] || {}
run_list = { :run_list => config[:run_list] || [] }
Expand Down
8 changes: 8 additions & 0 deletions test/node_config_command_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ def test_generates_a_node_config_with_specified_run_list_and_attributes
end
end

def test_creates_the_nodes_directory_if_needed
outside_kitchen do
cmd = command(@host, "--node-name=mynode")
cmd.generate_node_config
assert cmd.node_config.exist?
end
end

def command(*args)
knife_command(DummyNodeConfigCommand, *args)
end
Expand Down