Open sean-r-williams opened 7 months ago
It looks like #866 was supposed to add this functionality, but type coercion appears to be broken:
PS C:\> [Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo](Get-SecretInfo -Vault "Default" -Name "Artifactory")
Cannot convert the "Microsoft.PowerShell.SecretManagement.SecretInformation" value of type "Microsoft.PowerShell.SecretManagement.SecretInformation" to type "Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo".
At line:1 char:1
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo](Get ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : ConvertToFinalInvalidCastException
PS C:\> [Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo]::new((Get-SecretInfo -Vault "Default" -Name "Artifactory"))
Exception calling ".ctor" with "1" argument(s): "Invalid CredentialInfo, SecretName must be a non-empty string"
At line:1 char:1
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo]::ne ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentException
(@FriedrichWeinmann, is there something we're missing here?)
Looking at the implementation for PSCredentialInfo, the problem appears to be multifold:
SecretInformation
, so we can't use any of the custom converters to that effect.SecretName
is null (the property is just Name
)Some possible options come to mind:
SecretInformation
@sean-r-williams thanks so much for the issue, we likely won't have time to get to this in the near future but it looks like you have a good understanding of the issue and we would be happy to accept a PR-- thanks
Prerequisites
Steps to reproduce
Register-PSResourceRepository
Set-PSResourceRepository -Name <repo> -CredentialInfo (Get-SecretInfo -Vault <vault> -Name <secret>)
Expected behavior
Actual behavior
Error details
Environment data
Visuals
No response