Downloads:

982

Downloads of v 3.0.1:

768

Last Update:

28 Jun 2016

Package Maintainer(s):

Software Author(s):

  • Jayme Edwards

Tags:

admin

PowerDelivery 3 Node

3.0.1 | Updated: 28 Jun 2016

Downloads:

982

Downloads of v 3.0.1:

768

Maintainer(s):

Software Author(s):

  • Jayme Edwards

Tags:

admin

PowerDelivery 3 Node 3.0.1

All Checks are Passing

2 Passing Test


Validation Testing Passed


Verification Testing Passed

Details

To install PowerDelivery 3 Node, run the following command from the command line or from PowerShell:

>

To upgrade PowerDelivery 3 Node, run the following command from the command line or from PowerShell:

>

To uninstall PowerDelivery 3 Node, run the following command from the command line or from PowerShell:

>

NOTE: This applies to both open source and commercial editions of Chocolatey.

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://chocolatey.org/api/v2. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Enter your internal repository url

(this should look similar to https://chocolatey.org/api/v2)

4. Choose your deployment method:


choco upgrade powerdelivery3node -y --source="'STEP 3 URL'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade powerdelivery3node -y --source="'STEP 3 URL'"
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Ensure powerdelivery3node installed
  win_chocolatey:
    name: powerdelivery3node
    state: present
    version: 3.0.1
    source: STEP 3 URL

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.

Coming early 2020! Central Managment Reporting available now! More information...


chocolatey_package 'powerdelivery3node' do
  action    :install
  version  '3.0.1'
  source   'STEP 3 URL'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


Chocolatey::Ensure-Package
(
    Name: powerdelivery3node,
    Version: 3.0.1,
    Source: STEP 3 URL
);

Requires Otter Chocolatey Extension. See docs at https://inedo.com/den/otter/chocolatey.


cChocoPackageInstaller powerdelivery3node
{
   Name     = 'powerdelivery3node'
   Ensure   = 'Present'
   Version  = '3.0.1'
   Source   = 'STEP 3 URL'
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'powerdelivery3node':
  provider => 'chocolatey',
  ensure   => '3.0.1',
  source   => 'STEP 3 URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


salt '*' chocolatey.install powerdelivery3node version="3.0.1" source="STEP 3 URL"

See docs at https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.chocolatey.html.

5. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

This package was approved by moderator dtgm on 03 Jul 2016.

Description

PowerShell cmdlets for use on remote nodes being deployed to with PowerDelivery 3.


tools\chocolateyInstall.ps1
<# ChocolateyInstall.ps1

Installs PowerDelivery3Node with chocolatey.
#>

$ErrorActionPreference = 'Stop'

$moduleDir = Split-Path -parent $MyInvocation.MyCommand.Definition

. (Join-Path $moduleDir 'chocolateyPowerDeliveryUtils.ps1')

Install-PowerDeliveryModule -moduleDir $moduleDir -moduleName PowerDeliveryNode -packageId powerdelivery3node
tools\chocolateyPowerDeliveryUtils.ps1
<# chocolateyPowerDeliveryUtils.ps1

Installs and Uninstalls PowerShell modules for PowerDelivery with chocolatey.
#>

$ErrorActionPreference = 'Stop'

function Install-PowerDeliveryModule {
  [CmdletBinding()]
  param(
    [Parameter(Position=0, Mandatory=1)][string] $moduleDir,
    [Parameter(Position=1, Mandatory=1)][string] $moduleName,
    [Parameter(Position=2, Mandatory=1)][string] $packageId
  )
  
  $moduleDir = "$moduleDir\"

  $psModulePath = [Environment]::GetEnvironmentVariable("PSMODULEPATH", [EnvironmentVariableTarget]::Machine)

  $newEnvVar = $moduleDir

  $caseInsensitive = [StringComparison]::InvariantCultureIgnoreCase

  $pathSegment = "chocolatey\lib\$packageId\"

  if (![String]::IsNullOrWhiteSpace($psModulePath)) {
    if ($psModulePath.IndexOf($pathSegment, $caseInsensitive) -lt 0) { # First time installing
        if ($psModulePath.EndsWith(";")) {
            $psModulePath = $psModulePath.TrimEnd(";")
        }
        $newEnvVar = "$($psModulePath);$($moduleDir)"
    }
    else { # Replacing an existing install
        $indexOfSegment = $psModulePath.IndexOf($pathSegment, $caseInsensitive)
        $startingSemicolon = $psModulePath.LastIndexOf(";", $indexOfSegment, $caseInsensitive)
        $trailingSemicolon = $psModulePath.IndexOf(";", $indexOfSegment + $pathSegment.Length, $caseInsensitive)

        if ($startingSemicolon -ne -1) {
            $psModulePrefix = $psModulePath.Substring(0, $startingSemicolon)
            $newEnvVar = "$($psModulePrefix);$($moduleDir)"
        }     
        if ($trailingSemicolon -ne -1) {
            $newEnvVar += $psModulePath.Substring($trailingSemicolon)
        }
    }
  }
  else {
    $newEnvVar = "%PSMODULEPATH%;$newEnvVar"
  }

  [Environment]::SetEnvironmentVariable("PSMODULEPATH", $newEnvVar, [EnvironmentVariableTarget]::Machine)
  $Env:PSMODULEPATH = $newEnvVar

  Import-Module $moduleName -Force
}

function Uninstall-PowerDeliveryModule {
  [CmdletBinding()]
  param(
    [Parameter(Position=0, Mandatory=1)][string] $moduleDir,
    [Parameter(Position=1, Mandatory=1)][string] $moduleName,
    [Parameter(Position=2, Mandatory=1)][string] $packageId
  )

  try {
    Remove-Module $moduleName | Out-Null
  }
  catch {}

  $moduleDir = "$moduleDir\"

  $psModulePath = [Environment]::GetEnvironmentVariable("PSMODULEPATH", [EnvironmentVariableTarget]::Machine)

  $newEnvVar = $moduleDir

  $caseInsensitive = [StringComparison]::InvariantCultureIgnoreCase

  $pathSegment = "chocolatey\lib\$packageId\"

  if (![String]::IsNullOrWhiteSpace($psModulePath)) {
    if ($psModulePath.IndexOf($pathSegment, $caseInsensitive) -ge 0) {
        $indexOfSegment = $psModulePath.IndexOf($pathSegment, $caseInsensitive)
        $startingSemicolon = $psModulePath.LastIndexOf(";", $indexOfSegment, $caseInsensitive)
        $trailingSemicolon = $psModulePath.IndexOf(";", $indexOfSegment + $pathSegment.Length, $caseInsensitive)

        if ($startingSemicolon -ne -1) {
            $newEnvVar = $psModulePath.Substring(0, $startingSemicolon)
        }     
        if ($trailingSemicolon -ne -1) {
            $newEnvVar += $psModulePath.Substring($trailingSemicolon)
        }

        [Environment]::SetEnvironmentVariable("PSMODULEPATH", $newEnvVar, [EnvironmentVariableTarget]::Machine)
        $Env:PSMODULEPATH = $newEnvVar
    }
  }
}
tools\chocolateyUninstall.ps1
<# ChocolateyUninstall.ps1

Uninstalls PowerDelivery3Node with chocolatey.
#>

$ErrorActionPreference = 'Stop'

$moduleDir = Split-Path -parent $MyInvocation.MyCommand.Definition

. (Join-Path $moduleDir 'chocolateyPowerDeliveryUtils.ps1')

Uninstall-PowerDeliveryModule -moduleDir $moduleDir -moduleName PowerDeliveryNode -packageId powerdelivery3node
tools\init.ps1
<# Init.ps1

Initializes PowerDelivery3Node when loaded by chocolatey.
#>

param($installPath, $toolsPath, $package)

$modulePath = Join-Path $toolsPath PowerDeliveryNode.psm1
Import-Module $modulePath -Force
tools\PowerDeliveryNode\Cmdlets\Get-DeliveryFilesFromAzure.ps1
<#
.Synopsis
Downloads files that were published by powerdelivery to Windows Azure 
during the current run of a target onto a node.

.Description
Downloads files that were published by powerdelivery to Windows Azure 
during the current run of a target onto a node.

.Example
Delivery:Role {
  param($target, $config, $node)

  # You must install PowerDeliveryNode using chocolatey in a 
  # role that has run before this one on the remote node first.
  Import-Module PowerDeliveryNode

  # $releasePath will be C:\Users\<User>\AppData\Roaming\<Project>\Current 
  # pointing to a yyyyMMdd_HHmmss folder in the same directory.
  $releasePath = New-DeliveryReleasePath $target [Environment]::GetFolderPath("AppData")
  
  # Downloads files within the folder "MyApp" that were uploaded to Azure
  # into a local directory for the release on the node created above.
  Get-DeliveryFilesFromAzure -Target $target `
                             -Path "MyApp" `
                             -Destination $releasePath `
                             -Credential $target.Credentials['[email protected]'] `
                             -SubscriptionId $config.MyAzureSubsciptionId `
                             -StorageAccountName $config.MyAzureStorageAccountName `
                             -StorageAccountKey $config.MyAzureStorageAccountKey `
                             -StorageContainer $config.MyAzureStorageContainer
}

.Parameter Target
The $target parameter from the role.

.Parameter Path
The path of files to download relative to the release directory (<ProjectName>/<StartedAt>) 
uploaded to Azure with the Publish-DeliveryFilesToAzure cmdlet.

.Parameter Destination
The directory in which to place downloaded files. The New-DeliveryReleasePath cmdlet 
is recommended to enable rollback via the Undo-DeliveryReleasePath cmdlet in a Down block.

.Parameter Credential
The Windows Azure account credentials to use. You must configure the computer running powerdelivery 
as described at http://www.powerdelivery.io/secrets.html#using_credentials_in_remote_roles 
for these to travel from to the node that will download files with this cmdlet.

.Parameter SubscriptionId
A Windows Azure subscription that the account in the Credential parameter is permitted 
to use.

.Parameter StorageAccountName
A Windows Azure storage account that the account in the Credential parameter is permitted 
to access.

.Parameter StorageAccountKey
A Windows Azure storage account key that matches the StorageAccountName parameter providing 
read access.

.Parameter StorageContainer
A container within the Windows Azure storage account referred to in the StorageAccountName 
parameter that contains files uploaded with the Publish-DeliveryFilesToAzure cmdlet in 
a prior role that ran on localhost to create a release.
#>
function Get-DeliveryFilesFromAzure {
  param(
    [Parameter(Position=0,Mandatory=1)][hashtable] $Target,
    [Parameter(Position=1,Mandatory=1)][string] $Path,
    [Parameter(Position=2,Mandatory=1)][string] $Destination,
    [Parameter(Position=3,Mandatory=1)][PSCredential] $Credential,
    [Parameter(Position=4,Mandatory=1)][string] $SubscriptionId,
    [Parameter(Position=5,Mandatory=1)][string] $StorageAccountName,
    [Parameter(Position=6,Mandatory=1)][string] $StorageAccountKey,
    [Parameter(Position=7,Mandatory=1)][string] $StorageContainer
  )

  $verbose = Test-Verbose

  if (-not ("win32.Shell" -as [type])) {
      Add-Type -Namespace win32 -Name Shell -MemberDefinition @"
      [DllImport("Shlwapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
      public static extern bool PathRelativePathTo(System.Text.StringBuilder lpszDst,
      string From, System.IO.FileAttributes attrFrom, String to, System.IO.FileAttributes attrTo);
"@
  }

  Import-Module Azure

  # Set the active Azure account
  Add-AzureAccount -Credential $Credential | Out-Null

  if ($verbose) {
    Write-Host "Using Azure subscription ""$SubscriptionId"""
  }

  # Set the active subscription
  Select-AzureSubscription -SubscriptionId $SubscriptionId

  if ($verbose) {
    Write-Host "Using Azure storage account ""$StorageAccountName"""
  }

  # Connect to the Azure storage account
  $storageContext = New-AzureStorageContext -StorageAccountName $StorageAccountName `
                                            -StorageAccountKey $StorageAccountKey
  
  # Get the powerdelivery share
  $releasesContainer = Get-AzureStorageContainer -Name $StorageContainer `
                                                 -Context $storageContext `
                                                 -ErrorAction SilentlyContinue
  if (!$releasesContainer) {
    throw "Azure storage container $StorageContainer not found in account $StorageAccountName."
  }

  # List all files in the container for all releases
  $allReleaseFiles = Get-AzureStorageBlob -Blob "$($target.ProjectName)*" `
                                          -Container $StorageContainer `
                                          -Context $storageContext

  $releasePrefix = "$($target.ProjectName)/$($target.StartedAt)"
  $pathToGet = $releasePrefix

  # Append the source path if not the entire directory
  if ($Path -ne ".") {
    $extraPath = $Path -replace '\\', '/'

    if ($extraPath.StartsWith("/")) {
      $extraPath = $extraPath.Substring(1)
    }

    $pathToGet = "$releasePrefix/$extraPath"
  }

  # Iterate the files in the release
  foreach ($releaseFile in $allReleaseFiles) {

    # Only download files for the current release
    if ($releaseFile.Name.StartsWith($pathToGet)) {

      # Fix up the filename to exclude the release and timestamp
      $targetPath = $releaseFile.Name.Substring($releasePrefix.Length + 1)
      $targetPath = $targetPath -replace '/', '\'
      $targetPath = Join-Path $Destination $targetPath

      # Create the directory containing the file if it doesn't exist
      $targetDir = [IO.Path]::GetDirectoryName($targetPath)
      if (!(Test-Path $targetDir)) {
        New-Item -ItemType Directory $targetDir | Out-Null
      }

      # Download the file
      Get-AzureStorageBlobContent -Blob $releaseFile.Name `
                                  -Container $StorageContainer `
                                  -Context $storageContext `
                                  -Destination $targetPath | Out-Null
    }
  }
}

Export-ModuleMember -Function Get-DeliveryFilesFromAzure
tools\PowerDeliveryNode\Cmdlets\Get-DeliveryFilesFromS3.ps1
<#
.Synopsis
Downloads files that were published by powerdelivery to an AWS Simple Storage Service bucket 
during the current run of a target onto a node.

.Description
Downloads files that were published by powerdelivery to an AWS Simple Storage Service bucket 
during the current run of a target onto a node.

.Example
Delivery:Role {
  param($target, $config, $node)

  # You must install PowerDeliveryNode using chocolatey in a 
  # role that has run before this one on the remote node first.
  Import-Module PowerDeliveryNode

  # $releasePath will be C:\Users\<User>\AppData\Roaming\<Project>\Current 
  # pointing to a yyyyMMdd_HHmmss folder in the same directory.
  $releasePath = New-DeliveryReleasePath $target [Environment]::GetFolderPath("AppData")
  
  # Downloads files within the folder "MyApp" that were uploaded to S3
  # into a local directory for the release on the node created above.
  Get-DeliveryFilesFromS3 -Target $target `
                          -Path "MyApp" `
                          -Destination $releasePath `
                          -ProfileName "MyProfile" `
                          -BucketName "MyAppReleases"
}

.Parameter Target
The $target parameter from the role.

.Parameter Path
The path of files to download relative to the release directory (<ProjectName>/<StartedAt>) 
uploaded to S3 with the Publish-DeliveryFilesToS3 cmdlet.

.Parameter Destination
The directory in which to place downloaded files. The New-DeliveryReleasePath cmdlet 
is recommended to enable rollback via the Undo-DeliveryReleasePath cmdlet in a Down block.

.Parameter ProfileName
The name of the AWS profile containing credentials to use. 
See https://docs.aws.amazon.com/powershell/latest/userguide/specifying-your-aws-credentials.html

.Parameter BucketName
The name of the S3 bucket that contains files uploaded with the Publish-DeliveryFilesToS3 cmdlet in 
a prior role that ran on localhost to create a release.

.Parameter ProfilesLocation
The location to look in for the AWS profile containing credentials.
See https://docs.aws.amazon.com/powershell/latest/userguide/specifying-your-aws-credentials.html
#>
function Get-DeliveryFilesFromS3 {
  param(
    [Parameter(Position=0,Mandatory=1)][hashtable] $Target,
    [Parameter(Position=1,Mandatory=1)][string] $Path,
    [Parameter(Position=2,Mandatory=1)][string] $Destination,
    [Parameter(Position=3,Mandatory=1)][string] $ProfileName,
    [Parameter(Position=4,Mandatory=1)][string] $BucketName,
    [Parameter(Position=5,Mandatory=0)][string] $ProfilesLocation
  )

  $verbose = Test-Verbose

  if (-not ("win32.Shell" -as [type])) {
      Add-Type -Namespace win32 -Name Shell -MemberDefinition @"
      [DllImport("Shlwapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
      public static extern bool PathRelativePathTo(System.Text.StringBuilder lpszDst,
      string From, System.IO.FileAttributes attrFrom, String to, System.IO.FileAttributes attrTo);
"@
  }

  $setAwsCredentialsArgs = @{
    ProfileName = $ProfileName
  }

  if (![String]::IsNullOrEmpty($ProfilesLocation)) {
    $setAwsCredentialsArgs.Add("ProfilesLocation", $ProfilesLocation)
  }

  # Set the active AWS credentials
  Set-AwsCredentials @$setAwsCredentialsArgs

  if ($verbose) {
    Write-Host "Using AWS profile ""$ProfileName"""
  }

  # Connect to the S3 bucket
  $bucket = Get-S3Bucket $BucketName
  if (!$bucket) {
    throw "S3 bucket $BucketName not found."
  }

  # List all files in the container for all releases
  $allReleaseFiles = Get-S3Object -BucketName $BucketName `
                                  -KeyPrefix $target.ProjectName

  $releasePrefix = "$($target.ProjectName)/$($target.StartedAt)"
  $pathToGet = $releasePrefix

  # Append the source path if not the entire directory
  if ($Path -ne ".") {
    $extraPath = $Path -replace '\\', '/'

    if ($extraPath.StartsWith("/")) {
      $extraPath = $extraPath.Substring(1)
    }

    $pathToGet = "$releasePrefix/$extraPath"
  }

  # Iterate the files in the release
  foreach ($releaseFile in $allReleaseFiles) {

    # Only download files for the current release
    if ($releaseFile.Key.StartsWith($pathToGet)) {

      # Fix up the filename to exclude the release and timestamp
      $targetPath = $releaseFile.Key.Substring($releasePrefix.Length + 1)
      $targetPath = $targetPath -replace '/', '\'
      $targetPath = Join-Path $Destination $targetPath

      # Create the directory containing the file if it doesn't exist
      $targetDir = [IO.Path]::GetDirectoryName($targetPath)
      if (!(Test-Path $targetDir)) {
        New-Item -ItemType Directory $targetDir | Out-Null
      }

      # Download the file
      Read-S3Object -BucketName $BucketName `
                    -Key $releaseFile.Key `
                    -File $targetPath | Out-Null
    }
  }
}

Export-ModuleMember -Function Get-DeliveryFilesFromS3
tools\PowerDeliveryNode\Cmdlets\New-DeliveryReleasePath.ps1
<#
.Synopsis
Creates a new release directory on a remote node being deployed to with powerdelivery.

.Description
Creates a new release directory on a remote node being deployed to with powerdelivery. 
A directory will be created within the path you specify and named after the ProjectName 
property of the target. A directory will be created within it with the timestamp of the 
current run of the target and symbolicly linked to "Current".

Any releases older than the number in the Keep parameter will be deleted.

.Example
Delivery:Role -Up {
  param($target, $config, $node)

  # You must install PowerDeliveryNode using chocolatey in a 
  # role that has run before this one on the remote node first.
  Import-Module PowerDeliveryNode

  # $releasePath will be C:\Users\<User>\AppData\Roaming\<Project>\Current 
  # pointing to a yyyyMMdd_HHmmss folder in the same directory.
  $releasePath = New-DeliveryReleasePath $target [Environment]::GetFolderPath("AppData")
} -Down {

  # You must install PowerDeliveryNode using chocolatey in a 
  # role that has run before this one on the remote node first.
  Import-Module PowerDeliveryNode
  
  # This will rollback a previous release. If no previous 
  # release exists it will be the same path as current.
  $releasePath = Undo-DeliveryReleasePath $target [Environment]::GetFolderPath("AppData")
}

The release will be created at the path:

C:\Users\<User>\AppData\Roaming\<Project>\<StartedAt>

And symlinked to:

C:\Users\<User>\AppData\Roaming\<Project>\Current

.Parameter Target
The hash of target properties for the powerdelivery run.

.Parameter Path
The parent path into which to create the release path.

.Parameter Keep
The number of previous releases to keep. Defaults to 5.
#>
function New-DeliveryReleasePath {
  [CmdletBinding()]
  param(
    [Parameter(Position=0,Mandatory=1)][hashtable] $Target,
    [Parameter(Position=1,Mandatory=1)][string] $Path,
    [Parameter(Position=2,Mandatory=0)][int] $Keep = 5
  )

  # Reference a sub-directory named after the project
  $projectPath = Join-Path $Path $target.ProjectName

  # Create a directory for this release
  $currentReleasePath = Join-Path $projectPath "Current"
  $thisReleasePath = Join-Path $projectPath $target.StartedAt

  if (!(Test-Path $thisReleasePath)) {
    New-Item $thisReleasePath -ItemType Directory | Out-Null

    # Remove old link to current release
    if (Test-Path $currentReleasePath) {
      & cmd /c "rmdir ""$currentReleasePath"""
    }

    # Link this release to the current release
    & cmd /c "mklink /J ""$currentReleasePath"" ""$thisReleasePath""" | Out-Null

    # Get releases
    $releases = Get-ChildItem -Directory $projectPath -Exclude "Current"

    # Delete releases older than the last 5
    if ($releases.count -gt $Keep) {
      $oldReleaseCount = $releases.count - $Keep
      $releases | 
        Sort-Object -Property Name | 
          Select -First $oldReleaseCount | 
            Remove-Item -Force -Recurse | Out-Null
    }
  }

  $currentReleasePath
}

Export-ModuleMember -Function New-DeliveryReleasePath
tools\PowerDeliveryNode\Cmdlets\Test-CommandExists.ps1
<#
.Synopsis
Tests whether a command is present in the PowerShell path.

.Description
Tests whether a command is present in the PowerShell path. Useful for checking for dependencies.

.Example
Test-Command choco

.Parameter CommandName
The name of the command to test for.
#>
function Test-CommandExists {
  [CmdletBinding()]
  param(
    [Parameter(Position=0,Mandatory=1)][string] $CommandName
  )

  $oldPreference = $ErrorActionPreference
  $ErrorActionPreference = 'stop'

  try {
    if (Get-Command $CommandName) {
      $true
    }
  }
  catch {
    $false
  }
  finally {
    $ErrorActionPreference = $oldPreference
  }
}

Export-ModuleMember -Function Test-CommandExists
tools\PowerDeliveryNode\Cmdlets\Test-Verbose.ps1
<#
.Synopsis
Tests whether PowerShell is being run in verbose mode.

.Description
Tests whether PowerShell is being run in verbose mode. Useful for logging additional details only when requested.

.Example
if (Test-Verbose) {
  Write-Host "Detailed log entry"
}
#>
function Test-Verbose {
  [CmdletBinding()]
  param()
  [System.Management.Automation.ActionPreference]::SilentlyContinue -ne $VerbosePreference
}

Export-ModuleMember -Function Test-Verbose
tools\PowerDeliveryNode\Cmdlets\Undo-DeliveryReleasePath.ps1
<#
.Synopsis
Rolls back to a previous release directory on a remote node being deployed to with powerdelivery.

.Description
Rolls back to a previous release directory on a remote node being deployed to with powerdelivery.
Modifies the symbolic link pointing to the current release path to point to the previous release 
and deletes the old current release directory. If no previous release exists, will leave the 
current release as is and return it.

.Example
Delivery:Role -Up {
  param($target, $config, $node)

  # You must install PowerDeliveryNode using chocolatey in a 
  # role that has run before this one on the remote node first.
  Import-Module PowerDeliveryNode

  # $releasePath will be C:\Users\<User>\AppData\Roaming\<Project>\Current
  $releasePath = New-DeliveryReleasePath $target [Environment]::GetFolderPath("AppData")
} -Down {

  # You must install PowerDeliveryNode using chocolatey in a 
  # role that has run before this one on the remote node first.
  Import-Module PowerDeliveryNode
  
  # This will rollback a previous release. If no previous 
  # release exists it will be the same path as current.
  $releasePath = Undo-DeliveryReleasePath $target [Environment]::GetFolderPath("AppData")
}

The releases will be looked for in the path:

C:\Users\<User>\AppData\Roaming\<Project>

And the previous release symlinked to:

C:\Users\<User>\AppData\Roaming\<Project>\Current

.Parameter Target
The hash of target properties for the powerdelivery run.

.Parameter Path
The parent path in which to look for releases.
#>
function Undo-DeliveryReleasePath {
  [CmdletBinding()]
  param(
    [Parameter(Position=0,Mandatory=1)][hashtable] $Target,
    [Parameter(Position=1,Mandatory=1)][string] $Path
  )

  $previousReleasePath = $null

  # Reference a sub-directory named after the project
  $projectPath = Join-Path $Path $target.ProjectName

  # If at least one release has occurred
  if (Test-Path $projectPath) {

    # Get current and previous release
    $lastRelease = Get-ChildItem -Directory $projectPath -Exclude "Current" | 
      Sort-Object -Descending -Property Name | Select -First 2

    # Only rollback if we've got a previous release
    if ($lastRelease.count -eq 2) {

      $previousReleasePath = $lastRelease[1]

      # Remove link to current release
      $currentReleasePath = Join-Path $projectPath "Current"
      if (Test-Path $currentReleasePath) {
        & cmd /c "rmdir ""$currentReleasePath"""
      }

      # Link current to previous release
      & cmd /c "mklink /J ""$currentReleasePath"" ""$previousReleasePath""" | Out-Null

      # Delete old current release
      Remove-Item -Force -Recurse $lastRelease[0] | Out-Null
    }
    elseif ($lastRelease.count -eq 1) {

      # Return current if no previous release
      $previousReleasePath = Join-Path $projectPath "Current"
    }
  }

  $previousReleasePath
}

Export-ModuleMember -Function Undo-DeliveryReleasePath
tools\PowerDeliveryNode\PowerDeliveryNode.psd1
 
tools\PowerDeliveryNode\PowerDeliveryNode.psm1
<# PowerDeliveryNode.psm1

Script for PowerShell module.

http://www.powerdelivery.io
#>

# Load cmdlets
$cmdletsDir = (Join-Path $PSScriptRoot "Cmdlets")
gci $cmdletsDir -Filter "*.ps1" | ForEach-Object { . (Join-Path $cmdletsDir $_.Name) }
tools\PowerDeliveryNode\Templates\.gitkeep
 

Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Version Downloads Last Updated Status
PowerDelivery 3 Node 3.0.0 214 Saturday, June 18, 2016 Approved

Discussion for the PowerDelivery 3 Node Package

Ground Rules:

  • This discussion is only about PowerDelivery 3 Node and the PowerDelivery 3 Node package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or PowerDelivery 3 Node, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus