lburgazzoli commented on code in PR #5090:
URL: https://github.com/apache/camel-k/pull/5090#discussion_r1500740746


##########
pkg/trait/mount.go:
##########
@@ -165,4 +193,191 @@ func (t *mountTrait) mountResource(vols *[]corev1.Volume, 
mnts *[]corev1.VolumeM
 
        *vols = append(*vols, *vol)
        *mnts = append(*mnts, *mnt)
+
+       // User specified location file (only properties file)
+       if dstDir != "" {
+               if strings.HasSuffix(dstDir, ".properties") {
+                       return []string{mntPath}, nil
+               }
+               return nil, nil
+       }
+
+       // We only process this for text configuration .properties files, never 
for resources
+       if conf.ContentType() == utilResource.ContentTypeText {
+               // the user asked to store the entire resource without 
specifying any filter
+               // we need to list all the resources belonging to the resource
+               if conf.StorageType() == utilResource.StorageTypeConfigmap {
+                       cm := kubernetes.LookupConfigmap(e.Ctx, e.Client, 
e.Integration.Namespace, conf.Name())
+                       if cm != nil {
+                               for k := range cm.Data {
+                                       if strings.HasSuffix(k, ".properties") {
+                                               paths = append(paths, 
fmt.Sprintf("%s/%s", mntPath, k))
+                                       } else {
+                                               // Deprecated: use explicit 
configuration instead
+                                               envName := 
strings.ToUpper(strings.ReplaceAll(strings.ReplaceAll(k, "-", "_"), ".", "_"))
+                                               t.L.Infof(`Deprecation notice: 
the operator is adding the environment variable %s which will take runtime 
value from configmap.
+                                               This feature may disappear in 
future releases, make sure to use properties file in you configmap instead.`, 
envName)
+                                               propsAsEnv = append(propsAsEnv, 
corev1.EnvVar{
+                                                       Name: envName,
+                                                       ValueFrom: 
&corev1.EnvVarSource{
+                                                               
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
+                                                                       
LocalObjectReference: corev1.LocalObjectReference{
+                                                                               
Name: cm.Name,
+                                                                       },
+                                                                       Key: k,
+                                                               },
+                                                       },
+                                               })
+                                       }
+                               }
+                       }
+               } else if conf.StorageType() == utilResource.StorageTypeSecret {
+                       sec := kubernetes.LookupSecret(e.Ctx, e.Client, 
e.Integration.Namespace, conf.Name())
+                       if sec != nil {
+                               for k := range sec.Data {
+                                       if strings.HasSuffix(k, ".properties") {
+                                               paths = append(paths, 
fmt.Sprintf("%s/%s", mntPath, k))
+                                       } else {
+                                               // Deprecated: use explicit 
configuration instead
+                                               envName := 
strings.ToUpper(strings.ReplaceAll(strings.ReplaceAll(k, "-", "_"), ".", "_"))
+                                               t.L.Infof(`Deprecation notice: 
the operator is adding the environment variable %s which will take runtime 
value from secret.
+                                               This feature may disappear in 
future releases, make sure to use properties file in you secret instead.`, 
envName)
+                                               propsAsEnv = append(propsAsEnv, 
corev1.EnvVar{
+                                                       Name: envName,
+                                                       ValueFrom: 
&corev1.EnvVarSource{
+                                                               SecretKeyRef: 
&corev1.SecretKeySelector{
+                                                                       
LocalObjectReference: corev1.LocalObjectReference{
+                                                                               
Name: sec.Name,
+                                                                       },
+                                                                       Key: k,
+                                                               },
+                                                       },
+                                               })
+                                       }
+                               }
+                       }
+               }
+       }
+
+       return paths, propsAsEnv
+}
+
+// Configure the list of location which the runtime will look for 
application.properties files.
+func (t *mountTrait) setConfigLocations(container *corev1.Container, 
configPaths []string) {
+       if configPaths != nil {
+               envvar.SetVar(&container.Env, corev1.EnvVar{
+                       Name:  "QUARKUS_CONFIG_LOCATIONS",

Review Comment:
   Me too, hence I recommend to keep the extension and work across the stack to 
make the integration smooth



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