Skip to content

Commit d1e1edd

Browse files
authored
Merge pull request #144 from dataplat/development
v0.8.0
2 parents 7ded3d2 + 410f309 commit d1e1edd

12 files changed

+64
-13
lines changed

build/bump_version.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Param (
22
$Path = '.\dbops.psd1'
33
)
4-
git config --global user.email $env:git_user_email
5-
git config --global user.name $env:git_username
4+
git config --global user.email $env:GIT_USER_EMAIL
5+
git config --global user.name $env:GIT_USERNAME
66
$moduleFile = Invoke-Command -ScriptBlock ([scriptblock]::Create((Get-Content $Path -Raw)))
77
$version = [Version]$moduleFile.ModuleVersion
88
$regEx = "^([\s]*ModuleVersion[\s]*\=[\s]*)\'(" + [regex]::Escape($version) + ")\'[\s]*`$"

dbops.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RootModule = 'dbops.psm1'
55

66
# Version number of this module.
7-
ModuleVersion = '0.7.0'
7+
ModuleVersion = '0.7.1'
88

99
# ID used to uniquely identify this module
1010
GUID = '16dff216-533a-4fa3-9b2e-4408dbe15e63'

dbops.psm1

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,25 @@ Register-PSFConfigValidation -Name "connectionType" -ScriptBlock {
116116
return $Result
117117
}
118118

119+
Register-PSFConfigValidation -Name "errorAction" -ScriptBlock {
120+
Param (
121+
$Value
122+
)
123+
$Result = New-Object PSObject -Property @{
124+
Success = $True
125+
Value = $null
126+
Message = ""
127+
}
128+
try {
129+
$Result.Value = [String][System.Management.Automation.ActionPreference]$Value
130+
}
131+
catch {
132+
$Result.Message = $_.Exception.Message
133+
$Result.Success = $False
134+
}
135+
return $Result
136+
}
137+
119138
Register-PSFConfigValidation -Name "tokenRegex" -ScriptBlock {
120139
Param (
121140
$Value
@@ -175,6 +194,10 @@ Set-PSFConfig -FullName dbops.package.slim -Value $false -Validation bool -Initi
175194
Set-PSFConfig -FullName dbops.config.variabletoken -Value "\#\{(token)\}" -Validation tokenRegex -Initialize -Description "Variable replacement token. Regex string that will be replaced with values from -Variables parameters. Default: \#\{(token)\}"
176195
$dotNet = try { dotnet --version } catch { $null }
177196
Set-PSFConfig -FullName dbops.runtime.dotnetversion -Value ($dotNet -as [version]) -Description "Current dotnet runtime." -Hidden
197+
Set-PSFConfig -FullName dbops.ErrorActionPreference -Value Stop -Initialize -Description "Module ErrorAction default value" -Validation errorAction
198+
199+
# Module-wide ErrorAction preference
200+
$ErrorActionPreference = Get-PSFConfigValue -FullName dbops.ErrorActionPreference
178201

179202
# extensions for SMO
180203
$typeData = Get-TypeData -TypeName 'Microsoft.SqlServer.Management.Smo.Database'
@@ -213,4 +236,4 @@ $aliases = @(
213236
)
214237
$aliases | ForEach-Object {
215238
if (-not (Test-Path Alias:$($_.AliasName))) { Set-Alias -Scope Global -Name $($_.AliasName) -Value $($_.Definition) }
216-
}
239+
}

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Release notes for v0.8.0:
2+
- ### Hotfix: Nuget downloads now use lowercase filename in the URL (#139) by @nvarscar
3+
- ### Feature: Allow ErrorAction to properly handle errors (#140) by @nvarscar
4+
- ### Setting default encoding to UTF8 (#142) by @nvarscar
15
# Release notes for v0.7.1:
26
- ### Adding support for underscore char in tokens (#130) by @nvarscar
37
# Release notes for v0.7.0:

functions/Invoke-DBOQuery.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ function Invoke-DBOQuery {
427427
}
428428
catch {
429429
# don't really need anything else here
430-
throw $_
430+
Write-Error $_
431431
}
432432
finally {
433433
# close the connection even when interrupted by Ctrl+C

internal/classes/DBOpsDeploymentStatus.class.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class DBOpsDeploymentStatus {
1010
[System.Nullable[datetime]] $StartTime
1111
[System.Nullable[datetime]] $EndTime
1212
[string[]] $DeploymentLog
13+
[string] $ErrorScript
1314

1415
DBOpsDeploymentStatus() {
1516
Add-Member -InputObject $this -MemberType ScriptProperty -Name Duration -Value {

internal/classes/DBOpsHelper.class.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ class DBOpsHelper {
137137
$encoding = [System.Text.Encoding]::UTF7
138138
}
139139
else {
140-
$encoding = [System.Text.Encoding]::ASCII
140+
$encoding = [System.Text.Encoding]::UTF8
141141
}
142142
return $encoding.GetString($Array, $skipBytes, $Array.Length - $skipBytes)
143143
}
144144
# scrubs nulls from the datatable
145-
static [PSObject] DataRowToPSObject([DataRow] $row){
145+
static [PSObject] DataRowToPSObject([DataRow] $row) {
146146
$psObject = [PSObject]::new()
147147
if ($null -ne $row -and $row.RowState -and $row.RowState -ne [DataRowState]::Detached) {
148148
foreach ($column in $row.Table.Columns) {

internal/functions/Install-NugetPackage.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function Install-NugetPackage {
6666

6767
# download and extract the files
6868
Write-PSFMessage -Level Verbose -Message "Version $selectedVersion of $packageName was selected"
69-
$fileName = "$packageName.$selectedVersion.nupkg"
69+
$fileName = "$packageName.$selectedVersion.nupkg".ToLower()
7070
# Path reference: https://github.com/OneGet/oneget/blob/master/src/Microsoft.PackageManagement/Utility/Platform/OSInformation.cs
7171
$scopePath = switch ($Scope) {
7272
'AllUsers' {

internal/functions/Invoke-Deployment.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@
134134
if (!$Status.Successful) {
135135
# Throw output error if unsuccessful
136136
if ($Status.Error) {
137+
if ($upgradeResult.errorScript) {
138+
$Status.ErrorScript = $upgradeResult.errorScript.Name
139+
}
137140
throw $Status.Error
138141
}
139142
else {
@@ -349,12 +352,12 @@
349352
}
350353
}
351354
catch {
352-
throw $_
355+
Write-Error $_
353356
}
354357
finally {
355358
$status.EndTime = [datetime]::Now
356-
$status
357359
}
360+
return $status
358361
}
359362
}
360363
end { }

internal/xml/dbops.format.ps1xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
<ListItem>
109109
<PropertyName>Duration</PropertyName>
110110
</ListItem>
111+
<ListItem>
112+
<PropertyName>ErrorScript</PropertyName>
113+
</ListItem>
111114
</ListItems>
112115
</ListEntry>
113116
</ListEntries>

0 commit comments

Comments
 (0)