Skip to content

Commit

Permalink
Allow supervisord environment vars to have "+"
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim Jahn committed May 22, 2019
1 parent c0b178c commit 5565827
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions data/export/supervisord/app.conf.erb
Expand Up @@ -9,6 +9,7 @@ engine.each_process do |name, process|
value = value.gsub('\=', '=')
value = value.gsub('\&', '&')
value = value.gsub('\?', '?')
value = value.gsub('\+', '+')
"#{key}=\"#{value}\""
end
app_names << full_name
Expand Down
2 changes: 2 additions & 0 deletions spec/foreman/engine_spec.rb
Expand Up @@ -83,13 +83,15 @@ def shutdown
f.puts "FRED='barney'"
f.puts 'OTHER="escaped\"quote"'
f.puts 'URL="http://example.com/api?foo=bar&baz=1"'
f.puts 'KEY="LkZAMKGHwA9MsLj+rIVLmSMg+p206CeNaliqyFrjt9"'
end
subject.load_env "/tmp/env"
expect(subject.env["FOO"]).to eq("bar")
expect(subject.env["BAZ"]).to eq("qux")
expect(subject.env["FRED"]).to eq("barney")
expect(subject.env["OTHER"]).to eq('escaped"quote')
expect(subject.env["URL"]).to eq("http://example.com/api?foo=bar&baz=1")
expect(subject.env["KEY"]).to eq("LkZAMKGHwA9MsLj+rIVLmSMg+p206CeNaliqyFrjt9")
end

it "should handle multiline strings" do
Expand Down
2 changes: 1 addition & 1 deletion spec/foreman/export/supervisord_spec.rb
Expand Up @@ -14,7 +14,7 @@
before(:each) { allow(supervisord).to receive(:say) }

it "exports to the filesystem" do
write_env(".env", "FOO"=>"bar", "URL"=>"http://example.com/api?foo=bar&baz=1")
write_env(".env", "FOO"=>"bar", "URL"=>"http://example.com/api?foo=bar&baz=1", "KEY"=>"LkZAMKGHwA9MsLj+rIVLmSMg+p206CeNaliqyFrjt9")
supervisord.engine.load_env('.env')
supervisord.export
expect(File.read("/tmp/init/app.conf")).to eq(example_export_file("supervisord/app-alpha-1.conf"))
Expand Down
8 changes: 4 additions & 4 deletions spec/resources/export/supervisord/app-alpha-1.conf
Expand Up @@ -6,7 +6,7 @@ stdout_logfile=/var/log/app/alpha-1.log
stderr_logfile=/var/log/app/alpha-1.error.log
user=app
directory=/tmp/app
environment=FOO="bar",URL="http://example.com/api?foo=bar&baz=1",PORT="5000"
environment=FOO="bar",URL="http://example.com/api?foo=bar&baz=1",KEY="LkZAMKGHwA9MsLj+rIVLmSMg+p206CeNaliqyFrjt9",PORT="5000"

[program:app-bravo-1]
command=./bravo
Expand All @@ -16,7 +16,7 @@ stdout_logfile=/var/log/app/bravo-1.log
stderr_logfile=/var/log/app/bravo-1.error.log
user=app
directory=/tmp/app
environment=FOO="bar",URL="http://example.com/api?foo=bar&baz=1",PORT="5100"
environment=FOO="bar",URL="http://example.com/api?foo=bar&baz=1",KEY="LkZAMKGHwA9MsLj+rIVLmSMg+p206CeNaliqyFrjt9",PORT="5100"

[program:app-foo_bar-1]
command=./foo_bar
Expand All @@ -26,7 +26,7 @@ stdout_logfile=/var/log/app/foo_bar-1.log
stderr_logfile=/var/log/app/foo_bar-1.error.log
user=app
directory=/tmp/app
environment=FOO="bar",URL="http://example.com/api?foo=bar&baz=1",PORT="5200"
environment=FOO="bar",URL="http://example.com/api?foo=bar&baz=1",KEY="LkZAMKGHwA9MsLj+rIVLmSMg+p206CeNaliqyFrjt9",PORT="5200"

[program:app-foo-bar-1]
command=./foo-bar
Expand All @@ -36,7 +36,7 @@ stdout_logfile=/var/log/app/foo-bar-1.log
stderr_logfile=/var/log/app/foo-bar-1.error.log
user=app
directory=/tmp/app
environment=FOO="bar",URL="http://example.com/api?foo=bar&baz=1",PORT="5300"
environment=FOO="bar",URL="http://example.com/api?foo=bar&baz=1",KEY="LkZAMKGHwA9MsLj+rIVLmSMg+p206CeNaliqyFrjt9",PORT="5300"

[group:app]
programs=app-alpha-1,app-bravo-1,app-foo_bar-1,app-foo-bar-1

0 comments on commit 5565827

Please sign in to comment.