Skip to content

Commit

Permalink
Merge with Master
Browse files Browse the repository at this point in the history
  • Loading branch information
DarqueWarrior committed Aug 15, 2019
2 parents daa2dd3 + 69d2139 commit 98f3b9e
Show file tree
Hide file tree
Showing 11 changed files with 262 additions and 13 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@

## 6.3.2

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/181) from [Michael Erpenbeck](https://github.com/GitMje) which included the following:
Fixed typo in README.md file for better readability.

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/179) from [Jim W](https://github.com/Seekatar) which included the following:
Add PSDrive support for memberships

- Memberships
- Groups
- Group1
- Users
- User1

## 6.3.1

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/178) from [Jim W](https://github.com/Seekatar) which included the following:
Expand Down
16 changes: 12 additions & 4 deletions Source/Classes/VSTeamAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,28 @@ class VSTeamAccount : SHiPSDirectory {
}

[object[]] GetChildItem() {
$poolsAndProjects = @(
$topLevelFolders = @(
[VSTeamPools]::new('Agent Pools'),
[VSTeamExtensions]::new('Extensions')
[VSTeamFeeds]::new('Feeds')
)

# Don't show directories not supported by the server
if (_testFeedSupport) {
$topLevelFolders += [VSTeamFeeds]::new('Feeds')
}

if(_testGraphSupport) {
$topLevelFolders += [VSTeamPermissions]::new('Permissions')
}

$items = Get-VSTeamProject | Sort-Object Name

foreach ($item in $items) {
$item.AddTypeName('Team.Provider.Project')
$poolsAndProjects += $item
$topLevelFolders += $item
}

return $poolsAndProjects
return $topLevelFolders
}

[void] hidden AddTypeName(
Expand Down
29 changes: 29 additions & 0 deletions Source/Classes/VSTeamGroups.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using namespace Microsoft.PowerShell.SHiPS

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

# Default constructor
VSTeamGroups(
[string]$Name
) : base($Name, $null) {
$this.AddTypeName('Team.Groups')

$this.DisplayMode = 'd-r-s-'
}

[object[]] GetChildItem() {
$Groups = Get-VSTeamGroup -ErrorAction SilentlyContinue | Sort-Object name

$objs = @()

foreach ($Group in $Groups) {
$Group.AddTypeName('Team.Provider.Group')

$objs += $Group
}

return $objs
}
}
24 changes: 24 additions & 0 deletions Source/Classes/VSTeamPermissions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using namespace Microsoft.PowerShell.SHiPS

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

# Default constructor
VSTeamPermissions(
[string]$Name
) : base($Name, $null) {
$this.AddTypeName('Team.Permissions')

$this.DisplayMode = 'd-r-s-'
}

[object[]] GetChildItem() {
$groupsAndUsers = @(
[VSTeamGroups]::new('Groups'),
[VSTeamUsers]::new('Users')
)

return $groupsAndUsers
}
}
29 changes: 29 additions & 0 deletions Source/Classes/VSTeamUsers.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using namespace Microsoft.PowerShell.SHiPS

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

# Default constructor
VSTeamUsers(
[string]$Name
) : base($Name, $null) {
$this.AddTypeName('Team.Users')

$this.DisplayMode = 'd-r-s-'
}

[object[]] GetChildItem() {
$Users = Get-VSTeamUser -ErrorAction SilentlyContinue | Sort-Object name

$objs = @()

foreach ($User in $Users) {
$User.AddTypeName('Team.Provider.User')

$objs += $User
}

return $objs
}
}
3 changes: 3 additions & 0 deletions Source/Classes/_classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
"VSTeamBuildDefinition.ps1",
"VSTeamExtension.ps1",
"VSTeamFeed.ps1",
"VSTeamUsers.ps1",
"VSTeamGroups.ps1",
"VSTeamPermissions.ps1",
"VSTeamProcess.ps1",
"VSTeamRef.ps1",
"VSTeamTeam.ps1",
Expand Down
20 changes: 18 additions & 2 deletions Source/Private/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,34 @@ $profilesPath = "$HOME/vsteam_profiles.json"

