Skip to content

Add ValueFromPipelineByPropertyName to Set-PSResourceRepository #705

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

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion src/code/SetPSResourceRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed class SetPSResourceRepository : PSCmdlet
/// <summary>
/// Specifies the name of the repository to be set.
/// </sumamry>
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ParameterSetName = NameParameterSet)]
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ParameterSetName = NameParameterSet)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also make note of this in the help doc, for the Name property where it says accepts pipeline input we currently only have True (byValue) but would also need to signify by property name. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if I add this now it'll get overwritten with Sean's changes, so I'll just leave a comment on his PR either asking him to do it or as a reminder that I should add that in. Thank you for flagging this though!

[ArgumentCompleter(typeof(RepositoryNameCompleter))]
[ValidateNotNullOrEmpty]
public string Name { get; set; }
Expand Down
11 changes: 11 additions & 0 deletions test/SetPSResourceRepository.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ Describe "Test Set-PSResourceRepository" {
$res.CredentialInfo | Should -BeNullOrEmpty
}

It "set repository given pipeline input ValueFromPipelineByPropertyName passed in" {
Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
Get-PSResourceRepository -Name $TestRepoName1 | Set-PSResourceRepository -Trusted
$res = Get-PSResourceRepository -Name $TestRepoName1
$res.Name | Should -Be $TestRepoName1
$Res.Uri.LocalPath | Should -Contain $tmpDir1Path
$res.Priority | Should -Be 50
$res.Trusted | Should -Be True
$res.CredentialInfo | Should -BeNullOrEmpty
}

It "set repository given Name and CredentialInfo parameters" {
Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
Set-PSResourceRepository -Name $TestRepoName1 -CredentialInfo $credentialInfo1
Expand Down