-
Notifications
You must be signed in to change notification settings - Fork 157
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
Removing Dynamic parameters #275
Closed
Closed
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
33fe74a
Add parameter classes
95860f6
import classes via PSD1, add exportFunctions list
a265bc7
Replace dynamic parameters with clasess
a42840a
Move _Supports* functionality into calling fn
da9245e
remove _isonwindows
2beaa35
remove _applyTypes
978e0cc
fix break of Add-VSteamWorkItem, improve build
1fd09ed
Merge remote-tracking branch 'upstream/master'
jhoneill c27dc5f
Use Invoke-VSTeamRequest externally and make _callApi Private again
jhoneill 688bdf4
Auto-update of md help with 6.4.4 changes
e2bb372
Allow $env:testing to bypass validation checks
3467ddd
fix issue Getting build artifacts with no properties field
427114f
Fix regressions and modify mocking in tests to work with new classes
jhoneill d1bc72f
ensure validator doesn't break tests fix a couple more regressions & …
jhoneill 99871e2
Merge remote-tracking branch 'upstream/master'
jhoneill 7af8dab
Merge remote-tracking branch 'upstream/master'
jhoneill 2fab630
Tidy class loading - Merge classes to PSM1 file.
51d9b49
Merge remote-tracking branch 'upstream/master'
jhoneill 9d53c00
fix ProcessCompleter
e990b83
fix ProcessCompleter
80fcb5f
Merge branch 'master' of https://github.com/jhoneill/vsteam
jhoneill 2608b10
Fixed tests to not mix source & built files.
fed84c4
Re-introduced a mockable to help one test (CI has 3 param not founds …
jhoneill abdb3a1
Fix build when file encodings are mixed
jhoneill 2dea841
Merge remote-tracking branch 'upstream/master'
jhoneill 615f08e
Merge remote-tracking branch 'upstream/master'
jhoneill bc18fa0
Meged update up to #283 from Upstream
jhoneill 8a2ee54
Remove strict mode see DarqueWarrior/vsteam # 296
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 was deleted.
Oops, something went wrong.
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
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
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
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
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
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,16 @@ | ||
class BuildCompleter : System.Management.Automation.IArgumentCompleter { | ||
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( | ||
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete, | ||
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters | ||
) { | ||
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new() | ||
if ($Global:PSDefaultParameterValues["*:projectName"]){ | ||
foreach ($b in (Get-VSTeamBuild -ProjectName $Global:PSDefaultParameterValues["*:projectName"]).name ) { | ||
if ($b -like "*$WordToComplete*") { | ||
$results.Add([System.Management.Automation.CompletionResult]::new($b)) | ||
} | ||
} | ||
} | ||
return $results | ||
} | ||
} |
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,16 @@ | ||
class BuildDefinitionCompleter : System.Management.Automation.IArgumentCompleter { | ||
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( | ||
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete, | ||
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters | ||
) { | ||
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new() | ||
if ($Global:PSDefaultParameterValues["*:projectName"]){ | ||
foreach ($b in (Get-VSTeamBuildDefinition -ProjectName $Global:PSDefaultParameterValues["*:projectName"]).name ) { | ||
if ($b -like "*$WordToComplete*") { | ||
$results.Add([System.Management.Automation.CompletionResult]::new($b)) | ||
} | ||
} | ||
} | ||
return $results | ||
} | ||
} |
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,19 @@ | ||
class ProcessCompleter : System.Management.Automation.IArgumentCompleter { | ||
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( | ||
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete, | ||
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters | ||
) { | ||
$minutesNow = (Get-Date).TimeOfDay.TotalMinutes | ||
if ( ([VSTeamProcessCache]::timestamp + 100 -lt $minutesNow) -and ( [VSTeamVersions]::Account) ) { | ||
[VSTeamProcessCache]::processes = (Invoke-VSTeamRequest -url ('{0}/_apis/process/processes?api-version={1}&stateFilter=All&$top=9999' -f [VSTeamVersions]::Account, [VSTeamVersions]::Core )).value.name | ||
[VSTeamProcessCache]::timestamp = $minutesNow | ||
} | ||
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new() | ||
foreach ($p in [VSTeamProcessCache]::processes ) { | ||
if ($p -like "*$WordToComplete*") { | ||
$results.Add([System.Management.Automation.CompletionResult]::new($p)) | ||
} | ||
} | ||
return $results | ||
} | ||
} |
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,23 @@ | ||
class ProjectCompleter : System.Management.Automation.IArgumentCompleter { | ||
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( | ||
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete, | ||
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters | ||
) { | ||
if ( [VSTeamVersions]::Account -and | ||
([VSTeamProjectCache]::timestamp -lt 0 -or | ||
[VSTeamProjectCache]::timestamp -lt [datetime]::Now.TimeOfDay.TotalMinutes - 5) ) { | ||
[VSTeamProjectCache]::projects = (Invoke-VSTeamRequest -url ('{0}/_apis/projects?api-version={1}&stateFilter=All&$top=9999' -f [VSTeamVersions]::Account, [VSTeamVersions]::Core )).value.name | ||
[VSTeamProjectCache]::timestamp = (Get-Date).TimeOfDay.TotalMinutes | ||
} | ||
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new() | ||
foreach ($p in [VSTeamProjectCache]::projects ) { | ||
if ($p -like "*$WordToComplete*" -and $p -match "\s") { | ||
$results.Add([System.Management.Automation.CompletionResult]::new("'$p'")) | ||
} | ||
elseif ($p -like "*$WordToComplete*"){ | ||
$results.Add([System.Management.Automation.CompletionResult]::new($p)) | ||
} | ||
} | ||
return $results | ||
} | ||
} |
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,28 @@ | ||
class QueryCompleter : System.Management.Automation.IArgumentCompleter { | ||
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( | ||
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete, | ||
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters | ||
) { | ||
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new() | ||
$projName = $FakeBoundParameters['ProjectName'] | ||
if (-not $projName -and $Global:PSDefaultParameterValues["*:projectName"]) { | ||
$projName = $Global:PSDefaultParameterValues["*:projectName"] | ||
} | ||
if (-not $projName) {return $results} | ||
if ([VSTeamQueryCache]::timestamp -lt 0 -or | ||
[VSTeamQueryCache]::timestamp -lt [datetime]::Now.TimeOfDay.TotalMinutes -5) { | ||
[VSTeamQueryCache]::queries = (Invoke-VSTeamRequest -ProjectName $projName -Area wit -Resource queries -version ([vsteamversions]::core) -QueryString @{'$depth'=1} | ||
).value.children | Select-Object Name,ID | Sort-Object Name | ||
[VSTeamQueryCache]::timestamp = (Get-Date).TimeOfDay.TotalMinutes | ||
} | ||
foreach ($q in [VSTeamQueryCache]::queries ) { | ||
if ($q.name -like "*$WordToComplete*" -and $q.name -match "[\s'\(\[#;@]") { | ||
$results.Add([System.Management.Automation.CompletionResult]::new(('"{0}"' -f $q.name))) | ||
} | ||
elseif ($q.name -like "*$WordToComplete*"){ | ||
$results.Add([System.Management.Automation.CompletionResult]::new($q.name)) | ||
} | ||
} | ||
return $results | ||
} | ||
} |
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,9 @@ | ||
class QueryTransformToIDAttribute : System.Management.Automation.ArgumentTransformationAttribute { | ||
[object] Transform([System.Management.Automation.EngineIntrinsics]$EngineIntrinsics, [object] $InputData) { | ||
if ($InputData -notmatch "[0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}" -and | ||
[VSTeamQueryCache]::queries.where({$_.name -eq $InputData}).count) { | ||
$InputData = [VSTeamQueryCache]::queries.where({$_.name -eq $InputData}).id | ||
} | ||
return ($InputData) | ||
} | ||
} |
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,16 @@ | ||
class ReleaseDefinitionCompleter : System.Management.Automation.IArgumentCompleter { | ||
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( | ||
[string]$CommandName, [string]$ParameterName, [string]$WordToComplete, | ||
[System.Management.Automation.Language.CommandAst]$CommandAst, [System.Collections.IDictionary] $FakeBoundParameters | ||
) { | ||
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new() | ||
if ($Global:PSDefaultParameterValues["*:projectName"]){ | ||
foreach ($r in (Get-VSTeamReleaseDefinition -ProjectName $Global:PSDefaultParameterValues["*:projectName"]).name ) { | ||
if ($r -like "*$WordToComplete*") { | ||
$results.Add([System.Management.Automation.CompletionResult]::new($r)) | ||
} | ||
} | ||
} | ||
return $results | ||
} | ||
} |
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.
You might want to be careful with code like this. If Get-VSTeamBuild returns an empty Array this will post the following error.
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.
I changed the code to this.
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.
Funny that the code works because builds don't have a name. They have a buildNumber. But that code was working... I changed to buildNumber and it is still working.
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.
It might be to do with strictmode . When it's off ($null).name is fine, , when it is on it gives that error. I noticed the tests turn strictmode on, and I have a tendency to write code which relies on it being off. If you need/want to change that anywhere feel free to do so :-)
There are a couple of cases where dynamic parameters may still be the most sensible way to do it - that's usually where the value of parameter A determines if parameter B is visible or not. And I may have left some in that are only used once.
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.
Got it! Good to know.