Skip to content

🪲 [Fix]: Add -PassThru parameter to Set-Context and Set-ContextVault functions for pipeline support#93

Merged
Marius Storhaug (MariusStorhaug) merged 3 commits into
mainfrom
fixSetFunctions
Jun 8, 2025
Merged

🪲 [Fix]: Add -PassThru parameter to Set-Context and Set-ContextVault functions for pipeline support#93
Marius Storhaug (MariusStorhaug) merged 3 commits into
mainfrom
fixSetFunctions

Conversation

@MariusStorhaug

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Jun 8, 2025

Copy link
Copy Markdown
Member

Description

This pull request introduces a new -PassThru parameter to the Set-Context and Set-ContextVault functions, allowing users to pass objects through the pipeline. Corresponding updates have been made to the logic and tests to support this functionality.

Enhancements to Set-Context and Set-ContextVault functions:

  • Added -PassThru parameter to Set-Context: This optional parameter enables the function to return the context object through the pipeline if specified. (src/functions/public/Set-Context.ps1, [1] [2]
  • Modified Set-ContextVault calls within Set-Context: Updated to include the -PassThru parameter when invoking Set-ContextVault, ensuring consistent behavior. (src/functions/public/Set-Context.ps1, src/functions/public/Set-Context.ps1L79-R83)

Enhancements to Set-ContextVault function:

  • Added -PassThru parameter to Set-ContextVault: This optional parameter allows the function to return the created or updated vault object through the pipeline if specified. (src/functions/public/Vault/Set-ContextVault.ps1, [1] [2]

Test updates:

  • Updated tests for Set-ContextVault: Modified test cases to include the -PassThru parameter, ensuring the returned objects meet the expected type and content. (tests/ContextVaults.Tests.ps1, tests/ContextVaults.Tests.ps1L41-R57)

Type of change

  • 📖 [Docs]
  • 🪲 [Fix]
  • 🩹 [Patch]
  • ⚠️ [Security fix]
  • 🚀 [Feature]
  • 🌟 [Breaking change]

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

Copilot AI review requested due to automatic review settings June 8, 2025 15:22
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title 🩹 [Patch]: Add -PassThru parameter to Set-Context and Set-ContextVault functions for pipeline support 🪲 [Fix]: Add -PassThru parameter to Set-Context and Set-ContextVault functions for pipeline support Jun 8, 2025
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title 🪲 [Fix]: Add -PassThru parameter to Set-Context and Set-ContextVault functions for pipeline support 🪲 [Fix]: Add -PassThru parameter to Set-Context and Set-ContextVault functions for pipeline support Jun 8, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a -PassThru switch to both Set-ContextVault and Set-Context so that these cmdlets can emit their resulting objects down the pipeline.

  • Introduced the -PassThru parameter in both functions and wired it through from Set-Context to Set-ContextVault.
  • Updated tests in ContextVaults.Tests.ps1 to invoke -PassThru and validate returned vault objects.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/functions/public/Vault/Set-ContextVault.ps1 Added -PassThru switch and conditional object output in process
src/functions/public/Set-Context.ps1 Added -PassThru switch, passed it to Set-ContextVault and conditionally emitted context
tests/ContextVaults.Tests.ps1 Updated test cases to include -PassThru and assert returned types
Comments suppressed due to low confidence (4)

tests/ContextVaults.Tests.ps1:57

  • The pipeline input test only asserts that Name contains 'test-pipeline1'; consider also checking for 'test-pipeline2' and verifying that Path is not null or empty for each returned object to fully validate the output.
$results = 'test-pipeline1', 'test-pipeline2' | Set-ContextVault -PassThru

src/functions/public/Vault/Set-ContextVault.ps1:32

  • [nitpick] The new -PassThru parameter isn't documented in the function's comment-based help; consider adding a .PARAMETER PassThru entry and an example usage so users know how to emit the vault object.
[switch] $PassThru

src/functions/public/Set-Context.ps1:74

  • [nitpick] The function help block should be updated to include a description for the new -PassThru switch and an example of using it to return the context object in the pipeline.
[switch] $PassThru

src/functions/public/Set-Context.ps1:126

  • There are no existing tests for Set-Context -PassThru; consider adding a test that verifies the context object is returned when -PassThru is specified.
if ($PassThru) {

@MariusStorhaug Marius Storhaug (MariusStorhaug) merged commit 1baa2f0 into main Jun 8, 2025
37 checks passed
@MariusStorhaug Marius Storhaug (MariusStorhaug) deleted the fixSetFunctions branch June 8, 2025 15:36
@github-actions

github-actions Bot commented Jun 8, 2025

Copy link
Copy Markdown

Module Context - 8.0.2 published to the PowerShell Gallery.

@github-actions

github-actions Bot commented Jun 8, 2025

Copy link
Copy Markdown

GitHub release for Context v8.0.2 has been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants