-
-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update-DbaBuildReference - Add Parameter Proxy #9174
Open
fm-knopfler
wants to merge
14
commits into
dataplat:development
Choose a base branch
from
fm-knopfler:buildref_proxy
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8e4a9e6
Update-DbaBuildReference - Add Parameter Proxy
ffa0a6c
Update-DbaBuildReference - Proxy Credential
4a04512
Invoke-TlsWebRequest - UseBasicParsing Parameter
5ece7fc
Merge branch 'development' of github.com:dataplat/dbatools into build…
00fcdae
polished PR
niphlod 3fad3a4
fixed formatting and params checking for inline help
niphlod 4630855
Explicitly declare parameters
b9122a3
Merge branch 'development' of github.com:dataplat/dbatools into build…
7499703
Merge branch 'development' of github.com:dataplat/dbatools into build…
ea83351
Use dbatools config for proxy settings
0b205e4
put that back
potatoqualitee d49a195
Update InModule.Help.Tests.ps1
potatoqualitee fc8537b
put it back
potatoqualitee d0171d4
add proxy info
potatoqualitee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Set-DbatoolsConfig -FullName network.proxy.url -Value $null -Initialize -Validation string -Description "The URL of the network proxy." | ||
Set-DbatoolsConfig -FullName network.proxy.username -Value $null -Initialize -Validation string -Description "The username for the network proxy." | ||
Set-DbatoolsConfig -FullName network.proxy.securepassword -Value $null -Initialize -Validation securestring -Description "The secure password for the network proxy." | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,16 +53,28 @@ function Update-DbaBuildReference { | |
$EnableException | ||
) | ||
$url = Get-DbatoolsConfigValue -Name 'assets.sqlbuildreference' | ||
$proxyUrl = Get-DbatoolsConfigValue -FullName network.proxy.url | ||
$proxyUsername = Get-DbatoolsConfigValue -FullName network.proxy.username | ||
$proxySecurePassword = Get-DbatoolsConfigValue -FullName network.proxy.securepassword | ||
if ($proxyUsername) { | ||
$proxyCredential = New-Object System.Management.Automation.PSCredential ($proxyUsername, $proxySecurePassword) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I'm more for this being embedded into |
||
try { | ||
$webContent = Invoke-TlsWebRequest $url -UseBasicParsing -ErrorAction Stop | ||
} catch { | ||
try { | ||
Write-Message -Level Verbose -Message "Probably using a proxy for internet access, trying default proxy settings" | ||
(New-Object System.Net.WebClient).Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials | ||
$webContent = Invoke-TlsWebRequest $url -UseBasicParsing -ErrorAction Stop | ||
Write-Message -Level Verbose -Message "Probably using a proxy for internet access, trying dbatools proxy settings" | ||
$webContent = Invoke-TlsWebRequest $url -Proxy:$proxyUrl -ProxyCredential:$proxyCredential -UseBasicParsing -ErrorAction Stop | ||
} catch { | ||
Write-Message -Level Warning -Message "Couldn't download updated index from $url" | ||
return | ||
try { | ||
Write-Message -Level Verbose -Message "Probably using a proxy for internet access, trying default proxy settings" | ||
(New-Object System.Net.WebClient).Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials | ||
$webContent = Invoke-TlsWebRequest $url -UseBasicParsing -ErrorAction Stop | ||
} catch { | ||
Write-Message -Level Warning -Message "Couldn't download updated index from $url" | ||
return | ||
} | ||
} | ||
} | ||
return $webContent.Content | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I've ever tried but is there any reason we couldn't just squash these two into a config that holds the credential object itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wsmelton i believe this is a limitation of the securestring type. fred said it was very complicated.