diff options
author | Tim Smith <tsmith@chef.io> | 2019-06-25 09:40:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-25 09:40:22 -0700 |
commit | d4e30e7291a6aa8291c436cc373185d431a04591 (patch) | |
tree | bc9ea3af03b1b7e68414ae82db92164488cbe7c5 /lib | |
parent | 1e319e3b7a9fa66d4c207f4b262b053fd0a7d5e1 (diff) | |
parent | 5a1daf0c5a0899a53ce181834cd851192fb89c7c (diff) | |
download | chef-d4e30e7291a6aa8291c436cc373185d431a04591.tar.gz |
Merge pull request #8635 from gep13/choco_source
(GH-8634) Add ability to further configure source
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource/chocolatey_source.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/chef/resource/chocolatey_source.rb b/lib/chef/resource/chocolatey_source.rb index e8ef95aad5..2b358a22f7 100644 --- a/lib/chef/resource/chocolatey_source.rb +++ b/lib/chef/resource/chocolatey_source.rb @@ -31,9 +31,17 @@ class Chef property :bypass_proxy, [TrueClass, FalseClass], default: false, description: "Whether or not to bypass the system's proxy settings to access the source." + property :admin_only, [TrueClass, FalseClass], default: false, + description: "Whether or not to set the source to be accessible to only admins." + + property :allow_self_service, [TrueClass, FalseClass], default: false, + description: "Whether or not to set the source to be used for self service." + property :priority, Integer, default: 0, description: "The priority level of the source." + property :disabled, [TrueClass, FalseClass], default: false, desired_state: false, skip_docs: true + load_current_value do element = fetch_source_element(source_name) current_value_does_not_exist! if element.nil? @@ -41,7 +49,10 @@ class Chef source_name element["id"] source element["value"] bypass_proxy element["bypassProxy"] == "true" + admin_only element["adminOnly"] == "true" + allow_self_service element["selfService"] == "true" priority element["priority"].to_i + disabled element["disabled"] == "true" end # @param [String] id the source name @@ -77,6 +88,26 @@ class Chef end end + action :disable do + description "Disables a Chocolatey source." + + if current_resource.disabled != true + converge_by("disable Chocolatey source '#{new_resource.source_name}'") do + shell_out!(choco_cmd("disable")) + end + end + end + + action :enable do + description "Enables a Chocolatey source." + + if current_resource.disabled == true + converge_by("enable Chocolatey source '#{new_resource.source_name}'") do + shell_out!(choco_cmd("enable")) + end + end + end + action_class do # @param [String] action the name of the action to perform # @return [String] the choco source command string @@ -85,6 +116,8 @@ class Chef if action == "add" cmd << " -s #{new_resource.source} --priority=#{new_resource.priority}" cmd << " --bypassproxy" if new_resource.bypass_proxy + cmd << " --allowselfservice" if new_resource.allow_self_service + cmd << " --adminonly" if new_resource.admin_only end cmd end |