Skip to content
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

converted VSTeamQueue from format/type to class #84

Merged
merged 46 commits into from
Sep 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
98a0da2
adapt integration test to additional VSTS pool 'Hosted Ubuntu 1604'
KaiWalter Jul 26, 2018
0954436
Updating psd1 and readme but not releasing new version yet.
DarqueWarrior Jul 29, 2018
6895c67
Merge remote-tracking branch 'upstream/master'
KaiWalter Jul 29, 2018
7afb6ed
breaking BuildDefinition down to Target
KaiWalter Jul 29, 2018
2a1ab7d
added integration tests for BuildDefinition
KaiWalter Jul 29, 2018
ac087b0
fixed identation in integration test
KaiWalter Jul 29, 2018
53ba724
added integration tests for BuildDefinition
KaiWalter Jul 29, 2018
2c5d978
Merge branch 'master' of github.com:KaiWalter/vsteam
KaiWalter Jul 29, 2018
6cae4b7
merge upstream
KaiWalter Jul 30, 2018
a279ff2
removed pools.ps1xml again from vsteam.psd1
KaiWalter Jul 31, 2018
7f5dc06
merge upstream
KaiWalter Aug 1, 2018
9809f21
rollback to version w/o Process and Phase
KaiWalter Aug 1, 2018
751f792
added integration test for BuildDefinition
KaiWalter Aug 1, 2018
b8c5491
rollback process and phase breakdown
KaiWalter Aug 1, 2018
288d2e5
fix typo
KaiWalter Aug 1, 2018
5a3fa0d
Merge remote-tracking branch 'upstream/master'
KaiWalter Aug 2, 2018
12e5073
Merge remote-tracking branch 'darquewarrior/master'
DarqueWarrior Aug 3, 2018
d41898d
Updated readme and updated build def tests to run on TFS and VSTS.
DarqueWarrior Aug 3, 2018
c8d1260
Merge remote-tracking branch 'upstream/master'
KaiWalter Aug 3, 2018
aea1e4d
Merge remote-tracking branch 'upstream/master'
KaiWalter Aug 12, 2018
2c2a36e
initial drilldown build def to process, phases, steps
KaiWalter Aug 13, 2018
f0fe9d8
added basic attrs to build def steps
KaiWalter Aug 13, 2018
84a8626
fixed build def unit tests
KaiWalter Aug 13, 2018
e7cb346
adapted formats for typed build defs
KaiWalter Aug 13, 2018
8102338
hooked up build def with PS provider project
KaiWalter Aug 13, 2018
5108cc4
add formats for process+phase+step
KaiWalter Aug 13, 2018
0481690
added missing Build Def + Phase properties
KaiWalter Aug 14, 2018
b7c2898
Merge remote-tracking branch 'upstream/master'
KaiWalter Aug 15, 2018
187f257
Getting Close. All tests passing.
DarqueWarrior Aug 17, 2018
afea396
Merge branch 'reivew'
DarqueWarrior Aug 17, 2018
b32ef6f
100% code coverage on teamspsdrive file.
DarqueWarrior Aug 17, 2018
e43475b
All integration tests passing.
DarqueWarrior Aug 17, 2018
a7fa45d
Added yaml and phased process types.
DarqueWarrior Aug 17, 2018
0c0d97b
Updated help for version class.
DarqueWarrior Aug 18, 2018
b50149c
Fixed broken tests
DarqueWarrior Aug 18, 2018
014258d
realign with upstream
KaiWalter Aug 21, 2018
bb94a10
remove obsolete output from buildDefinitions module
KaiWalter Aug 22, 2018
337172a
added GitRepository object to BuildDefinition
KaiWalter Aug 22, 2018
9a90727
rolled back Get-VSTeamGitRepo in Get-VSTeamBuildDef
KaiWalter Aug 23, 2018
582a113
Merge branch 'master' of github.com:KaiWalter/vsteam
KaiWalter Aug 26, 2018
d422c2c
convert VSTeamQueue from format/type to class
KaiWalter Aug 28, 2018
1c3fbc0
Got rid of merge conflict markers and little formatting.
DarqueWarrior Aug 30, 2018
4ca7384
Merge branch 'master' of https://github.com/KaiWalter/vsteam
DarqueWarrior Aug 30, 2018
696914a
Formatting.
DarqueWarrior Aug 30, 2018
a1a434b
fixed TeamPSDrive unit test
KaiWalter Sep 2, 2018
19e0957
protecting against null created by which I have seen on newer accounts.
DarqueWarrior Sep 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions VSTeam.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
'types\cloudSubscriptions.ps1xml',
'types\repositories.ps1xml',
'types\policies.ps1xml',
'types\queues.ps1xml',
'types\releaseDefinitions.ps1xml',
'types\releases.ps1xml',
'types\serviceendpoints.ps1xml',
Expand All @@ -82,7 +81,6 @@
'formats\builds.format.ps1xml',
'formats\policyTypes.format.ps1xml',
'formats\profile.format.ps1xml',
'formats\queues.format.ps1xml',
'formats\serviceendpoints.format.ps1xml',
'formats\serviceendpointTypes.format.ps1xml',
'formats\team.format.ps1xml',
Expand Down
40 changes: 0 additions & 40 deletions formats/queues.format.ps1xml

