protected Configuration getConfiguration() { return enricherContext.getConfiguration(); }
protected boolean hasImageConfiguration() { return !enricherContext.getConfiguration().getImages().orElse(Collections.emptyList()).isEmpty(); }
protected Optional<List<ImageConfiguration>> getImages() { return enricherContext.getConfiguration().getImages(); }
protected Boolean asBooleanFromGlobalProp(String prop) { String value = getContext().getConfiguration().getProperty(prop); if (value == null) { value = System.getProperty(prop); } return value != null ? Boolean.valueOf(value) : null; }
private Optional<Object> getElement(String... path) { final Optional<Map<String, Object>> configuration = getContext().getConfiguration().getPluginConfiguration("maven", "io.fabric8:fabric8-maven-plugin"); if (!configuration.isPresent()) { return Optional.empty(); } String[] roots = new String[]{"enricher", "config", "f8-healthcheck-vertx"}; List<String> absolute = new ArrayList<>(); absolute.addAll(Arrays.asList(roots)); absolute.addAll(Arrays.asList(path)); Object root = configuration.get(); for (String key : absolute) { if (root instanceof Map) { Map<String, Object> rootMap = (Map<String, Object>) root; root = rootMap.get(key); if (root == null) { return Optional.empty(); } } } return Optional.of(root); }
@Override protected Map<String, String> generateData(String dockerId) { final Configuration config = getContext().getConfiguration(); final Optional<Map<String,Object>> secretConfig = config.getSecretConfiguration(dockerId); if (!secretConfig.isPresent()) { return null; } JsonObject params = new JsonObject(); for (String key : new String[] { "username", "password", "email" }) { if (secretConfig.get().containsKey(key)) { params.add(key, new JsonPrimitive(secretConfig.get().get(key).toString())); } } JsonObject ret = new JsonObject(); ret.add(dockerId, params); return Collections.singletonMap( SecretConstants.DOCKER_DATA_KEY, encode(ret.toString())); } }
private String getNamespace() { String namespace = getConfig(Config.namespace); if (StringUtils.isNotBlank(namespace)){ return namespace; } namespace = getContext().getConfiguration().getProperty("fabric8.namespace"); if (StringUtils.isNotBlank(namespace)){ return namespace; } namespace = System.getProperty("fabric8.namespace"); if (StringUtils.isNotBlank(namespace)){ return namespace; } return KubernetesHelper.getDefaultNamespace(); } }
private boolean debugEnabled() { String value = getContext().getConfiguration().getProperties().getProperty(ENABLE_DEBUG_MAVEN_PROPERTY); if (value != null && isTrueFlag(value)) { return true; } return isTrueFlag(System.getProperty(ENABLE_DEBUG_MAVEN_PROPERTY)); }
public BaseEnricher(EnricherContext enricherContext, String name) { this.enricherContext = enricherContext; // Pick the configuration which is for us this.config = new EnricherConfig(name, enricherContext.getConfiguration()); this.log = new PrefixedLogger(name, enricherContext.getLog()); this.name = name; }
/** * Returns true if we are in OpenShift S2I binary building mode */ protected boolean isOpenShiftMode() { Properties properties = getContext().getConfiguration().getProperties(); if (properties != null) { return PlatformMode.isOpenShiftMode(properties); } return false; } }
private Optional<String> getStringValue(String attribute, boolean readiness) { String specific = getSpecificPropertyName(readiness, attribute); String generic = VERTX_HEALTH + attribute; // Check if we have the specific user property. Configuration contextConfig = getContext().getConfiguration(); String property = contextConfig.getProperty(specific); if (property != null) { return Optional.of(property).map(TRIM); } property = contextConfig.getProperty(generic); if (property != null) { return Optional.of(property).map(TRIM); } String[] specificPath = new String[]{ readiness ? "readiness" : "liveness", attribute }; Optional<String> config = getValueFromConfig(specificPath).map(TRIM); if (!config.isPresent()) { // Generic path. return getValueFromConfig(attribute).map(TRIM); } else { return config; } }
if (StringUtils.isNotBlank(url)) { url = replaceProperties(url, getContext().getConfiguration().getProperties());
public EnricherManager(ResourceConfig resourceConfig, EnricherContext enricherContext, Optional<List<String>> extraClasspathElements) { PluginServiceFactory<EnricherContext> pluginFactory = new PluginServiceFactory<>(enricherContext); extraClasspathElements.ifPresent( cpElements -> pluginFactory.addAdditionalClassLoader(ClassUtil.createProjectClassLoader(cpElements, enricherContext.getLog()))); this.log = enricherContext.getLog(); this.defaultEnricherConfig = enricherContext.getConfiguration().getProcessorConfig().orElse(ProcessorConfig.EMPTY); this.enrichers = pluginFactory.createServiceObjects("META-INF/fabric8-enricher-default", "META-INF/fabric8/enricher-default", "META-INF/fabric8-enricher", "META-INF/fabric8/enricher"); logEnrichers(filterEnrichers(defaultEnricherConfig, enrichers)); }
public ControllerViaPluginConfigurationEnricher(MavenEnricherContext context) { super(context, "fmp-controller-from-configuration"); HandlerHub handlers = new HandlerHub( getContext().getGav(), getContext().getConfiguration().getProperties()); deployHandler = handlers.getDeploymentHandler(); statefulSetHandler = handlers.getStatefulSetHandler(); }
private Probe discoverKarafProbe(String path, int initialDelay) { final Optional<Map<String, Object>> configurationValues = getContext().getConfiguration().getPluginConfiguration("maven", "karaf-maven-plugin");
String gitRemote = getContext().getConfiguration().getProperties().getProperty(GIT_REMOTE); gitRemote = gitRemote == null? "origin" : gitRemote; String gitRemoteUrl = repository.getConfig().getString("remote", gitRemote, "url");
public DefaultControllerEnricher(MavenEnricherContext buildContext) { super(buildContext, "fmp-controller"); HandlerHub handlers = new HandlerHub( getContext().getGav(), getContext().getConfiguration().getProperties()); rcHandler = handlers.getReplicationControllerHandler(); rsHandler = handlers.getReplicaSetHandler(); deployHandler = handlers.getDeploymentHandler(); statefulSetHandler = handlers.getStatefulSetHandler(); daemonSetHandler = handlers.getDaemonSetHandler(); jobHandler = handlers.getJobHandler(); }