From dbc6086fee201ca1c787963abd575fdeca04d2bc Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 08:58:09 -0400 Subject: [PATCH 01/26] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..bf898f5 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,64 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +jobs: + - job: Build_PS_Win2016 + pool: + vmImage: vs2017-win2016 + steps: + - powershell: | + .\build.ps1 -Verbose + displayName: 'Build and Test' + - task: PublishTestResults@2 + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.xml' + testRunTitle: 'PS_Win2016' + displayName: 'Publish Test Results' + + - job: Build_PSCore_Ubuntu1604 + + pool: + vmImage: ubuntu-16.04 + + steps: + - script: | + curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - + curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list + sudo apt-get update + sudo apt-get install -y powershell + displayName: 'Install PowerShell Core' + + - script: | + pwsh -c '.\build.ps1' + displayName: 'Build and Test' + + - task: PublishTestResults@2 + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.xml' + testRunTitle: 'PSCore_Ubuntu1604' + displayName: 'Publish Test Results' + + - job: Build_PSCore_MacOS1013 + pool: + vmImage: xcode9-macos10.13 + steps: + - script: | + brew update + brew tap caskroom/cask + brew cask install powershell + displayName: 'Install PowerShell Core' + + - script: | + pwsh -c '.\build.ps1' + displayName: 'Build and Test' + + - task: PublishTestResults@2 + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.xml' + testRunTitle: 'PSCore_MacOS1013' + displayName: 'Publish Test Results' \ No newline at end of file From 830f5633b50f3d9acd4d6da25a7278f80d714419 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:13:38 -0400 Subject: [PATCH 02/26] Building Out Build Items --- ZertoApiWrapper.Depend.psd1 | 50 +++++++++++++++++++++++++++++++++++++ ZertoApiWrapper.build.ps1 | 42 ++++++++++++++++++++++++++----- build.ps1 | 16 ++++++++++++ 3 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 ZertoApiWrapper.Depend.psd1 create mode 100644 build.ps1 diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 new file mode 100644 index 0000000..e0e013c --- /dev/null +++ b/ZertoApiWrapper.Depend.psd1 @@ -0,0 +1,50 @@ +@{ + psake = @{ + Name = 'InvokeBuild' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '5.4.3' + Tags = 'Bootstrap' + } + + Pester = @{ + Name = 'Pester' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '4.6.0' + Tags = 'Test' + } + + PSScriptAnalyzer = @{ + Name = 'PSScriptAnalyzer' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '1.17.1' + Tags = 'Test' + } + + Platyps = @{ + Name = 'Platyps' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '0.12.0' + Tags = 'Build' + } + +} diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index d4f7348..a8df4ca 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -1,17 +1,44 @@ -task . InstallDependencies, Analyze +#Requires -Modules 'InvokeBuild' -task InstallDependencies { - Install-Module Pester -Force - Install-Module PSScriptAnalyzer -Force +. '.\ZertoApiWrapper.settings.ps1' +# import-module "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -Verbose -Force + +<# [CmdletBinding()] +param([switch]$Install, + [string]$Configuration = (property Configuration Release)) +$targetDir = "temp/$Configuration/ZertoApiWrapper" #> + +task . Analyze, FileTests + +<# Synopsis: Ensure platyPS is installed #> +task CheckPlatyPSInstalled { + if ($null -eq (Get-Module -List platyPS)) { + Install-Module -Scope CurrentUser -Repository PSGallery -Name platyPS + } } -task Analyze { +<# Synopsis: Ensure Pester is installed #> +task CheckPesterInstalled { + if ($null -eq (Get-Module -List Pester)) { + Install-Module -Scope CurrentUser -Repository PSGallery -Name Pester + } +} + +<# Synopsis: Ensure PSScriptAnalyzer is installed #> +task CheckPSScriptAnalyzerInstalled { + if ($null -eq (Get-Module -List PSScriptAnalyzer)) { + Install-Module -Scope CurrentUser -Repository PSGallery -Name PSScriptAnalyzer + } +} + +<# Synopsis: Analyze ZertoApiWrapper functions for Code Violations #> +task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSInstalled, { $scriptAnalyzerParams = @{ Path = "$BuildRoot\ZertoApiWrapper\" Severity = @('Error', 'Warning') Recurse = $true Verbose = $false - ExcludeRule = 'PSUseDeclaredVarsMoreThanAssignments' + ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions') } $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams @@ -21,3 +48,6 @@ task Analyze { } } +task FileTests CheckPesterInstalled, { + Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails +} \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..9ce90cf --- /dev/null +++ b/build.ps1 @@ -0,0 +1,16 @@ +# Bootstrap the environment +$null = Get-PackageProvider -Name NuGet -ForceBootstrap + +if (-not (Get-Module -Name PSDepend -ListAvailable)) { + Install-Module -Name PSDepend -Scope CurrentUser -Force -Confirm:$false +} + +Import-Module -Name PSDepend +Invoke-PSDepend ` + -Path $PSScriptRoot ` + -Force ` + -Import ` + -Install ` + -Tags 'Bootstrap' + +Invoke-Build . From 973143314e8c4dfca0900f06db41287e0cdb8479 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:19:06 -0400 Subject: [PATCH 03/26] Move Module Installs to Bootstrap Tag --- ZertoApiWrapper.Depend.psd1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 index e0e013c..9b60641 100644 --- a/ZertoApiWrapper.Depend.psd1 +++ b/ZertoApiWrapper.Depend.psd1 @@ -20,7 +20,7 @@ } Target = 'CurrentUser' Version = '4.6.0' - Tags = 'Test' + Tags = 'Bootstrap' } PSScriptAnalyzer = @{ @@ -32,7 +32,7 @@ } Target = 'CurrentUser' Version = '1.17.1' - Tags = 'Test' + Tags = 'Bootstrap' } Platyps = @{ @@ -44,7 +44,7 @@ } Target = 'CurrentUser' Version = '0.12.0' - Tags = 'Build' + Tags = 'Bootstrap' } } From d67eb6530f36c7a90bafec61bf3d8f22c70bf0fa Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:24:17 -0400 Subject: [PATCH 04/26] Ignore PSUseToExportFieldsInManifest Checks --- ZertoApiWrapper.build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index a8df4ca..272353d 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -38,7 +38,7 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI Severity = @('Error', 'Warning') Recurse = $true Verbose = $false - ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions') + ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions', 'PSUseToExportFieldsInManifest') } $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams @@ -50,4 +50,4 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI task FileTests CheckPesterInstalled, { Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails -} \ No newline at end of file +} From 6b8587a30eac09fde3eadcd2718447b4b870b94e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:29:24 -0400 Subject: [PATCH 05/26] Update Generic Tests --- Tests/Public/ZertoApiWrapper.Tests.ps1 | 42 ++++++++++++++++++-------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/Tests/Public/ZertoApiWrapper.Tests.ps1 b/Tests/Public/ZertoApiWrapper.Tests.ps1 index 529c086..b9f88f4 100644 --- a/Tests/Public/ZertoApiWrapper.Tests.ps1 +++ b/Tests/Public/ZertoApiWrapper.Tests.ps1 @@ -1,23 +1,39 @@ +$moduleName = "ZertoApiWrapper" $moduleFileName = "ZertoApiWrapper.psm1" $filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' -$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' +$docsPath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests[\\\/]Public', 'docs' $modulePath = $filePath -replace "Public", "" -Import-Module $modulePath\$moduleFileName -Force -$userName = "zerto\build" -$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force -$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password) - -# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml -$zertoServer = "192.168.1.100" -$zertoPort = "7669" +Import-Module $modulePath\$moduleFileName Describe "File Tests" { - $commands = Get-Command -Module ZertoApiWrapper | Select-Object -ExpandProperty Name + Remove-Module $moduleName -Force + Import-Module $modulePath\$moduleFileName + $commands = Get-Command -Module $moduleName | Select-Object -ExpandProperty Name foreach ($command in $commands) { + $externalHelpFile = "{0}/{1}.md" -f $docsPath, $command $path = "{0}/{1}.ps1" -f $filePath, $command - it "$command is backed by a file with the same name" { - $path | should exist + context "$command File Tests" { + it "$command is backed by a file with the same name" { + $path | should exist + } + it "$command file has openbraces on the same line as the statement" { + $content = Get-Content -Path $path + $openingBracesExist = $content | Where-Object {$_.Trim() -eq '{'} + if ($openingBracesExist) { + Write-Warning "Found the following opening brances on their own line:" + foreach ($openingBrace in $openingBracesExist) { + Write-Warning "Opening Brace on it's own line - $openingBrace" + } + } + $openingBracesExist | should benullorempty + } + it "$command has an external help file" { + $externalHelpFile | should exist + } + it "$command has the External Help File Defined" { + Get-Content -Path $path -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>" + } } } -} \ No newline at end of file +} From f99c95c6c46d464a458389b8aa422593c9286197 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:53:11 -0400 Subject: [PATCH 06/26] Rename to remove plural noun --- ZertoApiWrapper/Public/Import-ZertoVpg.ps1 | 2 +- ...gSettings.ps1 => Save-ZertoVpgSetting.ps1} | 2 +- ...VpgSettings.md => Save-ZertoVpgSetting.md} | 184 +++++++++--------- 3 files changed, 94 insertions(+), 94 deletions(-) rename ZertoApiWrapper/Public/{Save-ZertoVpgSettings.ps1 => Save-ZertoVpgSetting.ps1} (95%) rename docs/{Save-ZertoVpgSettings.md => Save-ZertoVpgSetting.md} (85%) diff --git a/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 index 4c269d0..bbc45ef 100644 --- a/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 @@ -24,7 +24,7 @@ function Import-ZertoVpg { $importedSettings.VpgSettingsIdentifier = $vpgSettingsIdentifier $uri = "{0}/{1}" -f $baseUri, $vpgSettingsIdentifier Invoke-ZertoRestRequest -uri $uri -method "PUT" -body $($importedSettings | convertto-json -Depth 10) - $vpgSettingsIdentifier | Save-ZertoVpgSettings + $vpgSettingsIdentifier | Save-ZertoVpgSetting if ($settingsFile.Count -gt 1) { Start-Sleep 5 } diff --git a/ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 b/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 similarity index 95% rename from ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 rename to ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 index 24f5084..8e06784 100644 --- a/ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 +++ b/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 @@ -1,5 +1,5 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> -function Save-ZertoVpgSettings { +function Save-ZertoVpgSetting { [cmdletbinding( SupportsShouldProcess = $true )] diff --git a/docs/Save-ZertoVpgSettings.md b/docs/Save-ZertoVpgSetting.md similarity index 85% rename from docs/Save-ZertoVpgSettings.md rename to docs/Save-ZertoVpgSetting.md index 16d9dda..2e2efaf 100644 --- a/docs/Save-ZertoVpgSettings.md +++ b/docs/Save-ZertoVpgSetting.md @@ -1,92 +1,92 @@ ---- -external help file: ZertoApiWrapper-help.xml -Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSettings.md -schema: 2.0.0 ---- - -# Save-ZertoVpgSettings - -## SYNOPSIS -Commits the updated Vpg Settings with the configured Vpg Settings Identifier - -## SYNTAX - -``` -Save-ZertoVpgSettings [-vpgSettingsIdentifier] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Commits the updated Vpg Settings with the configured Vpg Settings Identifier - -## EXAMPLES - -### Example 1 -```powershell -PS C:> Save-ZertoVpgSettings -vpgSettingsIdentifier "MyVpgSettingsIdentifier" -``` - -Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier" - -## PARAMETERS - -### -vpgSettingsIdentifier -VpgSettings Identifier to save - -```yaml -Type: String -Parameter Sets: (All) -Aliases: vpgSettingsId - -Required: True -Position: 0 -Default value: None -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: cf - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -WhatIf -Shows what would happen if the cmdlet runs. -The cmdlet is not run. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: wi - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String -## OUTPUTS - -### System.Object -## NOTES - -## RELATED LINKS - -[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#) +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md +schema: 2.0.0 +--- + +# Save-ZertoVpgSetting + +## SYNOPSIS +Commits the updated Vpg Settings with the configured Vpg Settings Identifier + +## SYNTAX + +``` +Save-ZertoVpgSetting [-vpgSettingsIdentifier] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Commits the updated Vpg Settings with the configured Vpg Settings Identifier + +## EXAMPLES + +### Example 1 +```powershell +PS C:> Save-ZertoVpgSetting -vpgSettingsIdentifier "MyVpgSettingsIdentifier" +``` + +Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier" + +## PARAMETERS + +### -vpgSettingsIdentifier +VpgSettings Identifier to save + +```yaml +Type: String +Parameter Sets: (All) +Aliases: vpgSettingsId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +## OUTPUTS + +### System.Object +## NOTES + +## RELATED LINKS + +[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#) From 3098566c890d8a733d67f6c46ef9726b749a11e3 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:53:48 -0400 Subject: [PATCH 07/26] Update Markdown Help --- docs/Remove-ZertoPeerSite.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/Remove-ZertoPeerSite.md b/docs/Remove-ZertoPeerSite.md index 142d574..6bb3816 100644 --- a/docs/Remove-ZertoPeerSite.md +++ b/docs/Remove-ZertoPeerSite.md @@ -150,8 +150,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. -For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS From deae94227217ce790e94224029826e967725a5c1 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 10:13:10 -0400 Subject: [PATCH 08/26] Update examples to single noun --- .../Public/en-us/ZertoApiWrapper-help.xml | 24 +++++++++---------- docs/Get-ZertoVpgSetting.md | 10 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml index 0ee3eb7..03653be 100644 --- a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml +++ b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml @@ -5977,35 +5977,35 @@ -------------------------- Example 1 -------------------------- - PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" + PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" Returns all current settings for vpgSettingsIdentifier "MySettingsIdentifier" -------------------------- Example 2 -------------------------- - PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" + PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" Returns all current vm level settings for the vmIdentifier "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" -------------------------- Example 3 -------------------------- - PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes + PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes Returns current vm level settings for volumes for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" -------------------------- Example 4 -------------------------- - PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -nics + PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -nics Returns current vm level settings for nics for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" -------------------------- Example 5 -------------------------- - PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -basic + PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -basic Returns current basic settings for vpgSettingsIdentifier "MySettingsIdentifier" @@ -10656,9 +10656,9 @@ - Save-ZertoVpgSettings + Save-ZertoVpgSetting Save - ZertoVpgSettings + ZertoVpgSetting Commits the updated Vpg Settings with the configured Vpg Settings Identifier @@ -10668,8 +10668,8 @@ - Save-ZertoVpgSettings - + Save-ZertoVpgSetting + vpgSettingsIdentifier VpgSettings Identifier to save @@ -10706,7 +10706,7 @@ - + vpgSettingsIdentifier VpgSettings Identifier to save @@ -10771,7 +10771,7 @@ -------------------------- Example 1 -------------------------- - PS C:> Save-ZertoVpgSettings -vpgSettingsIdentifier "MyVpgSettingsIdentifier" + PS C:> Save-ZertoVpgSetting -vpgSettingsIdentifier "MyVpgSettingsIdentifier" Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier" @@ -10780,7 +10780,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSettings.md + https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md Zerto REST API VPG Settings End Point Documentation diff --git a/docs/Get-ZertoVpgSetting.md b/docs/Get-ZertoVpgSetting.md index d812532..8c97811 100644 --- a/docs/Get-ZertoVpgSetting.md +++ b/docs/Get-ZertoVpgSetting.md @@ -118,35 +118,35 @@ It is important to note that only once a VPG settings object has been created, w ### Example 1 ```powershell -PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" +PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" ``` Returns all current settings for vpgSettingsIdentifier "MySettingsIdentifier" ### Example 2 ```powershell -PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" +PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" ``` Returns all current vm level settings for the vmIdentifier "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" ### Example 3 ```powershell -PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes +PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes ``` Returns current vm level settings for volumes for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" ### Example 4 ```powershell -PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -nics +PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -nics ``` Returns current vm level settings for nics for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" ### Example 5 ```powershell -PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -basic +PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -basic ``` Returns current basic settings for vpgSettingsIdentifier "MySettingsIdentifier" From 5a10669403d96ed42036598c511ab764df6d58b3 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 10:14:11 -0400 Subject: [PATCH 09/26] Add Build Tasks for Help System --- ZertoApiWrapper.build.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 272353d..00e604a 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -51,3 +51,21 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI task FileTests CheckPesterInstalled, { Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails } + +$buildMamlParams = @{ + Inputs = { Get-ChildItem docs\*.md } + Outputs = ".\ZertoApiWrapper\Public\en-us\ZertoApiWrapper-help.xml" +} + +task BuildMamlHelp CheckPlatyPSInstalled, { + if (Test-Path $buildMamlParams.Outputs) { + Remove-Item $buildMamlParams.Outputs + } + platyPS\New-ExternalHelp .\docs -Force -OutputPath $buildMamlParams.Outputs +} + +task UpdateMarkdownHelp CheckPlatyPSInstalled, { + remove-module ZertoApiWrapper -force -ErrorAction SilentlyContinue + Import-Module .\ZertoApiWrapper\ZertoApiWrapper.psm1 -Force + Update-MarkDownHelp -Path docs -AlphabeticParamsOrder +} From 3e9f450208775091b32692baed99ee6ca38bae3a Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 10:32:23 -0400 Subject: [PATCH 10/26] Fix Test Publishing --- ZertoApiWrapper.build.ps1 | 3 ++- azure-pipelines.yml | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 00e604a..e469509 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -49,7 +49,8 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI } task FileTests CheckPesterInstalled, { - Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails + $testResultsFile = "$BuildRoot\Tests\Public\TestResults.xml" + Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -PassThru } $buildMamlParams = @{ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bf898f5..afbd413 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,15 +14,15 @@ jobs: - task: PublishTestResults@2 inputs: testRunner: 'NUnit' - testResultsFiles: '**/TestResults.xml' + testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PS_Win2016' displayName: 'Publish Test Results' - + - job: Build_PSCore_Ubuntu1604 - + pool: vmImage: ubuntu-16.04 - + steps: - script: | curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - @@ -30,18 +30,18 @@ jobs: sudo apt-get update sudo apt-get install -y powershell displayName: 'Install PowerShell Core' - + - script: | pwsh -c '.\build.ps1' displayName: 'Build and Test' - + - task: PublishTestResults@2 inputs: testRunner: 'NUnit' - testResultsFiles: '**/TestResults.xml' + testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PSCore_Ubuntu1604' displayName: 'Publish Test Results' - + - job: Build_PSCore_MacOS1013 pool: vmImage: xcode9-macos10.13 @@ -51,14 +51,14 @@ jobs: brew tap caskroom/cask brew cask install powershell displayName: 'Install PowerShell Core' - + - script: | pwsh -c '.\build.ps1' displayName: 'Build and Test' - + - task: PublishTestResults@2 inputs: testRunner: 'NUnit' - testResultsFiles: '**/TestResults.xml' + testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PSCore_MacOS1013' - displayName: 'Publish Test Results' \ No newline at end of file + displayName: 'Publish Test Results' From b460e87702081e5bb8ddd1e6d59f06a8989d0122 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 10:38:31 -0400 Subject: [PATCH 11/26] Add Build Status to README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6508ec2..15ad3b6 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ PowerShell Core wrapper for Zerto Virtual Manager API +## Current Build Status + +[![Build Status](https://dev.azure.com/wescarroll/wescarroll/_apis/build/status/wcarroll.ZertoApiWrapper?branchName=master)](https://dev.azure.com/wescarroll/wescarroll/_build/latest?definitionId=1&branchName=master) + ## Legal Disclaimer This script is an example script and is not supported under any Zerto support program or service. The author and Zerto further disclaim all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. From f085a8e5e021692bac3ef6cc0cfa8909b529cea4 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 11:01:32 -0400 Subject: [PATCH 12/26] Force Windows Test to PwSh --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index afbd413..633d063 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,7 +9,7 @@ jobs: vmImage: vs2017-win2016 steps: - powershell: | - .\build.ps1 -Verbose + pwsh -c '.\build.ps1 -Verbose' displayName: 'Build and Test' - task: PublishTestResults@2 inputs: From 5b56a0c15b7ade9f0ac44aeb5c1410ed0a823588 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 13:22:53 -0400 Subject: [PATCH 13/26] Update Build Process Remove unnecessary install calls, set timeouts for each job, and specify job name. --- azure-pipelines.yml | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 633d063..77f1202 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,12 +3,16 @@ # Add steps that build, run tests, deploy, and more: # https://aka.ms/yaml +name: $(TeamProject)_$(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.rr) + jobs: - job: Build_PS_Win2016 + timeoutInMinutes: 10 + cancelTimeoutInMinutes: 2 pool: vmImage: vs2017-win2016 steps: - - powershell: | + - script: | pwsh -c '.\build.ps1 -Verbose' displayName: 'Build and Test' - task: PublishTestResults@2 @@ -19,22 +23,14 @@ jobs: displayName: 'Publish Test Results' - job: Build_PSCore_Ubuntu1604 - + timeoutInMinutes: 10 + cancelTimeoutInMinutes: 2 pool: vmImage: ubuntu-16.04 - steps: - script: | - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list - sudo apt-get update - sudo apt-get install -y powershell - displayName: 'Install PowerShell Core' - - - script: | - pwsh -c '.\build.ps1' + pwsh -c '.\build.ps1 -verbose' displayName: 'Build and Test' - - task: PublishTestResults@2 inputs: testRunner: 'NUnit' @@ -43,19 +39,14 @@ jobs: displayName: 'Publish Test Results' - job: Build_PSCore_MacOS1013 + timeoutInMinutes: 10 + cancelTimeoutInMinutes: 2 pool: vmImage: xcode9-macos10.13 steps: - script: | - brew update - brew tap caskroom/cask - brew cask install powershell - displayName: 'Install PowerShell Core' - - - script: | - pwsh -c '.\build.ps1' + pwsh -c '.\build.ps1 -verbose' displayName: 'Build and Test' - - task: PublishTestResults@2 inputs: testRunner: 'NUnit' From 90e06a6dc580dfecb7188b283271b6dac5ebc910 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 13:52:03 -0400 Subject: [PATCH 14/26] Update az pipeline Windows Script Using single quotes will not execute the script. Changing to double quotes should actually run the build process on the Windows Host --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 77f1202..882dc54 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,7 +13,7 @@ jobs: vmImage: vs2017-win2016 steps: - script: | - pwsh -c '.\build.ps1 -Verbose' + pwsh -c ".\build.ps1 -Verbose" displayName: 'Build and Test' - task: PublishTestResults@2 inputs: From b8cccd02dcc0b1895ca2238839062c5b80f5a112 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 16:48:21 -0400 Subject: [PATCH 15/26] Ignore all files in Temp directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 03a576d..eece103 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.zip +temp/* From f6e0ffa6db0fe19ce1437712aa9db7810b86218f Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 08:27:13 -0400 Subject: [PATCH 16/26] Add MarkDown Help File Content Test --- Tests/Public/ZertoApiWrapper.Tests.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Tests/Public/ZertoApiWrapper.Tests.ps1 b/Tests/Public/ZertoApiWrapper.Tests.ps1 index b9f88f4..734c23f 100644 --- a/Tests/Public/ZertoApiWrapper.Tests.ps1 +++ b/Tests/Public/ZertoApiWrapper.Tests.ps1 @@ -34,6 +34,14 @@ Describe "File Tests" { it "$command has the External Help File Defined" { Get-Content -Path $path -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>" } + it "$command external Help file is filled out" { + $stubExist = Get-Content -Path $externalHelpFile | Where-Object {$_.Trim() -like '*{{*}}*'} + if ($stubExist) { + Write-Warning "Found a stub in the Markdown File $externalHelpFile" + Write-Warning "$stubExist" + } + $stubExist | should benullorempty + } } } } From 5f42804c0bcc902568c71bd5303b7c2538a242ce Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 08:27:44 -0400 Subject: [PATCH 17/26] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eece103..e4bc748 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.zip temp/* +Tests/Public/TestResults.xml From 47bc3be463dcf2894dc15258e414f8395dfb8cfc Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 08:27:50 -0400 Subject: [PATCH 18/26] Update LICENSE --- LICENSE | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index f288702..44122ce 100644 --- a/LICENSE +++ b/LICENSE @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - - Copyright (C) + ZertoApiWrapper + Copyright (C) 2019 Wes Carroll This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Copyright (C) + ZertoApiWrapper Copyright (C) 2019 Wes Carroll This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. From 802eef60673d8aeb992afba5b82d35eed2bc517b Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 10:19:23 -0400 Subject: [PATCH 19/26] Update Build to Fail on Pester Failure This is expected to fail the build test as one pester test will fail --- ZertoApiWrapper.build.ps1 | 86 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index e469509..76a18ca 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -8,7 +8,11 @@ param([switch]$Install, [string]$Configuration = (property Configuration Release)) $targetDir = "temp/$Configuration/ZertoApiWrapper" #> -task . Analyze, FileTests +$versionMajor = '0' +$versionMinor = '1' +$versionBuild = "{0}.{1}" -f $(get-date -format 'yyyyMMdd'), $env:Rev + +task . AnalyzeSourceFiles, CreateModule <# Synopsis: Ensure platyPS is installed #> task CheckPlatyPSInstalled { @@ -32,7 +36,7 @@ task CheckPSScriptAnalyzerInstalled { } <# Synopsis: Analyze ZertoApiWrapper functions for Code Violations #> -task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSInstalled, { +task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, { $scriptAnalyzerParams = @{ Path = "$BuildRoot\ZertoApiWrapper\" Severity = @('Error', 'Warning') @@ -41,6 +45,21 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions', 'PSUseToExportFieldsInManifest') } $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams + if ($saResults) { + $saResults | Format-Table + throw "One or more PSScriptAnalyzer errors/warnings were found" + } +} + +task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, { + $scriptAnalyzerParams = @{ + Path = "$BuildRoot\Temp\" + Severity = @('Error', 'Warning') + Recurse = $true + Verbose = $false + ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions', 'PSUseToExportFieldsInManifest') + } + $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams if ($saResults) { $saResults | Format-Table @@ -50,12 +69,14 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI task FileTests CheckPesterInstalled, { $testResultsFile = "$BuildRoot\Tests\Public\TestResults.xml" - Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -PassThru + $results = Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -OutputFormat NUnitXML -EnableExit -PassThru + $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount + assert ($results.FailedCount -eq 0) $FailureMessage } $buildMamlParams = @{ Inputs = { Get-ChildItem docs\*.md } - Outputs = ".\ZertoApiWrapper\Public\en-us\ZertoApiWrapper-help.xml" + Outputs = "temp\en-us\ZertoApiWrapper-help.xml" } task BuildMamlHelp CheckPlatyPSInstalled, { @@ -70,3 +91,60 @@ task UpdateMarkdownHelp CheckPlatyPSInstalled, { Import-Module .\ZertoApiWrapper\ZertoApiWrapper.psm1 -Force Update-MarkDownHelp -Path docs -AlphabeticParamsOrder } + +task CreatePsd1ForRelease CleanTemp, { + $functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName } + $ManifestParams = @{ + Path = "temp\ZertoApiWrapper.psd1" + RootModule = 'ZertoApiWrapper.psm1' + ModuleVersion = '{0}.{1}.{2}' -f $versionMajor, $versionMinor, $versionBuild + GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325' + Author = 'Wes Carroll' + CompanyName = 'Zerto' + Copyright = '(c) {0} Wes Carroll. All rights reserved.' -f $(Get-Date -format 'yyyy') + Description = 'PowerShell Core Wrapper Module for Zerto Virtual Manager API' + PowerShellVersion = '6.0.0' + ProjectUri = 'https://github.com/wcarroll/ZertoApiWrapper' + LicenseUri = 'https://github.com/wcarroll/ZertoApiWrapper/blob/master/LICENSE' + Tags = @("Zerto", "Automation") + FunctionsToExport = $functionsToExport + CmdletsToExport = @() + VariablesToExport = @() + AliasesToExport = @() + } + Write-Output $ManifestParams.ModuleVersion + New-ModuleManifest @ManifestParams +} + +task CleanTemp { + Remove-Item -Recurse -Path 'temp\*' +} + +task CreatePsm1ForRelease CreatePsd1ForRelease, { + $emptyLine = "" + $psm1Path = "temp\ZertoApiWrapper.psm1" + $lines = '#------------------------------------------------------------#' + $Public = @( Get-ChildItem -Path $PSScriptRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction SilentlyContinue ) + $Private = @( Get-ChildItem -Path $PSScriptRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction SilentlyContinue ) + Add-Content -Path $psm1Path -Value $lines + Add-Content -Path $psm1Path -Value "#---------------------Private Functions----------------------#" + Add-Content -Path $psm1Path -Value $lines + Add-Content -Path $psm1Path -Value $emptyLine + foreach ($file in $private) { + Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) + Add-Content -Path $psm1Path -Value $emptyLine + } + Add-Content -Path $psm1Path -Value $lines + Add-Content -Path $psm1Path -Value "#----------------------Public Functions----------------------#" + Add-Content -Path $psm1Path -Value $lines + Add-Content -Path $psm1Path -Value $emptyLine + foreach ($file in $public) { + Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) + Add-Content -Path $psm1Path -Value $emptyLine + } +} + +task CreateModule CleanTemp, FileTests, CreatePsd1ForRelease, CreatePsm1ForRelease, AnalyzeBuiltFiles, BuildMamlHelp, { + +} + From 1fc7bf697e3dd69bd5668b3a49132c5778cd2fd7 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 10:25:46 -0400 Subject: [PATCH 20/26] Create temp folder if it doesn't exist --- ZertoApiWrapper.build.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 76a18ca..751f4bb 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -117,6 +117,9 @@ task CreatePsd1ForRelease CleanTemp, { } task CleanTemp { + if (-not $(Test-Path "$BuildRoot\temp")) { + New-Item -Path $BuildRoot -Name "temp" -ItemType "Directory" + } Remove-Item -Recurse -Path 'temp\*' } From 3c1cdef3a58082cfc3c272cf0bc9282aef4914f3 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 10:51:45 -0400 Subject: [PATCH 21/26] Set Tests to Always Publish --- ZertoApiWrapper.build.ps1 | 2 +- azure-pipelines.yml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 751f4bb..b433623 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -69,7 +69,7 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, { task FileTests CheckPesterInstalled, { $testResultsFile = "$BuildRoot\Tests\Public\TestResults.xml" - $results = Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -OutputFormat NUnitXML -EnableExit -PassThru + $script:results = Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -PassThru $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount assert ($results.FailedCount -eq 0) $FailureMessage } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 882dc54..3baef72 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,6 +21,7 @@ jobs: testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PS_Win2016' displayName: 'Publish Test Results' + condition: always() - job: Build_PSCore_Ubuntu1604 timeoutInMinutes: 10 @@ -37,6 +38,7 @@ jobs: testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PSCore_Ubuntu1604' displayName: 'Publish Test Results' + condition: always() - job: Build_PSCore_MacOS1013 timeoutInMinutes: 10 @@ -53,3 +55,4 @@ jobs: testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PSCore_MacOS1013' displayName: 'Publish Test Results' + condition: always() From ef39b549371d1ab043a5acf5273f4b91e6a26c34 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 11:10:16 -0400 Subject: [PATCH 22/26] Update Get-ZertoVirtualizationSite Help --- .../Public/en-us/ZertoApiWrapper-help.xml | 29 ++++++++++++++--- docs/Get-ZertoVirtualizationSite.md | 31 ++++++++++++++++--- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml index 03653be..98cacd1 100644 --- a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml +++ b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml @@ -3859,11 +3859,11 @@ Get ZertoVirtualizationSite - {{Fill in the Synopsis}} + Returns information about the hypervisor site where the API is run and all the sites paired with this site. The information returned can be tailored to specific information about the resources managed at a specified site. - {{Fill in the Description}} + Returns information about the hypervisor site where the API is run and all the sites paired with this site. The information returned can be tailored to specific information about the resources managed at a specified site. @@ -4302,9 +4302,30 @@ -------------------------- Example 1 -------------------------- - PS C:\> {{ Add example code here }} + PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" - {{ Add example description here }} + Returns information about the site with identifier "MySiteIdentifier" + + + + -------------------------- Example 2 -------------------------- + PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -datastoreClusters + + Returns information about datastore clusters at site with site identifier "MySiteidentifier" + + + + -------------------------- Example 3 -------------------------- + PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -datastores + + Returns information about datastores at site with site identifier "MySiteidentifier" + + + + -------------------------- Example 4 -------------------------- + PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -devices + + Returns information about devices at site with site identifier "MySiteidentifier" diff --git a/docs/Get-ZertoVirtualizationSite.md b/docs/Get-ZertoVirtualizationSite.md index 049d2e9..7f44405 100644 --- a/docs/Get-ZertoVirtualizationSite.md +++ b/docs/Get-ZertoVirtualizationSite.md @@ -8,7 +8,8 @@ schema: 2.0.0 # Get-ZertoVirtualizationSite ## SYNOPSIS -{{Fill in the Synopsis}} + +Returns information about the hypervisor site where the API is run and all the sites paired with this site. The information returned can be tailored to specific information about the resources managed at a specified site. ## SYNTAX @@ -68,16 +69,38 @@ Get-ZertoVirtualizationSite -siteIdentifier [] ``` ## DESCRIPTION -{{Fill in the Description}} + +Returns information about the hypervisor site where the API is run and all the sites paired with this site. The information returned can be tailored to specific information about the resources managed at a specified site. ## EXAMPLES ### Example 1 ```powershell -PS C:\> {{ Add example code here }} +PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" ``` -{{ Add example description here }} +Returns information about the site with identifier "MySiteIdentifier" + +### Example 2 +```powershell +PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -datastoreClusters +``` + +Returns information about datastore clusters at site with site identifier "MySiteidentifier" + +### Example 3 +```powershell +PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -datastores +``` + +Returns information about datastores at site with site identifier "MySiteidentifier" + +### Example 4 +```powershell +PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -devices +``` + +Returns information about devices at site with site identifier "MySiteidentifier" ## PARAMETERS From 91cd6a2de5aa084f3ab17bd18fe38aba7786d0bb Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 11:22:14 -0400 Subject: [PATCH 23/26] Update Build to show Env Var --- ZertoApiWrapper.build.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index b433623..83ea8c5 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -10,7 +10,7 @@ $targetDir = "temp/$Configuration/ZertoApiWrapper" #> $versionMajor = '0' $versionMinor = '1' -$versionBuild = "{0}.{1}" -f $(get-date -format 'yyyyMMdd'), $env:Rev +$versionBuild = "{0}.{1}" -f $(get-date -format 'yyyyMMdd'), "$env:Rev:.r" task . AnalyzeSourceFiles, CreateModule @@ -112,6 +112,8 @@ task CreatePsd1ForRelease CleanTemp, { VariablesToExport = @() AliasesToExport = @() } + $myEnv = Get-Item Env: + Write-Output $myEnv Write-Output $ManifestParams.ModuleVersion New-ModuleManifest @ManifestParams } From 6899ded49e17c33bf461a18e45bd5aca929ef36e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 11:37:54 -0400 Subject: [PATCH 24/26] Update Build Version Methodology --- ZertoApiWrapper.build.ps1 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 83ea8c5..911780f 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -10,7 +10,7 @@ $targetDir = "temp/$Configuration/ZertoApiWrapper" #> $versionMajor = '0' $versionMinor = '1' -$versionBuild = "{0}.{1}" -f $(get-date -format 'yyyyMMdd'), "$env:Rev:.r" +$versionBuild = "{0}" -f $(get-date -format 'yyyyMMdd') task . AnalyzeSourceFiles, CreateModule @@ -112,9 +112,6 @@ task CreatePsd1ForRelease CleanTemp, { VariablesToExport = @() AliasesToExport = @() } - $myEnv = Get-Item Env: - Write-Output $myEnv - Write-Output $ManifestParams.ModuleVersion New-ModuleManifest @ManifestParams } From a6446c084979020b523e7381af0acb7d3442761f Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 11:45:55 -0400 Subject: [PATCH 25/26] Update temp for case-sensitive environments --- ZertoApiWrapper.build.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 911780f..b21dd4f 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -53,7 +53,7 @@ task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, { task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, { $scriptAnalyzerParams = @{ - Path = "$BuildRoot\Temp\" + Path = "$BuildRoot\temp\" Severity = @('Error', 'Warning') Recurse = $true Verbose = $false @@ -76,7 +76,7 @@ task FileTests CheckPesterInstalled, { $buildMamlParams = @{ Inputs = { Get-ChildItem docs\*.md } - Outputs = "temp\en-us\ZertoApiWrapper-help.xml" + Outputs = "$BuildRoot\temp\en-us\ZertoApiWrapper-help.xml" } task BuildMamlHelp CheckPlatyPSInstalled, { @@ -95,7 +95,7 @@ task UpdateMarkdownHelp CheckPlatyPSInstalled, { task CreatePsd1ForRelease CleanTemp, { $functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName } $ManifestParams = @{ - Path = "temp\ZertoApiWrapper.psd1" + Path = "$BuildRoot\temp\ZertoApiWrapper.psd1" RootModule = 'ZertoApiWrapper.psm1' ModuleVersion = '{0}.{1}.{2}' -f $versionMajor, $versionMinor, $versionBuild GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325' @@ -119,12 +119,12 @@ task CleanTemp { if (-not $(Test-Path "$BuildRoot\temp")) { New-Item -Path $BuildRoot -Name "temp" -ItemType "Directory" } - Remove-Item -Recurse -Path 'temp\*' + Remove-Item -Recurse -Path "$BuildRoot\temp\*" } task CreatePsm1ForRelease CreatePsd1ForRelease, { $emptyLine = "" - $psm1Path = "temp\ZertoApiWrapper.psm1" + $psm1Path = "$BuildRoot\temp\ZertoApiWrapper.psm1" $lines = '#------------------------------------------------------------#' $Public = @( Get-ChildItem -Path $PSScriptRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction SilentlyContinue ) $Private = @( Get-ChildItem -Path $PSScriptRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction SilentlyContinue ) From 64c089f3ec59af7ed5cd16cdb065b30ae3a340c3 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 11:46:21 -0400 Subject: [PATCH 26/26] Update README.md Azure Pipeline Badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15ad3b6..e2f76cc 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ PowerShell Core wrapper for Zerto Virtual Manager API ## Current Build Status -[![Build Status](https://dev.azure.com/wescarroll/wescarroll/_apis/build/status/wcarroll.ZertoApiWrapper?branchName=master)](https://dev.azure.com/wescarroll/wescarroll/_build/latest?definitionId=1&branchName=master) +[![Build Status](https://dev.azure.com/wescarroll/ZertoApiWrapper/_apis/build/status/wcarroll.ZertoApiWrapper?branchName=master)](https://dev.azure.com/wescarroll/ZertoApiWrapper/_build/latest?definitionId=1&branchName=master) ## Legal Disclaimer