🌟 [Major]: Introducing classes and removing base64
encoding
#66
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces several new classes, removes redundant functions, and refactors existing code to improve the management of contexts and their settings. The most significant changes include the addition of the
Context
andContextInfo
classes, the removal of Base64-related functions, and updates to the handling of context information.Removal of Base64 encoding
Base64 encoding of names has been removed from the module for now. We want to make it more flexible for module developers, so this can be decided on the implementation of
Context
in your modules. However take into consideration thatSecret
names (from theMicrosoft.PowerShell.SecretManagement
module) cannot have some special characters, like[]
for now.ConvertFrom-Base64
,ConvertTo-Base64
, andTest-Base64
from thesrc/functions/private/Base64
directory. [1] [2] [3]New Classes:
src/classes/public/Context.ps1
: Added a newContext
class that includes methods for creating context objects from different sources and a method to return the context ID.src/classes/public/ContextInfo.ps1
: Added a newContextInfo
class that includes methods for creating context info objects from different sources.Remove
ContextSetting
functions:ContextSetting
functions so that the implementer can create their own implementation. We want to push usingGet-Context
to get the object loaded to memory from disk, modify the object in memory (allows to modify one or more settings) and then useSet-Context
to write the context object back to disk when all is done. Mantra: Work with objects.Get-ContextSetting
,Remove-ContextSetting
, andSet-ContextSetting
from thesrc/functions/public/ContextSetting
directory. [1] [2] [3]Refactoring:
Get-ContextInfo
function publicsrc/functions/public/Get-ContextInfo.ps1
.Context
, which are now identified by theirID
throughout the functions.src/completers.ps1
: Updated the argument completer to useID
instead ofName
for context identification.src/functions/public/Get-Context.ps1
: Modified theGet-Context
function to useID
instead ofName
for context identification and added indentation to debug messages. [1] [2] [3] [4]src/functions/public/Remove-Context.ps1
: Updated theRemove-Context
function to useID
instead ofName
for context identification and made theID
parameter mandatory. [1] [2]Configuration Updates:
src/functions/private/Initialize-ContextVault.ps1
: Set theVaultName
in the script configuration after initializing and registering the vault. [1] [2]src/functions/private/JsonToObject/ConvertFrom-ContextJson.ps1
: Added a default value for theJsonString
parameter.src/functions/private/ObjectToJSON/Convert-ContextObjectToHashtableRecursive.ps1
: Added a default value for theObject
parameter.src/functions/private/ObjectToJSON/ConvertTo-ContextJson.ps1
: Added a default value for theContext
parameter.Mistake in versioning
Before this PR there was two commits to main that created version
4.0.4
and4.0.5
which was a mistake. Both of these were breaking changes, so they have been reverted and instead gathered into one major updated, covered in this PR.Type of change
Checklist