Skip to content

Commit

Permalink
fix error when dockerfile_vars is nil #11
Browse files Browse the repository at this point in the history
  • Loading branch information
marcy-terui committed Jun 12, 2015
1 parent b1324a5 commit b5eabb3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/kitchen/docker_cli/dockerfile_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ module DockerCli

class DockerfileTemplate
def initialize(vars={}, config={})
vars.each do |k, v|
instance_variable_set("@#{k.to_s}", v)
if vars.is_a?(Hash)
vars.each do |k, v|
instance_variable_set("@#{k.to_s}", v)
end
end
self.class.class_eval <<-EOF
def config
Expand Down
1 change: 1 addition & 0 deletions lib/kitchen/driver/docker_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class DockerCli < Kitchen::Driver::Base
default_config :privileged, false
default_config :instance_host_name, false
default_config :transport, "docker_cli"
default_config :dockerfile_vars, {}

default_config :image do |driver|
driver.default_image
Expand Down
16 changes: 16 additions & 0 deletions spec/kitchen/driver/docker_cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,22 @@
ret = <<-EOH
FROM ubuntu/12.04
ENV LANG ja_JP.UTF-8
EOH
expect(@docker_cli.send(:docker_file)).to eq ret
end
end
context 'dockerfile template when dockerfile_vars is nil' do
let(:config) {
{
image: "ubuntu/12.04",
platform: "ubuntu",
dockerfile: File.join(File.dirname(__FILE__), 'dockerfile_nil.erb'),
dockerfile_vars: nil
}
}
example do
ret = <<-EOH
FROM ubuntu/12.04
EOH
expect(@docker_cli.send(:docker_file)).to eq ret
end
Expand Down
1 change: 1 addition & 0 deletions spec/kitchen/driver/dockerfile_nil.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM <%= config[:image] %>

0 comments on commit b5eabb3

Please sign in to comment.