diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2020-04-23 14:11:10 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2020-04-23 14:11:10 -0700 |
commit | 165685fdcbd4fbe8138d37d1285b633e3958cf09 (patch) | |
tree | c95140471c1c8f816896d71957f5ac362b6d59f3 /lib/chef/provider/subversion.rb | |
parent | 16b6db24f54f4fa015b4939880a04abb9a8c256b (diff) | |
download | chef-165685fdcbd4fbe8138d37d1285b633e3958cf09.tar.gz |
Chef-16 git provider fixes
The git provider now no longer checks out to a "deploy" branch by
default and now checks out to the branch (with a remote upstream) or
else checks out to a detatched head.
The prior behavior can be restored by using "checkout branch 'deploy'".
This also removes the SCM resource base class and replaces it with a
resource partial and does some internal reorganization.
It also introduces the RecipeDSLHelper for better functional tests and
cleans up the functional tests of the git provider.
Properties that were only ever implemented on the git provider were
removed from the subversion provider where they had been inherited from
the base class incorrectly.
Some additional env var handling was added to the subversion handler in
the process of sorting out the common properties, including HOME
handling for alternative users.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/provider/subversion.rb')
-rw-r--r-- | lib/chef/provider/subversion.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb index 486bb38e5d..270f7457fa 100644 --- a/lib/chef/provider/subversion.rb +++ b/lib/chef/provider/subversion.rb @@ -149,9 +149,15 @@ class Chef end def run_options(run_opts = {}) - run_opts[:user] = new_resource.user if new_resource.user + env = {} + if new_resource.user + run_opts[:user] = new_resource.user + env["HOME"] = get_homedir(new_resource.user) + end run_opts[:group] = new_resource.group if new_resource.group run_opts[:timeout] = new_resource.timeout if new_resource.timeout + env.merge!(new_resource.environment) if new_resource.environment + run_opts[:environment] = env unless env.empty? run_opts end @@ -225,6 +231,20 @@ class Chef raise Chef::Exceptions::MissingParentDirectory, msg end end + + # Returns the home directory of the user + # @param [String] user must be a string. + # @return [String] the home directory of the user. + # + def get_homedir(user) + require "etc" unless defined?(Etc) + case user + when Integer + Etc.getpwuid(user).dir + else + Etc.getpwnam(user.to_s).dir + end + end end end end |