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

Agent Pools cmdlets for removing, adding and updating #384

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c60f354
Update README.md
SebastianSchuetze Jun 19, 2020
2465e18
Update README.md
SebastianSchuetze Jun 19, 2020
943204a
Merge remote-tracking branch 'upstream/master'
SebastianSchuetze Jun 20, 2020
c3e7a7d
Merge remote-tracking branch 'upstream/master'
SebastianSchuetze Jul 7, 2020
f25f9f3
Added Add-VSTeamPool
SebastianSchuetze Jul 7, 2020
ca9bd3a
Added Update-VSTeamPool
SebastianSchuetze Jul 7, 2020
e756d29
Added Remove-VSTeamPool
SebastianSchuetze Jul 7, 2020
40804ad
updated docs for Get-VSTeamPool
SebastianSchuetze Jul 7, 2020
7b193e1
added unit tests
SebastianSchuetze Mar 7, 2021
acc678b
Merge branch 'trunk' into topic/AgentPools
SebastianSchuetze Mar 7, 2021
a262474
added unit tests
SebastianSchuetze Mar 7, 2021
5148760
added shpildprocess and helpUris
SebastianSchuetze Mar 7, 2021
d33830b
added changelog
SebastianSchuetze Mar 7, 2021
37635e4
updated documentation
SebastianSchuetze Mar 7, 2021
503eb3e
updated documentation
SebastianSchuetze Mar 7, 2021
e46b23d
updated documentation
SebastianSchuetze Mar 7, 2021
04e5efa
updated documentation
SebastianSchuetze Mar 8, 2021
8b9f092
Merge branch 'trunk' into topic/AgentPools
SebastianSchuetze Mar 8, 2021
c69f78c
added vsteam pool maintenance type
SebastianSchuetze Mar 14, 2021
f55ebe9
added get and set agent pool maintanance cmdlets
SebastianSchuetze Mar 14, 2021
c695617
optimized, refactored and fixed time zone completer
SebastianSchuetze Mar 14, 2021
478181a
optimized base completer
SebastianSchuetze Mar 14, 2021
397761c
optimized timezones
SebastianSchuetze Mar 14, 2021
fd20f34
added timezone completer tests
SebastianSchuetze Mar 14, 2021
cbf8848
added time zone validation attribute tests
SebastianSchuetze Mar 14, 2021
aabeee9
- removed unused parameter 'Enable'
SebastianSchuetze Mar 14, 2021
25218b9
removed unneeded 'else' code
SebastianSchuetze Mar 14, 2021
7f0a699
added unit test for Set-VSTeamAgentPoolMaintenance
SebastianSchuetze Mar 14, 2021
bdbbc40
added unit tests and fixes for them
SebastianSchuetze Mar 14, 2021
690357e
removed unused variable
SebastianSchuetze Mar 14, 2021
077d1f3
Merge branch 'trunk' into topic/AgentPools
SebastianSchuetze Jun 24, 2021
fef6aad
Updating module version in manifest
SebastianSchuetze Jun 24, 2021
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
86 changes: 86 additions & 0 deletions .docs/Add-VSTeamPool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!-- #include "./common/header.md" -->

# Add-VSTeamPool

## SYNOPSIS

<!-- #include "./synopsis/Add-VSTeamPool.md" -->

## SYNTAX

## DESCRIPTION

<!-- #include "./synopsis/Add-VSTeamPool.md" -->

## EXAMPLES

### Example 1

```powershell
Add-VSTeamPool -Name "TestPool" -Description "Test Description" -AutoProvision -AutoAuthorize -NoAutoUpdates
```

It's creating an agent pool with the name "TestPool" that is auto provisioning to every project and also pre-authorized to be used with every pipeline. Agent software is not updated automatically.

## PARAMETERS

### -Name

Name of the pool to create.

```yaml
Type: string
Required: True
```

### -Description

Description of the pool to create.

```yaml
Type: string
Required: False
```

### -AutoProvision

Auto-provision this agent pool in new projects.

```yaml
Type: string
Required: True
```

### -AutoAuthorize

Grant access permission to all pipelines.

```yaml
Type: string
Required: True
```

### -NoAutoUpdates

Turn off automatic updates of agents in the pool. Default is turned on.

```yaml
Type: string
Required: True
```

## INPUTS

## OUTPUTS

### System.Object

## NOTES

## RELATED LINKS

