gansheer commented on code in PR #4794:
URL: https://github.com/apache/camel-k/pull/4794#discussion_r1345768432


##########
addons/vault/aws/aws_secrets_manager_test.go:
##########
@@ -75,6 +75,28 @@ func TestAwsSecretsManagerTraitNoDefaultCreds(t *testing.T) {
        assert.Equal(t, "false", 
e.ApplicationProperties["camel.vault.aws.defaultCredentialsProvider"])
 }
 
+func TestAwsSecretsManagerTraitWithSecrets(t *testing.T) {

Review Comment:
   If you could add an configmap case in your test it would be nice.



##########
addons/vault/aws/aws_secrets_manager.go:
##########
@@ -106,8 +112,20 @@ func (t *awsSecretsManagerTrait) Apply(environment 
*trait.Environment) error {
        }
 
        if environment.IntegrationInRunningPhases() {
-               environment.ApplicationProperties["camel.vault.aws.accessKey"] 
= t.AccessKey
-               environment.ApplicationProperties["camel.vault.aws.secretKey"] 
= t.SecretKey
+               hits := rex.FindAllStringSubmatch(t.AccessKey, -1)
+               if len(hits) >= 1 {
+                       var res, _ = v1.DecodeValueSource(t.AccessKey, 
"aws-access-key", "The access Key provided is not valid")
+                       
environment.ApplicationProperties["camel.vault.aws.accessKey"] = 
res.SecretKeyRef.Key

Review Comment:
   The DecodeValueSource will only translate your input expression to a golang 
struct object. Therefore here you are passing the value of the key from the  
expression `[configmap|secret]:name[/key]`  instead of its value.
   You need to retrieve the kubernetes object to have the value with: 
https://github.com/apache/camel-k/blob/f1b700cba2dc88f95737b10b141a0bf2e6b95a71/pkg/util/kubernetes/client.go#L179
   
   Also it will manage both configmap and secret because you only do not as the 
DecodeValueSource contains ONLY ONE of the sub-objects ref `ConfigMapKeyRef`  
or `SecretKeyRef`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to