From 9f3b903085af603e7bb0d7f0b0c8557fa3b3a2be Mon Sep 17 00:00:00 2001 From: Andy Morris Date: Fri, 25 Jan 2013 00:24:04 -0600 Subject: [PATCH] Prevent upstart export from deleting similarly named upstart files --- lib/foreman/export/upstart.rb | 2 +- spec/foreman/export/upstart_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/foreman/export/upstart.rb b/lib/foreman/export/upstart.rb index 01d36ef..3198e0f 100644 --- a/lib/foreman/export/upstart.rb +++ b/lib/foreman/export/upstart.rb @@ -6,7 +6,7 @@ class Foreman::Export::Upstart < Foreman::Export::Base def export super - Dir["#{location}/#{app}*.conf"].each do |file| + (Dir["#{location}/#{app}-*.conf"] << "#{location}/#{app}.conf").each do |file| clean file end diff --git a/spec/foreman/export/upstart_spec.rb b/spec/foreman/export/upstart_spec.rb index 907564e..5694643 100644 --- a/spec/foreman/export/upstart_spec.rb +++ b/spec/foreman/export/upstart_spec.rb @@ -34,6 +34,18 @@ describe Foreman::Export::Upstart, :fakefs do upstart.export end + it "does not delete exported files for similarly named applications" do + FileUtils.mkdir_p "/tmp/init" + + ["app2", "app2-alpha", "app2-alpha-1"].each do |name| + path = "/tmp/init/#{name}.conf" + FileUtils.touch(path) + dont_allow(FileUtils).rm(path) + end + + upstart.export + end + it "quotes and escapes environment variables" do engine.env['KEY'] = 'd"\|d' upstart.export