Skip to content

Commit 36bdd08

Browse files
authored
Merge pull request #765 from BornToBeRoot/feature/mysql-connector
Feature: mySQL Connector ODBC & NET
2 parents 2519b5c + 2556df3 commit 36bdd08

File tree

6 files changed

+167
-17
lines changed

6 files changed

+167
-17
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
function Get-mySQLConnectorNET {
2+
<#
3+
.NOTES
4+
Author: BornToBeRoot
5+
Twitter: @BornToBeRoot
6+
#>
7+
[OutputType([System.Management.Automation.PSObject])]
8+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "Product name is a plural")]
9+
[CmdletBinding(SupportsShouldProcess = $False)]
10+
param (
11+
[Parameter(Mandatory = $False, Position = 0)]
12+
[ValidateNotNull()]
13+
[System.Management.Automation.PSObject]
14+
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
15+
)
16+
17+
# Get latest repo tag
18+
$Tags = Get-GitHubRepoTag -Uri $res.Get.Update.Uri
19+
20+
$Version = ($Tags | Sort-Object -Property @{ Expression = { [System.Version]$_.Tag }; Descending = $true } | Select-Object -First 1).Tag
21+
22+
# Build the output object
23+
if ($Null -ne $Version) {
24+
foreach ($Architecture in $res.Get.Download.Uri.GetEnumerator()) {
25+
26+
# https://dev.mysql.com/get/Downloads/Connector-ODBC/9.1/mysql-connector-odbc-9.1.0-winx64.msi
27+
# redirect to
28+
# https://cdn.mysql.com//Downloads/Connector-ODBC/9.1/mysql-connector-odbc-9.1.0-winx64.msi
29+
#
30+
# The sub path is only major.minor
31+
# The version ist major.minor.patch, while the tag can have also have major.minor.patch.build
32+
$Uri = $res.Get.Download.Uri[$Architecture.Key] -replace $res.Get.Download.ReplaceVersionShort, (($Version -split '\.')[0, 1] -join '.') -replace $res.Get.Download.ReplaceVersion, (($Version -split '\.')[0..2] -join '.')
33+
34+
$CdnUri = (Invoke-WebRequest $Uri -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction:SilentlyContinue).Headers.Location[0]
35+
36+
$PSObject = [PSCustomObject] @{
37+
Version = $Version
38+
Type = Get-FileType -File $Uri
39+
Architecture = $Architecture.Name
40+
URI = $CdnUri
41+
}
42+
Write-Output -InputObject $PSObject
43+
}
44+
}
45+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
function Get-mySQLConnectorODBC {
2+
<#
3+
.NOTES
4+
Author: BornToBeRoot
5+
Twitter: @BornToBeRoot
6+
#>
7+
[OutputType([System.Management.Automation.PSObject])]
8+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "Product name is a plural")]
9+
[CmdletBinding(SupportsShouldProcess = $False)]
10+
param (
11+
[Parameter(Mandatory = $False, Position = 0)]
12+
[ValidateNotNull()]
13+
[System.Management.Automation.PSObject]
14+
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
15+
)
16+
17+
# Get latest repo tag
18+
$Tags = Get-GitHubRepoTag -Uri $res.Get.Update.Uri
19+
20+
$Version = ($Tags | Sort-Object -Property @{ Expression = { [System.Version]$_.Tag }; Descending = $true } | Select-Object -First 1).Tag
21+
22+
# Build the output object
23+
if ($Null -ne $Version) {
24+
foreach ($Architecture in $res.Get.Download.Uri.GetEnumerator()) {
25+
26+
# https://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-9.1.0.msi
27+
# redirect to
28+
# https://cdn.mysql.com//Downloads/Connector-Net/mysql-connector-net-9.1.0.msi
29+
#
30+
# The version ist major.minor.patch, while the tag can have also have major.minor.patch.build
31+
$Uri = $res.Get.Download.Uri[$Architecture.Key] -replace $res.Get.Download.ReplaceVersion, (($Version -split '\.')[0..2] -join '.')
32+
33+
$CdnUri = (Invoke-WebRequest $Uri -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction:SilentlyContinue).Headers.Location[0]
34+
35+
$PSObject = [PSCustomObject] @{
36+
Version = $Version
37+
Type = Get-FileType -File $Uri
38+
Architecture = $Architecture.Name
39+
URI = $CdnUri
40+
}
41+
Write-Output -InputObject $PSObject
42+
}
43+
}
44+
}

