diff options
author | Tim Smith <tsmith@chef.io> | 2021-10-11 14:34:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-11 14:34:01 -0700 |
commit | d6b5f9cc787513eb0e0221cc8a106b81090481b0 (patch) | |
tree | 44662d9d457edd5464642a792f86b09746e70de8 | |
parent | 93f86e8a76b8dc9e0aa971e10bf9bf78d5114d8a (diff) | |
parent | f220f1ca90b810901b3e81a5570a6bf8fa1a6027 (diff) | |
download | chef-d6b5f9cc787513eb0e0221cc8a106b81090481b0.tar.gz |
Merge pull request #12159 from gep13/feature12158
(#12158) Add ability to create authenticated sources with chocolatey_source resource
-rw-r--r-- | lib/chef/resource/chocolatey_source.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/chef/resource/chocolatey_source.rb b/lib/chef/resource/chocolatey_source.rb index e3b35074e3..2496a86cd0 100644 --- a/lib/chef/resource/chocolatey_source.rb +++ b/lib/chef/resource/chocolatey_source.rb @@ -63,6 +63,22 @@ class Chef property :disabled, [TrueClass, FalseClass], default: false, desired_state: false, skip_docs: true + property :username, String, + description: "The username to use when authenticating against the source", + introduced: "17.7" + + property :password, String, sensitive: true, desired_state: false, + description: "The password to use when authenticating against the source", + introduced: "17.7" + + property :cert, String, + description: "The certificate to use when authenticating against the source", + introduced: "17.7" + + property :cert_password, String, sensitive: true, desired_state: false, + description: "The password for the certificate to use when authenticating against the source", + introduced: "17.7" + load_current_value do element = fetch_source_element(source_name) current_value_does_not_exist! if element.nil? @@ -74,6 +90,8 @@ class Chef allow_self_service element["selfService"] == "true" priority element["priority"].to_i disabled element["disabled"] == "true" + username element["user"] + cert element["certificate"] end # @param [String] id the source name @@ -129,10 +147,14 @@ class Chef def choco_cmd(action) cmd = "#{ENV["ALLUSERSPROFILE"]}\\chocolatey\\bin\\choco source #{action} -n \"#{new_resource.source_name}\"" if action == "add" - cmd << " -s #{new_resource.source} --priority=#{new_resource.priority}" + cmd << " --source=\"#{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 + cmd << " --user=\"#{new_resource.username}\"" if new_resource.username + cmd << " --password=\"#{new_resource.password}\"" if new_resource.password + cmd << " --cert=\"#{new_resource.cert}\"" if new_resource.cert + cmd << " --certpassword=\"#{new_resource.cert_password}\"" if new_resource.cert_password end cmd end |