Search in sources :

Example 1 with JKubeEnricherContext

use of org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext in project jkube by eclipse.

the class WildflyJARHealthCheckEnricher method isAvailable.

private boolean isAvailable() {
    if (isProbeEnforced()) {
        return true;
    }
    JavaProject project = ((JKubeEnricherContext) getContext()).getProject();
    Plugin plugin = JKubeProjectUtil.getPlugin(project, BOOTABLE_JAR_GROUP_ID, BOOTABLE_JAR_ARTIFACT_ID);
    if (plugin == null) {
        return false;
    }
    Map<String, Object> config = plugin.getConfiguration();
    return config.containsKey("cloud");
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) JKubeEnricherContext(org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext) Plugin(org.eclipse.jkube.kit.common.Plugin)

Example 2 with JKubeEnricherContext

use of org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext in project jkube by eclipse.

the class MavenIssueManagementEnricher method getAnnotations.

private Map<String, String> getAnnotations() {
    Map<String, String> annotations = new HashMap<>();
    if (getContext() instanceof JKubeEnricherContext) {
        JKubeEnricherContext jkubeEnricherContext = (JKubeEnricherContext) getContext();
        JavaProject rootProject = jkubeEnricherContext.getProject();
        if (hasIssueManagement(rootProject)) {
            String system = rootProject.getIssueManagementSystem();
            String url = rootProject.getIssueManagementUrl();
            if (StringUtils.isNotEmpty(system) && StringUtils.isNotEmpty(url)) {
                annotations.put(JKubeAnnotations.ISSUE_SYSTEM.value(), system);
                annotations.put(JKubeAnnotations.ISSUE_TRACKER_URL.value(), url);
            }
        }
    }
    return annotations;
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) JKubeEnricherContext(org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext) HashMap(java.util.HashMap)

Example 3 with JKubeEnricherContext

use of org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext in project jkube by eclipse.

the class MavenScmEnricher method getAnnotations.

private Map<String, String> getAnnotations() {
    Map<String, String> annotations = new HashMap<>();
    if (getContext() instanceof JKubeEnricherContext) {
        JKubeEnricherContext jkubeEnricherContext = (JKubeEnricherContext) getContext();
        JavaProject rootProject = jkubeEnricherContext.getProject();
        if (hasScm(rootProject)) {
            String url = rootProject.getScmUrl();
            String tag = rootProject.getScmTag();
            if (StringUtils.isNotEmpty(tag)) {
                annotations.put(JKubeAnnotations.SCM_TAG.value(), tag);
            }
            if (StringUtils.isNotEmpty(url)) {
                annotations.put(JKubeAnnotations.SCM_URL.value(), url);
            }
        }
    }
    return annotations;
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) JKubeEnricherContext(org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext) HashMap(java.util.HashMap)

Example 4 with JKubeEnricherContext

use of org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext in project jkube by eclipse.

the class SecretEnricher method addSecretsFromXmlConfiguration.

private void addSecretsFromXmlConfiguration(KubernetesListBuilder builder) {
    log.verbose("Adding secrets resources from plugin configuration");
    List<SecretConfig> secrets = getSecretsFromXmlConfig();
    Map<String, Integer> secretToIndexMap = new HashMap<>();
    if (secrets == null || secrets.isEmpty()) {
        return;
    }
    for (Integer index = 0; index < builder.buildItems().size(); index++) {
        if (builder.buildItems().get(index) instanceof Secret) {
            secretToIndexMap.put(builder.buildItems().get(index).getMetadata().getName(), index);
        }
    }
    for (int i = 0; i < secrets.size(); i++) {
        SecretConfig secretConfig = secrets.get(i);
        if (StringUtils.isBlank(secretConfig.getName())) {
            log.warn("Secret name is empty. You should provide a proper name for the secret");
            continue;
        }
        Map<String, String> data = new HashMap<>();
        String type = "";
        ObjectMeta metadata = new ObjectMetaBuilder().withNamespace(secretConfig.getNamespace()).withName(secretConfig.getName()).build();
        // docker-registry
        if (secretConfig.getDockerServerId() != null) {
            JKubeEnricherContext mavenContext = ((JKubeEnricherContext) getContext());
            String dockerSecret = (mavenContext).getDockerJsonConfigString(mavenContext.getSettings(), secretConfig.getDockerServerId());
            if (StringUtils.isBlank(dockerSecret)) {
                log.warn("Docker secret with id " + secretConfig.getDockerServerId() + " cannot be found in maven settings");
                continue;
            }
            data.put(SecretConstants.DOCKER_DATA_KEY, Base64Util.encodeToString(dockerSecret));
            type = SecretConstants.DOCKER_CONFIG_TYPE;
        }
        if (StringUtils.isBlank(type) || data.isEmpty()) {
            log.warn("No data can be found for docker secret with id " + secretConfig.getDockerServerId());
            continue;
        }
        Secret secret = new SecretBuilder().withData(data).withMetadata(metadata).withType(type).build();
        if (!secretToIndexMap.containsKey(secretConfig.getName())) {
            builder.addToSecretItems(i, secret);
        }
    }
}
Also used : ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) HashMap(java.util.HashMap) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) Secret(io.fabric8.kubernetes.api.model.Secret) SecretBuilder(io.fabric8.kubernetes.api.model.SecretBuilder) SecretConfig(org.eclipse.jkube.kit.config.resource.SecretConfig) JKubeEnricherContext(org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext)

Aggregations

JKubeEnricherContext (org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext)4 HashMap (java.util.HashMap)3 JavaProject (org.eclipse.jkube.kit.common.JavaProject)3 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)1 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)1 Secret (io.fabric8.kubernetes.api.model.Secret)1 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)1 Plugin (org.eclipse.jkube.kit.common.Plugin)1 SecretConfig (org.eclipse.jkube.kit.config.resource.SecretConfig)1