Skip to content

Commit

Permalink
Merge pull request #103 from pauby/add-credential-help and !Deploy
Browse files Browse the repository at this point in the history
Add Credential Help
  • Loading branch information
RamblingCookieMonster authored Jun 30, 2020
2 parents 26785f2 + 5562e3b commit 0f912a4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 14 deletions.
36 changes: 22 additions & 14 deletions PSDepend/Public/Invoke-PSDepend.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,25 @@ Function Invoke-PSDepend {
If specified, override the target in the PSDependOptions or Dependency.
.PARAMETER Import
If the dependency supports it, import it
If the dependency supports it, import it
.PARAMETER Credentials
Specifies a hashtable of PSCredentials to use for each dependency that is served from a private feed.
.PARAMETER Credentials
Specifies a hashtable of PSCredentials to use for each dependency that is served from a private feed. The key of the hashtable must match the Credential property value in the dependency.
For example:
For example:
@{
dependency_name = @{
...
Credential = 'PrivatePackage'
...
}
}
-Credentials @{
PrivatePackage = $privateCredentials
AnotherPrivatePackage = $morePrivateCredenials
}
-Credentials @{
PrivatePackage = $privateCredentials
AnotherPrivatePackage = $morePrivateCredenials
}
.EXAMPLE
Invoke-PSDepend
Expand Down Expand Up @@ -154,9 +162,9 @@ Function Invoke-PSDepend {

[switch]$Force,

[String]$Target,
[String]$Target,

[parameter(ParameterSetName = 'installimport-file')]
[parameter(ParameterSetName = 'installimport-file')]
[parameter(ParameterSetName = 'installimport-hashtable')]
[hashtable]$Credentials
)
Expand Down Expand Up @@ -212,11 +220,11 @@ Function Invoke-PSDepend {
if($PSBoundParameters.ContainsKey('Tags'))
{
$GetPSDependParams.Add('Tags',$Tags)
}
}

if ($null -ne $Credentials) {
$GetPSDependParams.Add('Credentials', $Credentials)
}
if ($null -ne $Credentials) {
$GetPSDependParams.Add('Credentials', $Credentials)
}

# Handle Dependencies
$Dependencies = Get-Dependency @GetPSDependParams
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,38 @@ Note that we replace certain strings in Target and Source fields:
* If you call Invoke-PSDepend -Target $Something, we override any value for target
* Thanks to Mike Walker for the idea!

### Repository Credentials

If you are using a PowerShell module repository that requires authentication then add those to your dependency. When working with credentials there are two parts we need to consider:

* Credential property of our dependency.
* Credentials parameter for Invoke-PSDepend.

```powershell
@{
psdeploy = 'latest'
buildhelpers_0_0_20 = @{
Name = 'buildhelpers'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Version = '0.0.20'
Credential = 'must_match'
}
}
```

Now create a `PSCredential` object with the credentials to access the repository and run it:

```powershell
Invoke-PSDepend -Path C:\requirements.psd1 -Credentials @{ 'must_match' = $creds }
```

Make sure whatever you use as `must_match` is the same in the dependency as it is in the hashtable you pass to the Credentials parameter.

## Exploring and Getting Help

Each DependencyType - PSGalleryModule, FileDownload, Task, etc. - might treat these standard properties differently, and may include their own Parameters. For example, in the BuildHelpers node above, we specified a Repository and SkipPublisherCheck parameters.
Expand Down

0 comments on commit 0f912a4

Please sign in to comment.