All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dekorate.jaeger.adapter.JaegerAgentConfigAdapter Maven / Gradle / Ivy

There is a newer version: 4.1.4
Show newest version
package io.dekorate.jaeger.adapter;

import java.nio.file.Path;
import io.dekorate.jaeger.config.JaegerAgentConfigBuilder;
import java.util.stream.Collectors;
import io.dekorate.kubernetes.config.Port;
import java.lang.String;
import io.dekorate.jaeger.config.JaegerAgentConfig;
import java.util.Comparator;
import io.dekorate.project.Project;
import io.dekorate.jaeger.annotation.EnableJaegerAgent;
import io.dekorate.project.BuildInfo;
import io.dekorate.jaeger.config.Collector;
import java.lang.Object;
import java.util.List;
import io.dekorate.kubernetes.annotation.Protocol;
import io.dekorate.project.ScmInfo;
import java.util.Arrays;
import java.util.Map;

public class JaegerAgentConfigAdapter {


    public static JaegerAgentConfig adapt(EnableJaegerAgent instance) {
        return newBuilder(instance).build();
    }

    public static JaegerAgentConfigBuilder newBuilder(EnableJaegerAgent instance) {
        return new JaegerAgentConfigBuilder(new io.dekorate.jaeger.config.JaegerAgentConfig(null,
                    null,
                    instance.operatorEnabled(),
                    instance.version(),
                    new io.dekorate.jaeger.config.Collector(instance.collector().host(),
                    instance.collector().name(),
                    instance.collector().namespace(),
                    instance.collector().port()),
                    Arrays.asList(instance.ports()).stream().map(i ->new io.dekorate.kubernetes.config.Port(i.name(),
                    i.containerPort(),
                    i.hostPort(),
                    i.path(),
                    i.protocol())).collect(Collectors.toList()).toArray(new io.dekorate.kubernetes.config.Port[0])));
    }

    public static JaegerAgentConfig adapt(Map map) {
        return new io.dekorate.jaeger.config.JaegerAgentConfig(
        null,
        null,
                       Boolean.parseBoolean(String.valueOf(map instanceof Map ? ((Map)map).getOrDefault("operatorEnabled","false") : "false")),
                       (String)(map instanceof Map ? ((Map)map).getOrDefault("version", "1.10") : "1.10"),
        new io.dekorate.jaeger.config.Collector(
                           (String)(((Map)(map instanceof Map ? ((Map)map).get("collector") : null)) instanceof Map ? ((Map)((Map)(map instanceof Map ? ((Map)map).get("collector") : null))).getOrDefault("host", "") : ""),
                           (String)(((Map)(map instanceof Map ? ((Map)map).get("collector") : null)) instanceof Map ? ((Map)((Map)(map instanceof Map ? ((Map)map).get("collector") : null))).getOrDefault("name", "jaeger-collector") : "jaeger-collector"),
                           (String)(((Map)(map instanceof Map ? ((Map)map).get("collector") : null)) instanceof Map ? ((Map)((Map)(map instanceof Map ? ((Map)map).get("collector") : null))).getOrDefault("namespace", "") : ""),
                           Integer.parseInt(String.valueOf(((Map)(map instanceof Map ? ((Map)map).get("collector") : null)) instanceof Map ? ((Map)((Map)(map instanceof Map ? ((Map)map).get("collector") : null))).getOrDefault("port","14267") : "14267"))),
                       Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("ports" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.kubernetes.config.Port(
                       (String)(i instanceof Map ? ((Map)i).getOrDefault("name", null) : null),
                       Integer.parseInt(String.valueOf(i instanceof Map ? ((Map)i).getOrDefault("containerPort","0") : "0")),
                       Integer.parseInt(String.valueOf(i instanceof Map ? ((Map)i).getOrDefault("hostPort","0") : "0")),
                       (String)(i instanceof Map ? ((Map)i).getOrDefault("path", "/") : "/"),
                       Protocol.valueOf(String.valueOf(i instanceof Map ? ((Map)i).getOrDefault("protocol","TCP") : "TCP")))).toArray(size-> new io.dekorate.kubernetes.config.Port[size]));
    }

    public static JaegerAgentConfigBuilder newBuilder(Map map) {
        return new JaegerAgentConfigBuilder(new io.dekorate.jaeger.config.JaegerAgentConfig(
        null,
        null,
                       Boolean.parseBoolean(String.valueOf(map instanceof Map ? ((Map)map).getOrDefault("operatorEnabled","false") : "false")),
                       (String)(map instanceof Map ? ((Map)map).getOrDefault("version", "1.10") : "1.10"),
        new io.dekorate.jaeger.config.Collector(
                           (String)(((Map)(map instanceof Map ? ((Map)map).get("collector") : null)) instanceof Map ? ((Map)((Map)(map instanceof Map ? ((Map)map).get("collector") : null))).getOrDefault("host", "") : ""),
                           (String)(((Map)(map instanceof Map ? ((Map)map).get("collector") : null)) instanceof Map ? ((Map)((Map)(map instanceof Map ? ((Map)map).get("collector") : null))).getOrDefault("name", "jaeger-collector") : "jaeger-collector"),
                           (String)(((Map)(map instanceof Map ? ((Map)map).get("collector") : null)) instanceof Map ? ((Map)((Map)(map instanceof Map ? ((Map)map).get("collector") : null))).getOrDefault("namespace", "") : ""),
                           Integer.parseInt(String.valueOf(((Map)(map instanceof Map ? ((Map)map).get("collector") : null)) instanceof Map ? ((Map)((Map)(map instanceof Map ? ((Map)map).get("collector") : null))).getOrDefault("port","14267") : "14267"))),
                       Arrays.stream((Map[])(map instanceof Map ? ((Map)map).getOrDefault("ports" , new Map[0]) : new Map[0])).map(i ->new io.dekorate.kubernetes.config.Port(
                       (String)(i instanceof Map ? ((Map)i).getOrDefault("name", null) : null),
                       Integer.parseInt(String.valueOf(i instanceof Map ? ((Map)i).getOrDefault("containerPort","0") : "0")),
                       Integer.parseInt(String.valueOf(i instanceof Map ? ((Map)i).getOrDefault("hostPort","0") : "0")),
                       (String)(i instanceof Map ? ((Map)i).getOrDefault("path", "/") : "/"),
                       Protocol.valueOf(String.valueOf(i instanceof Map ? ((Map)i).getOrDefault("protocol","TCP") : "TCP")))).toArray(size-> new io.dekorate.kubernetes.config.Port[size])));
    }

    public static String[] toStringArray(Object o) {
                if (o instanceof String[]) {
                  return (String[]) o;
                }
                if (o instanceof String) {
                  String s =  (String) o;
                  return s.split(",[ ]*");
                }
                else if (o instanceof List) {
                  List c = (List) o;
                  String[] result = new String[c.size()]; 
                  for (int i=0; i <= c.size(); i++) {
                    result[i] = String.valueOf(c.get(i));
                  }
                  return result;
                }
                return new String[0];
            
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy