diff options
author | Tim Smith <tsmith@chef.io> | 2021-06-04 19:58:18 -0700 |
---|---|---|
committer | John McCrae <john.mccrae@progress.com> | 2021-06-14 19:01:09 -0700 |
commit | 529d0fbdb6c76a9e7e455f8d6880fc6cc14af5b2 (patch) | |
tree | e5e529a1516d1730d78bd02443a8ac281a7c95a2 | |
parent | 5725f249956fe31440110c8548e9ef1eeacfbba5 (diff) | |
download | chef-529d0fbdb6c76a9e7e455f8d6880fc6cc14af5b2.tar.gz |
Move logic for cookbook name to the property + optimize path escaping
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/provider/zypper_repository.rb | 10 | ||||
-rw-r--r-- | lib/chef/resource/zypper_repository.rb | 2 |
2 files changed, 3 insertions, 9 deletions
diff --git a/lib/chef/provider/zypper_repository.rb b/lib/chef/provider/zypper_repository.rb index c8f521d081..b5bdbce2d7 100644 --- a/lib/chef/provider/zypper_repository.rb +++ b/lib/chef/provider/zypper_repository.rb @@ -68,15 +68,7 @@ class Chef # zypper repos are allowed to have spaces in the names # @return [String] escaped repo string def escaped_repo_name - Shellwords.escape(new_resource.repo_name) - end - - # return the specified cookbook name or the cookbook containing the - # resource. - # - # @return [String] name of the cookbook - def cookbook_name - new_resource.cookbook || new_resource.cookbook_name + @escaped_repo_name ||= Shellwords.escape(new_resource.repo_name) end # determine if a template file is available in the current run diff --git a/lib/chef/resource/zypper_repository.rb b/lib/chef/resource/zypper_repository.rb index fd4a8e6b36..260ac2adec 100644 --- a/lib/chef/resource/zypper_repository.rb +++ b/lib/chef/resource/zypper_repository.rb @@ -99,6 +99,8 @@ class Chef property :cookbook, String, description: "The cookbook to source the repository template file from. Only necessary if you're not using the built in template.", + default: lazy { cookbook_name }, + default_description: "The cookbook containing the resource", desired_state: false property :gpgautoimportkeys, [TrueClass, FalseClass], |