summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Miller <joshuamiller01@gmail.com>2016-08-26 09:54:38 -0700
committerPhil Dibowitz <phil@ipom.com>2016-08-26 09:54:38 -0700
commit3f33d7a105801c31ae7a38334e582068ea94af2b (patch)
tree1711b52a9189401bcebb0de4d19235c245d0d41d
parentbf7c0f9a698616da9c68adf6c0ca81f27456dc9d (diff)
downloadchef-3f33d7a105801c31ae7a38334e582068ea94af2b.tar.gz
Use symbols instead of strings as keys for systemd user property (#5241)
* Use symbols instead of strings as keys for systemd user property related funcs * Fix tests for provider/service/systemd for when user property is set * Change hash in systemctl_opts to use symbols instead of strings * Fix tests for chef/provider/systemd_unit.rb
-rw-r--r--lib/chef/provider/service/systemd.rb4
-rw-r--r--lib/chef/provider/systemd_unit.rb4
-rw-r--r--spec/unit/provider/service/systemd_service_spec.rb4
-rw-r--r--spec/unit/provider/systemd_unit_spec.rb4
4 files changed, 8 insertions, 8 deletions
diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb
index 1597d46a3d..712f0f60c3 100644
--- a/lib/chef/provider/service/systemd.rb
+++ b/lib/chef/provider/service/systemd.rb
@@ -78,10 +78,10 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
if new_resource.user
uid = node["etc"]["passwd"][new_resource.user]["uid"]
options = {
- "environment" => {
+ :environment => {
"DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{uid}/bus",
},
- "user" => new_resource.user,
+ :user => new_resource.user,
}
args = "--user"
else
diff --git a/lib/chef/provider/systemd_unit.rb b/lib/chef/provider/systemd_unit.rb
index 5b558ba335..4aa4cd0aa2 100644
--- a/lib/chef/provider/systemd_unit.rb
+++ b/lib/chef/provider/systemd_unit.rb
@@ -225,8 +225,8 @@ class Chef
@systemctl_opts ||=
if new_resource.user
{
- "user" => new_resource.user,
- "environment" => {
+ :user => new_resource.user,
+ :environment => {
"DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{node['etc']['passwd'][new_resource.user]['uid']}/bus",
},
}
diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb
index 8574cbf772..4e25f499f6 100644
--- a/spec/unit/provider/service/systemd_service_spec.rb
+++ b/spec/unit/provider/service/systemd_service_spec.rb
@@ -196,14 +196,14 @@ describe Chef::Provider::Service::Systemd do
context "when a user is specified" do
it "should call '#{systemctl_path} --user start service_name' if no start command is specified" do
current_resource.user("joe")
- expect(provider).to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --user start #{service_name}", { "environment" => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, "user" => "joe" }).and_return(shell_out_success)
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --user start #{service_name}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe" }).and_return(shell_out_success)
provider.start_service
end
it "should not call '#{systemctl_path} --user start service_name' if it is already running" do
current_resource.running(true)
current_resource.user("joe")
- expect(provider).not_to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --user start #{service_name}", { "environment" => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, "user" => "joe" })
+ expect(provider).not_to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} --user start #{service_name}", { :environment => { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/10000/bus" }, :user => "joe" })
provider.start_service
end
end
diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb
index 42604c22eb..7f2907c982 100644
--- a/spec/unit/provider/systemd_unit_spec.rb
+++ b/spec/unit/provider/systemd_unit_spec.rb
@@ -58,8 +58,8 @@ describe Chef::Provider::SystemdUnit do
let(:user_cmd_opts) do
{
- "user" => "joe",
- "environment" => {
+ :user => "joe",
+ :environment => {
"DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/1000/bus",
},
}