@@ -54,7 +54,7 @@ func (a *akeylessSecretStore) Init(ctx context.Context, meta secretstores.Metada
5454 return errors .New ("failed to parse metadata: " + err .Error ())
5555 }
5656
57- err = a .Authenticate (m )
57+ err = a .Authenticate (ctx , m )
5858 if err != nil {
5959 return errors .New ("failed to authenticate with Akeyless: " + err .Error ())
6060 }
@@ -69,14 +69,14 @@ func (a *akeylessSecretStore) GetSecret(ctx context.Context, req secretstores.Ge
6969 }
7070
7171 a .logger .Debugf ("getting secret type for '%s'..." , req .Name )
72- secretType , err := a .GetSecretType (req .Name )
72+ secretType , err := a .GetSecretType (ctx , req .Name )
7373 if err != nil {
7474 return secretstores.GetSecretResponse {}, err
7575 }
7676
7777 a .logger .Debugf ("getting secret value for '%s' (type %s)..." , req .Name , secretType )
7878
79- secretValue , err := a .GetSingleSecretValue (req .Name , secretType )
79+ secretValue , err := a .GetSingleSecretValue (ctx , req .Name , secretType )
8080 if err != nil {
8181 return secretstores.GetSecretResponse {}, errors .New (err .Error ())
8282 }
@@ -104,7 +104,7 @@ func (a *akeylessSecretStore) BulkGetSecret(ctx context.Context, req secretstore
104104
105105 // For bulk get, we need to list all secrets first
106106 a .logger .Debug ("listing items from / path..." )
107- listItems , err := a .listItemsRecursively ("/" )
107+ listItems , err := a .listItemsRecursively (ctx , "/" )
108108 if err != nil {
109109 return response , fmt .Errorf ("failed to list items from Akeyless: %w" , err )
110110 }
@@ -150,10 +150,10 @@ func (a *akeylessSecretStore) BulkGetSecret(ctx context.Context, req secretstore
150150 defer wg .Done ()
151151 if len (staticItemNames ) == 1 {
152152 staticSecretName := staticItemNames [0 ]
153- value , err := a .GetSingleSecretValue (staticSecretName , STATIC_SECRET_RESPONSE )
153+ value , err := a .GetSingleSecretValue (ctx , staticSecretName , STATIC_SECRET_RESPONSE )
154154 secretResultChannels <- secretResultCollection {name : staticSecretName , value : value , err : err }
155155 } else {
156- secretResponse := a .GetBulkStaticSecretValues (staticItemNames )
156+ secretResponse := a .GetBulkStaticSecretValues (ctx , staticItemNames )
157157 if len (secretResponse ) > 0 {
158158 for _ , result := range secretResponse {
159159 secretResultChannels <- result
@@ -167,7 +167,7 @@ func (a *akeylessSecretStore) BulkGetSecret(ctx context.Context, req secretstore
167167 go func () {
168168 defer wg .Done ()
169169 for _ , item := range dynamicItemNames {
170- value , err := a .GetSingleSecretValue (item , DYNAMIC_SECRET_RESPONSE )
170+ value , err := a .GetSingleSecretValue (ctx , item , DYNAMIC_SECRET_RESPONSE )
171171 if err != nil {
172172 secretResultChannels <- secretResultCollection {name : item , value : "" , err : err }
173173 } else {
@@ -181,7 +181,7 @@ func (a *akeylessSecretStore) BulkGetSecret(ctx context.Context, req secretstore
181181 go func () {
182182 defer wg .Done ()
183183 for _ , item := range rotatedItemNames {
184- value , err := a .GetSingleSecretValue (item , ROTATED_SECRET_RESPONSE )
184+ value , err := a .GetSingleSecretValue (ctx , item , ROTATED_SECRET_RESPONSE )
185185 if err != nil {
186186 secretResultChannels <- secretResultCollection {name : item , value : "" , err : err }
187187 } else {
@@ -286,10 +286,10 @@ func (a *akeylessSecretStore) parseMetadata(meta secretstores.Metadata) (*akeyle
286286 return & m , nil
287287}
288288
289- func (a * akeylessSecretStore ) GetSecretType (secretName string ) (string , error ) {
289+ func (a * akeylessSecretStore ) GetSecretType (ctx context. Context , secretName string ) (string , error ) {
290290 describeItem := akeyless .NewDescribeItem (secretName )
291291 describeItem .SetToken (a .token )
292- describeItemResp , _ , err := a .v2 .DescribeItem (context . Background () ).Body (* describeItem ).Execute ()
292+ describeItemResp , _ , err := a .v2 .DescribeItem (ctx ).Body (* describeItem ).Execute ()
293293 if err != nil {
294294 return "" , fmt .Errorf ("failed to describe item '%s': %w" , secretName , err )
295295 }
@@ -303,7 +303,7 @@ func (a *akeylessSecretStore) GetSecretType(secretName string) (string, error) {
303303
304304// GetSingleSecretValue gets the value of a single secret from Akeyless.
305305// It returns the value of the secret or an error if the secret is not found.
306- func (a * akeylessSecretStore ) GetSingleSecretValue (secretName string , secretType string ) (string , error ) {
306+ func (a * akeylessSecretStore ) GetSingleSecretValue (ctx context. Context , secretName string , secretType string ) (string , error ) {
307307
308308 var secretValue string
309309 var err error
@@ -312,7 +312,7 @@ func (a *akeylessSecretStore) GetSingleSecretValue(secretName string, secretType
312312 case STATIC_SECRET_RESPONSE :
313313 getSecretValue := akeyless .NewGetSecretValue ([]string {secretName })
314314 getSecretValue .SetToken (a .token )
315- secretRespMap , _ , apiErr := a .v2 .GetSecretValue (context . Background () ).Body (* getSecretValue ).Execute ()
315+ secretRespMap , _ , apiErr := a .v2 .GetSecretValue (ctx ).Body (* getSecretValue ).Execute ()
316316 if apiErr != nil {
317317 err = fmt .Errorf ("failed to get secret '%s' value for static secret from Akeyless API: %w" , secretName , apiErr )
318318 break
@@ -336,7 +336,7 @@ func (a *akeylessSecretStore) GetSingleSecretValue(secretName string, secretType
336336 case DYNAMIC_SECRET_RESPONSE :
337337 getDynamicSecretValue := akeyless .NewGetDynamicSecretValue (secretName )
338338 getDynamicSecretValue .SetToken (a .token )
339- secretRespMap , _ , apiErr := a .v2 .GetDynamicSecretValue (context . Background () ).Body (* getDynamicSecretValue ).Execute ()
339+ secretRespMap , _ , apiErr := a .v2 .GetDynamicSecretValue (ctx ).Body (* getDynamicSecretValue ).Execute ()
340340 if apiErr != nil {
341341 err = fmt .Errorf ("failed to get dynamic secret '%s' value from Akeyless API: %w" , secretName , apiErr )
342342 break
@@ -369,7 +369,7 @@ func (a *akeylessSecretStore) GetSingleSecretValue(secretName string, secretType
369369 case ROTATED_SECRET_RESPONSE :
370370 getRotatedSecretValue := akeyless .NewGetRotatedSecretValue (secretName )
371371 getRotatedSecretValue .SetToken (a .token )
372- secretRespMap , _ , apiErr := a .v2 .GetRotatedSecretValue (context . Background () ).Body (* getRotatedSecretValue ).Execute ()
372+ secretRespMap , _ , apiErr := a .v2 .GetRotatedSecretValue (ctx ).Body (* getRotatedSecretValue ).Execute ()
373373 if apiErr != nil {
374374 err = fmt .Errorf ("failed to get rotated secret '%s' value from Akeyless API: %w" , secretName , apiErr )
375375 break
@@ -389,13 +389,13 @@ func (a *akeylessSecretStore) GetSingleSecretValue(secretName string, secretType
389389
390390// GetBulkStaticSecretValues gets the values of multiple static secrets from Akeyless.
391391// It returns a map of secret names and their values.
392- func (a * akeylessSecretStore ) GetBulkStaticSecretValues (secretNames []string ) []secretResultCollection {
392+ func (a * akeylessSecretStore ) GetBulkStaticSecretValues (ctx context. Context , secretNames []string ) []secretResultCollection {
393393
394394 var secretResponse = make ([]secretResultCollection , len (secretNames ))
395395
396396 getSecretsValues := akeyless .NewGetSecretValue (secretNames )
397397 getSecretsValues .SetToken (a .token )
398- secretRespMap , _ , apiErr := a .v2 .GetSecretValue (context . Background () ).Body (* getSecretsValues ).Execute ()
398+ secretRespMap , _ , apiErr := a .v2 .GetSecretValue (ctx ).Body (* getSecretsValues ).Execute ()
399399 if apiErr != nil {
400400 secretResponse = append (secretResponse , secretResultCollection {name : "" , value : "" , err : fmt .Errorf ("failed to get static secrets' '%s' value from Akeyless API: %w" , secretNames , apiErr )})
401401 } else {
@@ -410,7 +410,7 @@ func (a *akeylessSecretStore) GetBulkStaticSecretValues(secretNames []string) []
410410
411411// listItemsRecursively lists all items in a given path recursively.
412412// It returns a list of items and an error if the list items request fails.
413- func (a * akeylessSecretStore ) listItemsRecursively (path string ) ([]akeyless.Item , error ) {
413+ func (a * akeylessSecretStore ) listItemsRecursively (ctx context. Context , path string ) ([]akeyless.Item , error ) {
414414 var allItems []akeyless.Item
415415
416416 // Create the list items request
@@ -422,7 +422,7 @@ func (a *akeylessSecretStore) listItemsRecursively(path string) ([]akeyless.Item
422422
423423 // Execute the list items request
424424 a .logger .Debugf ("listing items from path '%s'..." , path )
425- itemsList , _ , err := a .v2 .ListItems (context . Background () ).Body (* listItems ).Execute ()
425+ itemsList , _ , err := a .v2 .ListItems (ctx ).Body (* listItems ).Execute ()
426426 if err != nil {
427427 return nil , err
428428 }
@@ -435,7 +435,7 @@ func (a *akeylessSecretStore) listItemsRecursively(path string) ([]akeyless.Item
435435 // Recursively process each subfolder
436436 if itemsList .Folders != nil {
437437 for _ , folder := range itemsList .Folders {
438- subItems , err := a .listItemsRecursively (folder )
438+ subItems , err := a .listItemsRecursively (ctx , folder )
439439 if err != nil {
440440 return nil , err
441441 }
@@ -448,7 +448,7 @@ func (a *akeylessSecretStore) listItemsRecursively(path string) ([]akeyless.Item
448448
449449// Authenticate authenticates with Akeyless using the provided metadata.
450450// It returns an error if the authentication fails.
451- func (a * akeylessSecretStore ) Authenticate (metadata * akeylessMetadata ) error {
451+ func (a * akeylessSecretStore ) Authenticate (ctx context. Context , metadata * akeylessMetadata ) error {
452452
453453 a .logger .Debug ("Creating authentication request to Akeyless..." )
454454 authRequest := akeyless .NewAuth ()
@@ -495,7 +495,7 @@ func (a *akeylessSecretStore) Authenticate(metadata *akeylessMetadata) error {
495495 a .v2 = akeyless .NewAPIClient (config ).V2Api
496496
497497 a .logger .Debug ("authenticating with Akeyless..." )
498- out , _ , err := a .v2 .Auth (context . Background () ).Body (* authRequest ).Execute ()
498+ out , _ , err := a .v2 .Auth (ctx ).Body (* authRequest ).Execute ()
499499 if err != nil {
500500 return fmt .Errorf ("failed to authenticate with Akeyless: %w" , err )
501501 }
0 commit comments