PSResourceGet
PSResourceGet copied to clipboard
CredentialInfo usability enhancements
Summary of the new feature / enhancement
The CredentialInfo
parameter currently requires the user to create a PSCredentialInfo
object in order to pass the values to the cmdlet. This can create some usability barriers since its an extra hoop for users to get the data in the desired format/object. From what I can tell the user only needs to supply the VaultName
and SecretName
.
This can be simplified in a few different ways:
- Replace
CredentialInfo
parameter with separateVault
andSecret
parameters - Allow
CredentialInfo
to accept a hashtable@{ VaultName = 'SecretStore'; SecretName = 'PSGet' }
by using aArgumentTransformation
attribute.
Proposed technical implementation details (optional)
class PSCredentialInfoTransformAttribute : ArgumentTransformationAttribute
{
private const string VaultName = "VaultName";
private const string SecretName = "SecretName";
public override object Transform(EngineIntrinsics engineIntrinsics, object inputData)
{
if (inputData is Hashtable)
{
var ht = inputData as Hashtable;
if (ht.ContainsKey(VaultName) && ht.ContainsKey(SecretName))
{
return new PSCredentialInfo(ht[VaultName], ht[SecretName]);
}
else
{
throw new ArgumentTransformationMetadataException();
}
}
else if (inputData is PSCredentialInfo)
{
return inputData;
}
else
{
throw new ArgumentTransformationMetadataException();
}
}
}
@ThomasNieto thanks for this detailed suggestion, there's still some work we aim to do with CredentialInfo so we can consider incorporating this in then. Thank you!
Hi @ThomasNieto would you be interested in putting in a PR for the ArgumentTransformation? If not, we can add this in, but figured I'd ask you first :smiley:
@alerickson yeah I can.