lburgazzoli commented on a change in pull request #400: Jolokia trait 
configuration maps JVM agent options directly
URL: https://github.com/apache/camel-k/pull/400#discussion_r252380594
 
 

 ##########
 File path: pkg/trait/jolokia.go
 ##########
 @@ -107,3 +139,64 @@ func (t *jolokiaTrait) Apply(e *Environment) (err error) {
 
        return nil
 }
+
+func setDefaultJolokiaOption(options map[string]string, option interface{}, 
key string, value interface{}) {
+       // Do not override existing option
+       if _, ok := options[key]; ok {
+               return
+       }
+       switch option.(type) {
+       case **bool:
+               if o := option.(**bool); *o == nil {
+                       v := value.(bool)
+                       *o = &v
+               }
+       case **int:
+               if o := option.(**int); *o == nil {
+                       v := value.(int)
+                       *o = &v
+               }
+       case **string:
+               if o := option.(**string); *o == nil {
+                       v := value.(string)
+                       *o = &v
+               }
+       }
+}
+
+func addToJolokiaOptions(options map[string]string, key string, value 
interface{}) {
+       switch value.(type) {
+       case *bool:
+               if v := value.(*bool); v != nil {
+                       options[key] = strconv.FormatBool(*v)
+               }
+       case *int:
+               if v := value.(*int); v != nil {
+                       options[key] = strconv.Itoa(*v)
+               }
+       case int:
+               options[key] = strconv.Itoa(value.(int))
+       case *string:
+               if v := value.(*string); v != nil {
+                       options[key] = *v
+               }
+       }
+}
+
+func parseJolokiaOptions(options *string) (map[string]string, error) {
 
 Review comment:
   Looks very similar to 
https://github.com/apache/camel-k/blob/c5e76c72ea3a58fe42e81387d01113ab2cb2bf69/pkg/trait/prometheus.go#L152,
 we may consolidate it as trait/kubernetes helper function

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to