[Remove-VSTeamPool](Remove-VSTeamPool.md)
[Update-VSTeamPool](Update-VSTeamPool.md)
[Get-VSTeamPool](Get-VSTeamPool.md)

<!-- #include "./common/related.md" -->
6 changes: 5 additions & 1 deletion .docs/Get-VSTeamPool.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ Accept pipeline input: true (ByPropertyName)

## RELATED LINKS

<!-- #include "./common/related.md" -->
[Remove-VSTeamAccount](Remove-VSTeamAccount.md)
[Update-VSTeamAccount](Update-VSTeamAccount.md)
[Add-VSTeamAccount](Add-VSTeamAccount.md)

<!-- #include "./common/related.md" -->
44 changes: 44 additions & 0 deletions .docs/Remove-VSTeamPool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!-- #include "./common/header.md" -->

# Remove-VSTeamPool

## SYNOPSIS

<!-- #include "./synopsis/Remove-VSTeamPool.md" -->

## SYNTAX

## DESCRIPTION

<!-- #include "./synopsis/Remove-VSTeamPool.md" -->

## EXAMPLES

## PARAMETERS

### -Id

Id of the pool to delete.

```yaml
Type: int
Parameter Sets: ByID
Aliases: PoolID
Required: True
Accept pipeline input: true (ByPropertyName)
```

## INPUTS

## OUTPUTS

## NOTES

## RELATED LINKS

[Add-VSTeamPool](Add-VSTeamPool.md)
[Update-VSTeamPool](Update-VSTeamPool.md)
[Get-VSTeamPool](Get-VSTeamPool.md)


<!-- #include "./common/related.md" -->
90 changes: 90 additions & 0 deletions .docs/Update-VSTeamPool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!-- #include "./common/header.md" -->

# Update-VSTeamPool

## SYNOPSIS

<!-- #include "./synopsis/Update-VSTeamPool.md" -->

## SYNTAX

## DESCRIPTION

<!-- #include "./synopsis/Update-VSTeamPool.md" -->

## EXAMPLES

### Example 1

```powershell
Update-VSTeamPool -Id 13 -Name "UpdatedTestPoolName" -Description "Test Description" -AutoProvision -NoAutoUpdates
```
Updates the pool with id 13 with the name new "UpdatedTestPoolName" that is auto-provisioning to every project and agent software is not updating automatically.

## PARAMETERS

### -Id

Id of the pool to return.

```yaml
Type: int
Parameter Sets: ByID
Aliases: PoolID
Required: True
Accept pipeline input: true (ByPropertyName)
```

### -Name

Name of the pool to update.

```yaml
Type: string
Required: True
```

### -Description

Description of the pool to update.

```yaml
Type: string
Required: False
```

### -AutoProvision

Auto-provision this agent pool in new projects.

```yaml
Type: string
Required: True
```

### -NoAutoUpdates

Turn off automatic updates of agents in the pool. Default is turned on.

```yaml
Type: string
Required: True
```

## INPUTS

### System.String

## OUTPUTS

### System.Object

## NOTES

## RELATED LINKS

[Remove-VSTeamPool](Remove-VSTeamPool.md)
[Add-VSTeamPool](Add-VSTeamPool.md)
[Get-VSTeamPool](Get-VSTeamPool.md)

