squakez commented on code in PR #5639:
URL: https://github.com/apache/camel-k/pull/5639#discussion_r1642722084


##########
pkg/apis/camel/v1/trait/environment.go:
##########
@@ -29,6 +29,7 @@ type EnvironmentTrait struct {
        HTTPProxy *bool `property:"http-proxy" json:"httpProxy,omitempty"`
        // A list of environment variables to be added to the integration 
container.
        // The syntax is KEY=VALUE, e.g., `MY_VAR="my value"`.
+       // The value may also be a reference to a configmap or secret, e.g. 
`MY_VAR=configmap:my-cm/my-cm-key`

Review Comment:
   Okey, we have an auto regen in the nightly so it will be eventually sync-ed, 
but you should report this to get it sorted.



##########
pkg/trait/environment.go:
##########
@@ -99,12 +101,81 @@ func (t *environmentTrait) Apply(e *Environment) error {
                }
        }
 
-       if t.Vars != nil {
-               for _, env := range t.Vars {
-                       k, v := property.SplitPropertyFileEntry(env)
+       for _, env := range t.Vars {
+               k, v := property.SplitPropertyFileEntry(env)
+               switch {
+               case strings.HasPrefix(v, "configmap:"):
+                       path := strings.TrimPrefix(v, "configmap:")
+                       setValFromConfigMapKeySelector(&e.EnvVars, k, path)
+               case strings.HasPrefix(v, "secret:"):
+                       path := strings.TrimPrefix(v, "secret:")
+                       setValFromSecretKeySelector(&e.EnvVars, k, path)
+               default:
                        envvar.SetVal(&e.EnvVars, k, v)
                }
        }
-
        return nil
 }
+
+func setValFromConfigMapKeySelector(vars *[]corev1.EnvVar, envName string, 
path string) {

Review Comment:
   I think we already cover this logic with our internal API: 
https://github.com/apache/camel-k/blob/ca5239b57c6e450b527204163d6cea33da297f3e/pkg/apis/camel/v1/common_types.go#L315
   
   You may look at the code which is using this struct and reuse the same 
instead to avoid duplicating the maintenance effort.



-- 
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