<commit_before>package io.syndesis.qe.templates;

import static org.assertj.core.api.Assertions.assertThat;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeoutException;

import io.fabric8.kubernetes.api.model.KubernetesList;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.openshift.api.model.Template;
import io.syndesis.qe.TestConfiguration;
import io.syndesis.qe.accounts.Account;
import io.syndesis.qe.accounts.AccountsDirectory;
import io.syndesis.qe.utils.HttpUtils;
import io.syndesis.qe.utils.OpenShiftUtils;
import io.syndesis.qe.wait.OpenShiftWaitUtils;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Headers;
import okhttp3.Response;

@Slf4j
public class KafkaTemplate {
    private static final String[] KAFKA_STRIMZI_RESOURCES = new String[] {
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/master/examples/install/cluster-operator/01-service-account.yaml",
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/master/examples/install/cluster-operator/02-role.yaml",
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/master/examples/install/cluster-operator/03-role-binding.yaml",
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/master/examples/install/cluster-operator/04-service-account-kafka.yaml",
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/master/examples/install/cluster-operator/05-role-kafka.yaml",
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/master/examples/install/cluster-operator/06-role-binding-kafka.yaml",
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/master/examples/install/cluster-operator/07-deployment.yaml",
    };

    private static final String KAFKA_TEMPLATE =
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/master/examples/templates/cluster-operator/ephemeral-template.yaml";

    public static void deploy() {
        if (!isUserAdmin()) {
            log.error("*************************************************");
            log.error("* Kafka deployment needs user with admin rights *");
            log.error("*************************************************");
            log.error("If you are using minishift, you can use \"oc adm policy --as system:admin add-cluster-role-to-user cluster-admin developer\"");
            throw new RuntimeException("Kafka deployment needs user with admin rights!");
        }
        for (String resource : KAFKA_STRIMZI_RESOURCES) {
            process(resource);
        }

        Template template;
        try (InputStream is = new URL(KAFKA_TEMPLATE).openStream()) {
            template = OpenShiftUtils.client().templates().load(is).get();
        } catch (IOException ex) {
            throw new IllegalArgumentException("Unable to read template ", ex);<commit_msg>[FUSEQE-1109] Use stable tag instead of master<commit_after>package io.syndesis.qe.templates;

import static org.assertj.core.api.Assertions.assertThat;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeoutException;

import io.fabric8.kubernetes.api.model.KubernetesList;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.openshift.api.model.Template;
import io.syndesis.qe.TestConfiguration;
import io.syndesis.qe.accounts.Account;
import io.syndesis.qe.accounts.AccountsDirectory;
import io.syndesis.qe.utils.HttpUtils;
import io.syndesis.qe.utils.OpenShiftUtils;
import io.syndesis.qe.wait.OpenShiftWaitUtils;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Headers;
import okhttp3.Response;

@Slf4j
public class KafkaTemplate {
    private static final String[] KAFKA_STRIMZI_RESOURCES = new String[] {
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/0.4.0/examples/install/cluster-operator/01-service-account.yaml",
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/0.4.0/examples/install/cluster-operator/02-role.yaml",
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/0.4.0/examples/install/cluster-operator/03-role-binding.yaml",
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/0.4.0/examples/install/cluster-operator/04-deployment.yaml",
    };

    private static final String KAFKA_TEMPLATE =
            "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/0.4.0/examples/templates/cluster-operator/ephemeral-template.yaml";

    public static void deploy() {
        if (!isUserAdmin()) {
            log.error("*************************************************");
            log.error("* Kafka deployment needs user with admin rights *");
            log.error("*************************************************");
            log.error("If you are using minishift, you can use \"oc adm policy --as system:admin add-cluster-role-to-user cluster-admin developer\"");
            throw new RuntimeException("Kafka deployment needs user with admin rights!");
        }
        for (String resource : KAFKA_STRIMZI_RESOURCES) {
            process(resource);
        }

        Template template;
        try (InputStream is = new URL(KAFKA_TEMPLATE).openStream()) {
            template = OpenShiftUtils.client().templates().load(is).get();
        } catch (IOException ex) {
            throw new IllegalArgumentException("Unable to read template ", ex);
{'fraction_non_alphanumeric': 0.15132365499573014, 'fraction_numerical': 0.010076857386848848, 'mean_word_length': 3.8, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 13, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1565565', 'n_tokens_mistral': 1814, 'n_tokens_neox': 1746, 'n_words': 270}