<!-- #include "./common/related.md" -->
1 change: 1 addition & 0 deletions .docs/synopsis/Add-VSTeamPool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adds a new agent pool.
1 change: 1 addition & 0 deletions .docs/synopsis/Remove-VSTeamPool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removes the agent pool.
1 change: 1 addition & 0 deletions .docs/synopsis/Update-VSTeamPool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updates an agent pool.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@
],
"powershell.pester.useLegacyCodeLens": false,
"powershell.pester.outputVerbosity": "Detailed",
"powershell.codeFormatting.addWhitespaceAroundPipe": true
"powershell.codeFormatting.addWhitespaceAroundPipe": true,
"gitdoc.enabled": false
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 7.3.0

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/384) from [Sebastian Schütze](https://github.com/SebastianSchuetze) which included the following:

- Add-VSTeamPool, Remove-VSTeamPool and Update-VSTeampool for handling agent pools on Azure DevOps

## 7.2.0

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/371) and (https://github.com/DarqueWarrior/vsteam/pull/389) from [Sebastian Schütze](https://github.com/SebastianSchuetze) which included the following:
Expand All @@ -25,6 +31,7 @@ Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/350) from [Da

Also added Clear-VSTeamDefaultProjectCount and Set-VSTeamDefaultProjectCount to control the default number of projects returned for tab completion and validation. By default only 100 projects are returned and the 100 returned is nondeterministic. But calling Set-VSTeamDefaultProjectCount you can increase the number of projects returned.


## 7.1.2

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/366) from [Jhoneill](https://github.com/jhoneill) which included the following:
Expand Down
10 changes: 10 additions & 0 deletions Source/Classes/Attribute/TimeZonesValidateAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

namespace vsteam_lib
{
public class TimeZoneValidateAttribute : BaseValidateArgumentsAttribute
{
internal override IEnumerable<string> GetValues() => TimeZones.GetTimeZoneIds();
}

}
99 changes: 65 additions & 34 deletions Source/Classes/Completer/BaseCompleter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,71 @@

namespace vsteam_lib
{
public abstract class BaseCompleter : IArgumentCompleter
{
protected readonly IPowerShell _powerShell;

/// <summary>
/// This constructor is used during unit testings
/// </summary>
/// <param name="powerShell">fake instance of IPowerShell used for testing</param>
protected BaseCompleter(IPowerShell powerShell) { this._powerShell = powerShell; }

/// <summary>
/// This constructor is used when running in a PowerShell session. It cannot be
/// loaded in a unit test.
/// </summary>
[ExcludeFromCodeCoverage]
protected BaseCompleter() : this(new PowerShellWrapper(RunspaceMode.CurrentRunspace)) { }

public abstract IEnumerable<CompletionResult> CompleteArgument(string commandName,
string parameterName,
string wordToComplete,
CommandAst commandAst,
IDictionary fakeBoundParameters);

protected static void SelectValues(string wordToComplete, IEnumerable<string> words, List<CompletionResult> values)
{
foreach (var word in words)
{
if (string.IsNullOrEmpty(wordToComplete) || word.StartsWith(wordToComplete, true, CultureInfo.InvariantCulture))
public abstract class BaseCompleter : IArgumentCompleter
{
protected readonly IPowerShell _powerShell;

/// <summary>
/// This constructor is used during unit testings
/// </summary>
/// <param name="powerShell">fake instance of IPowerShell used for testing</param>
protected BaseCompleter(IPowerShell powerShell) { this._powerShell = powerShell; }

/// <summary>
/// This constructor is used when running in a PowerShell session. It cannot be
/// loaded in a unit test.
/// </summary>
[ExcludeFromCodeCoverage]
protected BaseCompleter() : this(new PowerShellWrapper(RunspaceMode.CurrentRunspace)) { }

public abstract IEnumerable<CompletionResult> CompleteArgument(string commandName,
string parameterName,
string wordToComplete,
CommandAst commandAst,
IDictionary fakeBoundParameters);

protected static void SelectValues(string wordToComplete, IEnumerable<string> words, List<CompletionResult> values)
{
foreach (var word in words)
{
if (string.IsNullOrEmpty(wordToComplete) || word.StartsWith(wordToComplete, true, CultureInfo.InvariantCulture))
{
values.Add(GetCompletionResult(word));
}
}
}


private static CompletionResult GetCompletionResult(string word)
{
return GetCompletionResult(word,word,CompletionResultType.Text);
}

private static CompletionResult GetCompletionResult(string word, string wordLabel, CompletionResultType resultType)
SebastianSchuetze marked this conversation as resolved.
Show resolved Hide resolved
{
// Only wrap in single quotes if they have a space. This makes it easier
// to use on macOs
return (new CompletionResult(word.Contains(" ") ? $"'{word}'" : word, wordLabel, resultType, wordLabel + ": " + word));

}

protected static void SelectValues(string wordToComplete,
SebastianSchuetze marked this conversation as resolved.
Show resolved Hide resolved
Dictionary<string, string> words,
List<CompletionResult> values)
{
foreach (var word in words)
{
// Only wrap in single quotes if they have a space. This makes it easier
// to use on macOs
values.Add(new CompletionResult(word.Contains(" ") ? $"'{word}'" : word));
var keyToSearch = word.Key.ToLower();
var valueToSearch = word.Value.ToLower();

if (string.IsNullOrEmpty(wordToComplete) ||
keyToSearch.Contains(wordToComplete) ||
valueToSearch.Contains(wordToComplete)
)
{
values.Add(GetCompletionResult(word.Key, word.Value, CompletionResultType.Text));
}
}
}
}
}
}
}
}
Loading