This file was deleted.

34 changes: 34 additions & 0 deletions formats/vsteamPSDrive.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,38 @@
</TableControl>
</View>

<!--Team.Provider.Queue.Table-->
<View>
<Name>Team.Provider.Queue.Table</Name>
<ViewSelectedBy>
<TypeName>Team.Provider.Queue</TypeName>
</ViewSelectedBy>
<TableControl>
<AutoSize/>
<TableHeaders>
<TableColumnHeader>
<Label>Mode</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Name</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<Wrap/>
<TableColumnItems>
<TableColumnItem>
<PropertyName>DisplayMode</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>

<!--Team.Provider.Pool.Table-->
<View>
<Name>Team.Provider.Pool.Table</Name>
Expand Down Expand Up @@ -1265,6 +1297,7 @@
<TypeName>Microsoft.PowerShell.SHiPS.SHiPSDirectory</TypeName>
<TypeName>Team.Account</TypeName>
<TypeName>Team.Pool</TypeName>
<TypeName>Team.Queues</TypeName>
<TypeName>Team.Pools</TypeName>
<TypeName>Team.Provider.Pools</TypeName>
<TypeName>Team.Builds</TypeName>
Expand Down Expand Up @@ -1306,6 +1339,7 @@
<TypeName>Microsoft.PowerShell.SHiPS.SHiPSDirectory</TypeName>
<TypeName>Team.Account</TypeName>
<TypeName>Team.Pool</TypeName>
<TypeName>Team.Queues</TypeName>
<TypeName>Team.Pools</TypeName>
<TypeName>Team.Builds</TypeName>
<TypeName>Team.BuildDefinitions</TypeName>
Expand Down
22 changes: 7 additions & 15 deletions src/queues.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ Set-StrictMode -Version Latest
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
. "$here\common.ps1"

# Apply types to the returned objects so format and type files can
# identify the object and act on it.
function _applyTypesToQueue {
param($item)

$item.PSObject.TypeNames.Insert(0, 'Team.Queue')
$item.pool.PSObject.TypeNames.Insert(0, 'Team.Pool')
}

