@@ -14,8 +14,12 @@ type ExternalPluginProvider struct {
1414 // plugin is the commonplugin to be executed by this secret
1515 plugin commonplugins.SecretsPlugin
1616
17- // name of the plugin and also the executable
18- name string
17+ // pluginName refers to the provider parameter of the secret block
18+ // and is here mainly for debugging purposes
19+ pluginName string
20+
21+ // secretName is the secret block name executing the plugin
22+ secretName string
1923
2024 // path is the secret location used in Fetch
2125 path string
@@ -26,26 +30,27 @@ type Response struct {
2630 Error * string `json:"error,omitempty"`
2731}
2832
29- func NewExternalPluginProvider (plugin commonplugins.SecretsPlugin , name string , path string ) * ExternalPluginProvider {
33+ func NewExternalPluginProvider (plugin commonplugins.SecretsPlugin , pluginName , secretName , path string ) * ExternalPluginProvider {
3034 return & ExternalPluginProvider {
31- plugin : plugin ,
32- name : name ,
33- path : path ,
35+ plugin : plugin ,
36+ pluginName : pluginName ,
37+ secretName : secretName ,
38+ path : path ,
3439 }
3540}
3641
3742func (p * ExternalPluginProvider ) Fetch (ctx context.Context ) (map [string ]string , error ) {
3843 resp , err := p .plugin .Fetch (ctx , p .path )
3944 if err != nil {
40- return nil , fmt .Errorf ("failed to fetch secret from plugin %s : %w" , p .name , err )
45+ return nil , fmt .Errorf ("failed executing plugin %q for secret %q : %w" , p .pluginName , p . secretName , err )
4146 }
4247 if resp .Error != nil {
43- return nil , fmt .Errorf ("error returned from secret plugin %s : %s " , p .name , * resp .Error )
48+ return nil , fmt .Errorf ("provider %q for secret %q response contained error : %q " , p .pluginName , p . secretName , * resp .Error )
4449 }
4550
4651 formatted := make (map [string ]string , len (resp .Result ))
4752 for k , v := range resp .Result {
48- formatted [fmt .Sprintf ("secret.%s.%s" , p .name , k )] = v
53+ formatted [fmt .Sprintf ("secret.%s.%s" , p .secretName , k )] = v
4954 }
5055
5156 return formatted , nil
0 commit comments