diff options
author | Tim Smith <tsmith@chef.io> | 2021-09-30 13:20:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 13:20:54 -0700 |
commit | 8557b4277a4414dba1136aabd6b662b269e2e792 (patch) | |
tree | 8704e245f840bc8060569e539b4f27188bc788ec | |
parent | a7ea044e91dd87e7f228e285fcd03bbf58ece61d (diff) | |
parent | 7422d8506c65c5e4db2d91d9d2e7970e99a6278d (diff) | |
download | chef-8557b4277a4414dba1136aabd6b662b269e2e792.tar.gz |
Merge pull request #12119 from chef/jfm/powershell_package_source
Updated the package source resource to accept credentials and updated…
-rw-r--r-- | lib/chef/resource/powershell_package_source.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/chef/resource/powershell_package_source.rb b/lib/chef/resource/powershell_package_source.rb index 6a91b8d0b8..0902b7ff93 100644 --- a/lib/chef/resource/powershell_package_source.rb +++ b/lib/chef/resource/powershell_package_source.rb @@ -25,7 +25,7 @@ class Chef provides :powershell_package_source - description "Use the **powershell_package_source** resource to register a PowerShell Repository or other Package Source type with. There are 2 distinct objects we care about here. The first is a Package Source like a PowerShell Repository or a Nuget Source. The second object is a provider that PowerShell uses to get to that source with, like PowerShellGet, Nuget, Chocolatey, etc. " + description "Use the **powershell_package_source** resource to register a PowerShell package source and a Powershell package provider. There are 2 distinct objects we care about here. The first is a Package Source like a PowerShell Repository or a Nuget Source. The second object is a provider that PowerShell uses to get to that source with, like PowerShellGet, Nuget, Chocolatey, etc. " introduced "14.3" examples <<~DOC **Add a new PSRepository that is not trusted and which requires credentials to connect to**: @@ -36,8 +36,8 @@ class Chef source_location "https://pkgs.dev.azure.com/some-org/some-project/_packaging/some_feed/nuget/v2" publish_location "https://pkgs.dev.azure.com/some-org/some-project/_packaging/some_feed/nuget/v2" trusted false - user_name "someuser@somelocation.io" - user_pass "my_password" + user "someuser@somelocation.io" + password "my_password" provider_name "PSRepository" action :register end @@ -97,8 +97,8 @@ class Chef source_name "PowerShellModules" new_name "GoldFishBowl" trusted true - user_name "user@domain.io" - user_pass "some_secret_password" + user "user@domain.io" + password "some_secret_password" action :set end ``` @@ -117,10 +117,10 @@ class Chef description: "A label that names your package source.", name_property: true - property :new_name, String, - description: "Used when updating the name of a NON-PSRepository" + property :new_name, introduced: "17.6", String, + description: "Used to change the name of a standard package source." - property :source_location, String, + property :source_location, introduced: "17.6", String, description: "The URL to the location to retrieve modules from." alias :url :source_location @@ -138,10 +138,10 @@ class Chef description: "Whether or not to trust packages from this source. Used when creating a NON-PSRepository Package Source", default: false - property :user_name, String, + property :user, introduced: "17.6", String, description: "A username that, as part of a credential object, is used to register a repository or other package source with." - property :user_pass, String, + property :password, introduced: "17.6", String, description: "A password that, as part of a credential object, is used to register a repository or other package source with." property :provider_name, String, @@ -256,9 +256,9 @@ class Chef else install_policy = "Untrusted" end - if new_resource.user_name && new_resource.user_pass - cmd = "$user = '#{new_resource.user_name}';" - cmd << "[securestring]$secure_password = Convertto-SecureString -String '#{new_resource.user_pass}' -AsPlainText -Force;" + if new_resource.user && new_resource.password + cmd = "$user = '#{new_resource.user}';" + cmd << "[securestring]$secure_password = Convertto-SecureString -String '#{new_resource.password}' -AsPlainText -Force;" cmd << "$Credentials = New-Object System.Management.Automation.PSCredential -Argumentlist ($user, $secure_password);" cmd << "#{cmdlet_type}-PSRepository -Name '#{new_resource.source_name}'" cmd << " -SourceLocation '#{new_resource.source_location}'" if new_resource.source_location @@ -281,9 +281,9 @@ class Chef end def build_package_source_command(cmdlet_type, new_resource) - if new_resource.user_name && new_resource.user_pass - cmd = "$user = '#{new_resource.user_name}';" - cmd << "[securestring]$secure_password = Convertto-SecureString -String '#{new_resource.user_pass}' -AsPlainText -Force;" + if new_resource.user && new_resource.password + cmd = "$user = '#{new_resource.user}';" + cmd << "[securestring]$secure_password = Convertto-SecureString -String '#{new_resource.password}' -AsPlainText -Force;" cmd << "$Credentials = New-Object System.Management.Automation.PSCredential -Argumentlist ($user, $secure_password);" cmd << "#{cmdlet_type}-PackageSource -Name '#{new_resource.source_name}'" cmd << " -Location '#{new_resource.source_location}'" if new_resource.source_location |