function Get-VSTeamQueue {
[CmdletBinding(DefaultParameterSetName = 'List')]
param(
Expand All @@ -38,20 +29,21 @@ function Get-VSTeamQueue {
$resp = _callAPI -ProjectName $ProjectName -Id $id -Area distributedtask -Resource queues `
-Version $([VSTeamVersions]::DistributedTask)

_applyTypesToQueue -item $resp
$item = [VSTeamQueue]::new($resp, $ProjectName)

Write-Output $resp
Write-Output $item
}
else {
$resp = _callAPI -ProjectName $projectName -Area distributedtask -Resource queues `
-QueryString @{ queueName = $queueName; actionFilter = $actionFilter } -Version $([VSTeamVersions]::DistributedTask)

# Apply a Type Name so we can use custom format view and custom type extensions
$objs = @()

foreach ($item in $resp.value) {
_applyTypesToQueue -item $item
$objs += [VSTeamQueue]::new($item, $ProjectName)
}

Write-Output $resp.value
Write-Output $objs
}
}
}
Expand Down
77 changes: 70 additions & 7 deletions src/teamspsdrive.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class VSTeamProject : VSTeamDirectory {
return @(
[VSTeamBuildDefinitions]::new('Build Definitions', $this.Name),
[VSTeamBuilds]::new('Builds', $this.Name),
[VSTeamQueues]::new('Queues', $this.Name),
[VSTeamReleases]::new('Releases', $this.Name),
[VSTeamRepositories]::new('Repositories', $this.Name),
[VSTeamTeams]::new('Teams', $this.Name)
Expand Down Expand Up @@ -334,6 +335,58 @@ class VSTeamFeed : VSTeamLeaf {
}
}

[SHiPSProvider(UseCache = $true)]
[SHiPSProvider(BuiltinProgress = $false)]
class VSTeamQueues : VSTeamDirectory {

# Default constructor
VSTeamQueues(
[string]$Name,
[string]$ProjectName
) : base($Name, $ProjectName) {
$this.AddTypeName('Team.Queues')
}

[object[]] GetChildItem() {
$items = Get-VSTeamQueue -ProjectName $this.ProjectName -ErrorAction SilentlyContinue

foreach ($item in $items) {
$item.AddTypeName('Team.Provider.Queue')
}

return $items
}
}

[SHiPSProvider(UseCache = $true)]
[SHiPSProvider(BuiltinProgress = $false)]
class VSTeamQueue : VSTeamLeaf {

[string]$poolName
[VSTeamPool]$pool

# Default constructor
VSTeamQueue(
[object]$obj,
[string]$Projectname
) : base($obj.name, $obj.id, $Projectname) {

# pool values are not returned always
if ($obj.PSObject.Properties.Match('poolName').count -gt 0) {
$this.poolName = $obj.poolName
}

if ($obj.PSObject.Properties.Match('pool').count -gt 0) {
$this.pool = [VSTeamPool]::new($obj.pool)
$this.poolName = $obj.pool.name
}

$this.AddTypeName('Team.Queue')

$this._internalObj = $obj
}
}

[SHiPSProvider(UseCache = $true)]
[SHiPSProvider(BuiltinProgress = $false)]
class VSTeamPools : VSTeamDirectory {
Expand Down Expand Up @@ -380,11 +433,19 @@ class VSTeamPool : VSTeamDirectory {
) : base($obj.Name, $null) {

$this.id = $obj.id
$this.count = $obj.size
$this.isHosted = $obj.isHosted

# On some accounts teh CreatedBy is null for hosted pools
if ($null -ne $obj.createdBy) {
# values are not returned always
if ($obj.PSObject.Properties.Match('isHosted').count -gt 0) {
$this.isHosted = $obj.isHosted
}

if ($obj.PSObject.Properties.Match('size').count -gt 0) {
$this.count = $obj.size
}

# On some accounts the CreatedBy is null for hosted pools
if ($obj.PSObject.Properties.Match('createdBy').count -gt 0 -and
$null -ne $obj.createdBy) {
$this.createdBy = [VSTeamUser]::new($obj.createdBy, $null)
}

Expand Down Expand Up @@ -566,16 +627,16 @@ class VSTeamBuildDefinition : VSTeamDirectory {
[int]$Revision = -1
[string]$Path = $null
[object]$Tags = $null
[object]$Queue = $null
[object]$Options = $null
[object]$Triggers = $null
[object]$Variables = $null
[object]$Repository = $null
[VSTeamGitRepository]$GitRepository = $null
[VSTeamQueue]$Queue = $null
[object]$RetentionRules = $null
[VSTeamUser]$AuthoredBy = $null
[string]$BuildNumberFormat = $null
[string]$JobAuthorizationScope = $null
[VSTeamGitRepository]$GitRepository = $null
[datetime]$CreatedOn = [datetime]::MinValue
[VSTeamBuildDefinitionProcess]$Process = $null
[VSTeamBuildDefinitionProcessPhaseStep[]]$Steps = $null
Expand All @@ -587,14 +648,16 @@ class VSTeamBuildDefinition : VSTeamDirectory {

$this.id = $obj.id
$this.Path = $obj.path
$this.Queue = $obj.queue
$this.Revision = $obj.revision
$this.Variables = $obj.variables
$this.CreatedOn = $obj.createdDate
$this.JobAuthorizationScope = $obj.jobAuthorizationScope
$this.AuthoredBy = [VSTeamUser]::new($obj.authoredBy, $Projectname)

# These might not be returned
if ($obj.PSObject.Properties.Match('queue').count -gt 0) {
$this.Queue = [VSTeamQueue]::new($obj.queue, $Projectname)
}
if ($obj.PSObject.Properties.Match('triggers').count -gt 0) {
$this.Triggers = $obj.triggers
}
Expand Down
13 changes: 0 additions & 13 deletions types/queues.ps1xml

This file was deleted.

10 changes: 10 additions & 0 deletions unit/test/queues.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ InModuleScope queues {
Context 'Get-VSTeamQueue with no parameters' {
Mock Invoke-RestMethod { return @{
value = @{
id = 3
name = 'Hosted'
pool = @{}
}
}}
Expand All @@ -30,6 +32,8 @@ InModuleScope queues {
Context 'Get-VSTeamQueue with queueName parameter' {
Mock Invoke-RestMethod { return @{
value = @{
id = 3
name = 'Hosted'
pool = @{}
}
}}
Expand All @@ -46,6 +50,8 @@ InModuleScope queues {
Context 'Get-VSTeamQueue with actionFilter parameter' {
Mock Invoke-RestMethod { return @{
value = @{
id = 3
name = 'Hosted'
pool = @{}
}
}}
Expand All @@ -66,6 +72,8 @@ InModuleScope queues {

return @{
value = @{
id = 3
name = 'Hosted'
pool = @{}
}
}}
Expand All @@ -91,6 +99,8 @@ InModuleScope queues {

Context 'Get-VSTeamQueue' {
Mock Invoke-RestMethod { return @{
id = 3
name = 'Hosted'
pool = @{}
}}

Expand Down
8 changes: 5 additions & 3 deletions unit/test/teamspsdrive.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,14 @@ Describe 'TeamsPSDrive' {
$actual[0].ProjectName | Should Be 'TestProject'
$actual[1].Name | Should Be 'Builds'
$actual[1].ProjectName | Should Be 'TestProject'
$actual[2].Name | Should Be 'Releases'
$actual[2].Name | Should Be 'Queues'
$actual[2].ProjectName | Should Be 'TestProject'
$actual[3].Name | Should Be 'Repositories'
$actual[3].Name | Should Be 'Releases'
$actual[3].ProjectName | Should Be 'TestProject'
$actual[4].Name | Should Be 'Teams'
$actual[4].Name | Should Be 'Repositories'
$actual[4].ProjectName | Should Be 'TestProject'
$actual[5].Name | Should Be 'Teams'
$actual[5].ProjectName | Should Be 'TestProject'
}
}

Expand Down