@@ -392,7 +392,7 @@ var migratePamCmd = &cobra.Command{
392392 }
393393
394394 // check Store Password for PAM field, and process migration if applicable
395- var storePassword * api.StorePasswordConfig
395+ var storePassword * api.UpdateStorePasswordConfig
396396 if certStore .Password .IsManaged { // managed secret, i.e. PAM Provider in use
397397
398398 // check if Pam Secret is using our migrating provider
@@ -643,21 +643,38 @@ func selectProviderTypeParamId(name string, pamTypeParameterDefinitions []interf
643643}
644644
645645func reformatPamSecretForPost (secretProp map [string ]interface {}) map [string ]interface {} {
646- reformatted := map [string ]interface {}{
647- "Provider" : secretProp ["ProviderId" ],
646+
647+ reformatted := map [string ]interface {}{}
648+ // check if secretProp has a "SecretValue" key
649+ if secVal , ok := secretProp ["SecretValue" ]; ok && secVal != nil {
650+ // add top level "value" key with SecretValue
651+ formattedVal := make (map [string ]interface {})
652+ formattedVal ["SecretValue" ] = secVal
653+ // convert formattedVal into escaped JSON string
654+ jsonVal , _ := json .Marshal (formattedVal )
655+ reformatted ["value" ] = string (jsonVal )
656+ //reformatted["value"] = formattedVal
648657 }
649658
650- providerParams := secretProp ["ProviderTypeParameterValues" ].([]interface {})
651- reformattedParams := map [string ]string {}
659+ // check if secretProp has a "ProviderId" key
660+ if prId , ok := secretProp ["ProviderId" ]; ok && prId != nil {
661+ reformatted ["Provider" ] = prId
662+ }
663+ // check if secretProp has a "ProviderTypeParameterValues" key
664+ if vals , valsOk := secretProp ["ProviderTypeParameterValues" ]; valsOk && vals != nil {
665+ providerParams := secretProp ["ProviderTypeParameterValues" ].([]interface {})
666+ reformattedParams := map [string ]string {}
652667
653- for _ , param := range providerParams {
654- providerTypeParam := param .(map [string ]interface {})["ProviderTypeParam" ].(map [string ]interface {})
655- name := providerTypeParam ["Name" ].(string )
656- value := param .(map [string ]interface {})["Value" ].(string )
657- reformattedParams [name ] = value
668+ for _ , param := range providerParams {
669+ providerTypeParam := param .(map [string ]interface {})["ProviderTypeParam" ].(map [string ]interface {})
670+ name := providerTypeParam ["Name" ].(string )
671+ value := param .(map [string ]interface {})["Value" ].(string )
672+ reformattedParams [name ] = value
673+ }
674+
675+ reformatted ["Parameters" ] = reformattedParams
658676 }
659677
660- reformatted ["Parameters" ] = reformattedParams
661678 return reformatted
662679}
663680
0 commit comments