Evergreen/Apps/Get-mySQLWorkbench.ps1

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function Get-mySQLWorkbench {
55
Twitter: @stealthpuppy
66
#>
77
[OutputType([System.Management.Automation.PSObject])]
8-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification="Product name is a plural")]
8+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "Product name is a plural")]
99
[CmdletBinding(SupportsShouldProcess = $False)]
1010
param (
1111
[Parameter(Mandatory = $False, Position = 0)]
@@ -14,24 +14,29 @@ function Get-mySQLWorkbench {
1414
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
1515
)
1616

17-
# Pass the repo releases API URL and return a formatted object
18-
$params = @{
19-
Uri = $res.Get.Update.Uri
20-
MatchVersion = $res.Get.Update.MatchVersion
21-
Filter = $res.Get.Update.MatchFileTypes
22-
ReturnVersionOnly = $True
23-
}
24-
$object = Get-GitHubRepoRelease @params
17+
# Get latest repo tag
18+
$Tags = Get-GitHubRepoTag -Uri $res.Get.Update.Uri
19+
20+
$Version = ($Tags | Sort-Object -Property @{ Expression = { [System.Version]$_.Tag }; Descending = $true } | Select-Object -First 1).Tag
2521

2622
# Build the output object
27-
if ($Null -ne $object) {
23+
if ($Null -ne $Version) {
2824
foreach ($Architecture in $res.Get.Download.Uri.GetEnumerator()) {
29-
$Uri = $res.Get.Download.Uri[$Architecture.Key] -replace $res.Get.Download.ReplaceText, $object.Version
25+
26+
# https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-workbench-community-8.0.40-winx64.msi
27+
# redirect to
28+
# https://cdn.mysql.com//Downloads/MySQLGUITools/mysql-workbench-community-8.0.40-winx64.msi
29+
#
30+
# The version ist major.minor.patch, while the tag can have also have major.minor.patch.build
31+
$Uri = $res.Get.Download.Uri[$Architecture.Key] -replace $res.Get.Download.ReplaceVersion, (($Version -split '\.')[0..2] -join '.')
32+
33+
$CdnUri = (Invoke-WebRequest $Uri -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction:SilentlyContinue).Headers.Location[0]
34+
3035
$PSObject = [PSCustomObject] @{
31-
Version = $object.Version
36+
Version = $Version
3237
Type = Get-FileType -File $Uri
3338
Architecture = $Architecture.Name
34-
URI = $Uri
39+
URI = $CdnUri
3540
}
3641
Write-Output -InputObject $PSObject
3742
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"Name": "mySQL Connector NET",
3+
"Source": "https://dev.mysql.com/doc/connector-net/en/",
4+
"Get": {
5+
"Update": {
6+
"Uri": "https://api.github.com/repos/mysql/mysql-connector-net/tags"
7+
},
8+
"Download": {
9+
"Uri": {
10+
"x64": "https://dev.mysql.com/get/Downloads/Connector-ODBC/#versionshort/mysql-connector-odbc-#version-winx64.msi"
11+
},
12+
"ReplaceVersion": "#version",
13+
"ReplaceVersionShort": "#versionshort"
14+
}
15+
},
16+
"Install": {
17+
"Setup": "",
18+
"Preinstall": "",
19+
"Physical": {
20+
"Arguments": "",
21+
"PostInstall": []
22+
},
23+
"Virtual": {
24+
"Arguments": "",
25+
"PostInstall": []
26+
}
27+
}
28+
}
29+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"Name": "mySQL Connector ODCB",
3+
"Source": "https://dev.mysql.com/doc/connector-odbc/en/",
4+
"Get": {
5+
"Update": {
6+
"Uri": "https://api.github.com/repos/mysql/mysql-connector-odbc/tags"
7+
},
8+
"Download": {
9+
"Uri": {
10+
"x64": "https://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-#version.msi"
11+
},
12+
"ReplaceVersion": "#version"
13+
}
14+
},
15+
"Install": {
16+
"Setup": "",
17+
"Preinstall": "",
18+
"Physical": {
19+
"Arguments": "",
20+
"PostInstall": [
21+
]
22+
},
23+
"Virtual": {
24+
"Arguments": "",
25+
"PostInstall": [
26+
]
27+
}
28+
}
29+
}

Evergreen/Manifests/mySQLWorkbench.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
"Source": "https://dev.mysql.com/doc/workbench/en/",
44
"Get": {
55
"Update": {
6-
"Uri": "https://api.github.com/repos/mysql/mysql-workbench/tags",
7-
"MatchVersion": "(\\d+(\\.\\d+){1,4}).*",
8-
"MatchFileTypes": "\\.exe$"
6+
"Uri": "https://api.github.com/repos/mysql/mysql-workbench/tags"
97
},
108
"Download": {
119
"Uri": {
1210
"x64": "https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-workbench-community-#version-winx64.msi"
1311
},
14-
"ReplaceText": "#version"
12+
"ReplaceVersion": "#version"
1513
}
1614
},
1715
"Install": {

0 commit comments

Comments
 (0)