function _supportsGraph {
_hasAccount
if (-not [VSTeamVersions]::Graph) {
if ($false -eq $(_testGraphSupport)) {
throw 'This account does not support the graph API.'
}
}

function _testGraphSupport {
if (-not [VSTeamVersions]::Graph) {
return $false
}

return $true
}

function _supportsFeeds {
_hasAccount
if (-not [VSTeamVersions]::Packaging) {
if ($false -eq $(_testFeedSupport)) {
throw 'This account does not support packages.'
}
}

function _testFeedSupport {
if (-not [VSTeamVersions]::Packaging) {
return $false
}

return $true
}

function _supportsSecurityNamespace {
_hasAccount
if (([VSTeamVersions]::Version -ne "VSTS") -and ([VSTeamVersions]::Version -ne "AzD")) {
Expand Down
17 changes: 14 additions & 3 deletions Source/en-US/about_vsteam_provider.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ SHORT DESCRIPTION
- Agent1
- JobRequest1
- JobRequest2
- Extensions
- Extension1
- Extension2
- Feeds
- Feed1
- Feed2
- Memberships
- Groups
- Group1
- Users
- User1
- Project1
- Project2
- Builds
Expand All @@ -33,10 +44,10 @@ SHORT DESCRIPTION
- Ref2

LONG DESCRIPTION
You use the New-PSDrive cmdlet to mount a drive to your account.
You use the New-PSDrive cmdlet to mount a drive to your account.

You can also use the -Drive parameter of Set-VSTeamAccount to have
the required command written to the console so you can copy and
the required command written to the console so you can copy and
paste the command.

The provider caches the results. To force a round trip to skip the
Expand All @@ -49,7 +60,7 @@ EXAMPLES
Get-ChildItem

Set-VSTeamAccount -Profile '[profileName]' -Drive '[driveName]'

To map a drive run the following command:
New-PSDrive -Name driveName -PSProvider SHiPS -Root 'VSTeam#VSTeamAccount'

Expand Down
49 changes: 48 additions & 1 deletion Source/formats/Team.Build.TableView.ps1xml
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
<?xml version="1.0" encoding="utf-8" ?><Configuration><ViewDefinitions><View><Name>Team.Build.TableView</Name><ViewSelectedBy><TypeName>Team.Provider.Build</TypeName><TypeName>VSTeamBuild</TypeName></ViewSelectedBy><TableControl><TableHeaders><TableColumnHeader><Label>Mode</Label></TableColumnHeader><TableColumnHeader><Label>Build Number</Label></TableColumnHeader><TableColumnHeader><Label>Status</Label></TableColumnHeader><TableColumnHeader><Label>Result</Label></TableColumnHeader><TableColumnHeader><Label>Build Definition</Label></TableColumnHeader></TableHeaders><TableRowEntries><TableRowEntry><TableColumnItems><TableColumnItem><PropertyName>DisplayMode</PropertyName></TableColumnItem><TableColumnItem><PropertyName>name</PropertyName></TableColumnItem><TableColumnItem><PropertyName>status</PropertyName></TableColumnItem><TableColumnItem><PropertyName>result</PropertyName></TableColumnItem><TableColumnItem><PropertyName>BuildDefinition</PropertyName></TableColumnItem></TableColumnItems></TableRowEntry></TableRowEntries></TableControl></View></ViewDefinitions></Configuration>
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<ViewDefinitions>
<View>
<Name>Team.PSDrive.Default.TableView</Name>
<ViewSelectedBy>
<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>
<TypeName>Team.BuildDefinitions</TypeName>
<TypeName>Team.Releases</TypeName>
<TypeName>Team.Repositories</TypeName>
<TypeName>Team.Teams</TypeName>
<TypeName>Team.Permissions</TypeName>
<TypeName>Team.Provider.Group</TypeName>
<TypeName>Team.Provider.User</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>
</ViewDefinitions>
</Configuration>
49 changes: 48 additions & 1 deletion Source/formats/Team.PSDrive.Default.TableView.ps1xml
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
<?xml version="1.0" encoding="utf-8" ?><Configuration><ViewDefinitions><View><Name>Team.PSDrive.Default.TableView</Name><ViewSelectedBy><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><TypeName>Team.BuildDefinitions</TypeName><TypeName>Team.Releases</TypeName><TypeName>Team.Repositories</TypeName><TypeName>Team.Teams</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></ViewDefinitions></Configuration>
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<ViewDefinitions>
<View>
<Name>Team.PSDrive.Default.TableView</Name>
<ViewSelectedBy>
<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>
<TypeName>Team.BuildDefinitions</TypeName>
<TypeName>Team.Releases</TypeName>
<TypeName>Team.Repositories</TypeName>
<TypeName>Team.Teams</TypeName>
<TypeName>Team.Permissions</TypeName>
<TypeName>Team.Groups</TypeName>
<TypeName>Team.Users</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>
</ViewDefinitions>
</Configuration>
29 changes: 27 additions & 2 deletions unit/test/teamspsdrive.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ InModuleScope VSTeam {
}
}
}

Describe 'VSTS Build Definition' {
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
Mock Invoke-RestMethod { return @() } -ParameterFilter {
Expand Down Expand Up @@ -209,7 +209,8 @@ InModuleScope VSTeam {
# Skip 0 because that will be Agent Pools
# Skip 1 because that will be Extensions
# Skip 2 because that will be Feeds
$project = $account.GetChildItem()[3]
# Skip 3 because that will be Permissions
$project = $account.GetChildItem()[4]

It 'Should return projects' {
$project | Should Not Be $null
Expand Down Expand Up @@ -538,5 +539,29 @@ InModuleScope VSTeam {
$team | Should Not Be $null
}
}

Context 'Permissions' {
Set-StrictMode -Version Latest
Mock Get-VSTeamGroup { return [VSTeamGroup]::new(@{})}
Mock Get-VSTeamUser { return [VSTeamGroup]::new(@{})}

$permissions = [VSTeamPermissions]::new('Permissions')

It 'Should create Permissions' {
$permissions | Should Not Be $null
$permissions.GetChildItem().Count | Should Be 2
}

$groups = $permissions.GetChildItem()[0]
$users = $permissions.GetChildItem()[1]

It 'Should return groups' {
$groups | Should Not Be $null
}

It 'Should return users' {
$users | Should Not Be $null
}
}
}
}

0 comments on commit 98f3b9e

Please sign in to comment.