me.snowdrop.istio.api.internal.IstioSpecRegistry Maven / Gradle / Ivy
Show all versions of istio-common Show documentation
package me.snowdrop.istio.api.internal;
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/
import me.snowdrop.istio.api.IstioSpec;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author Christophe Laprun
*/
public class IstioSpecRegistry {
private static final String ISTIO_PACKAGE_PREFIX = "me.snowdrop.istio.";
private static final String ISTIO_API_PACKAGE_PREFIX = ISTIO_PACKAGE_PREFIX + "api.";
private static final String ISTIO_MIXER_TEMPLATE_PACKAGE_PREFIX = ISTIO_PACKAGE_PREFIX + "mixer.template.";
private static final String ISTIO_ADAPTER_PACKAGE_PREFIX = ISTIO_PACKAGE_PREFIX + "adapter.";
private static final Map crdInfos = new HashMap<>();
static {
Properties crdFile = new Properties();
try (final InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("istio-crd.properties")) {
crdFile.load(inputStream);
} catch (Exception e) {
throw new RuntimeException("Couldn't load Istio CRD information from classpath", e);
}
crdInfos.putAll(crdFile.entrySet().stream().collect(Collectors.toMap(IstioSpecRegistry::getCRDKeyFrom, IstioSpecRegistry::getCRDInfoFrom)));
}
private static CRDInfo getCRDInfoFrom(Map.Entry