<commit_before>package ekoshkin.teamcity.clouds.kubernetes;

import jetbrains.buildServer.agent.AgentLifeCycleAdapter;
import jetbrains.buildServer.agent.AgentLifeCycleListener;
import jetbrains.buildServer.agent.BuildAgent;
import jetbrains.buildServer.agent.BuildAgentConfigurationEx;
import jetbrains.buildServer.util.EventDispatcher;
import org.jetbrains.annotations.NotNull;

import java.util.Map;

/**
 * Created by ekoshkin (<EMAIL>) on 07.06.17.
 */
public class KubeAgentConfigurationProvider {
    @NotNull
    private final BuildAgentConfigurationEx myAgentConfigurationEx;

    public KubeAgentConfigurationProvider(@NotNull EventDispatcher<AgentLifeCycleListener> agentEvents,
                                          @NotNull BuildAgentConfigurationEx agentConfigurationEx) {
        myAgentConfigurationEx = agentConfigurationEx;
        agentEvents.addListener(new AgentLifeCycleAdapter(){
            @Override
            public void afterAgentConfigurationLoaded(@NotNull BuildAgent agent) {
                super.afterAgentConfigurationLoaded(agent);
                appendKubeSpecificConfiguration();
            }
        });
    }

    private void appendKubeSpecificConfiguration() {
        Map<String, String> env = System.getenv();
        myAgentConfigurationEx.setName(env.get(KubeContainerEnvironment.AGENT_NAME));
        myAgentConfigurationEx.setServerUrl(env.get(KubeContainerEnvironment.SERVER_URL));

        myAgentConfigurationEx.addConfigurationParameter(KubeAgentProperties.IMAGE_NAME, env.get(KubeContainerEnvironment.IMAGE_NAME));
        myAgentConfigurationEx.addConfigurationParameter(KubeAgentProperties.INSTANCE_NAME, env.get(KubeContainerEnvironment.INSTANCE_NAME));

        //TODO: review this
//        myAgentConfigurationEx.addAlternativeAgentAddress();
//        myAgentConfigurationEx.setAuthorizationToken();
    }
}<commit_msg>drop todo<commit_after>package ekoshkin.teamcity.clouds.kubernetes;

import jetbrains.buildServer.agent.AgentLifeCycleAdapter;
import jetbrains.buildServer.agent.AgentLifeCycleListener;
import jetbrains.buildServer.agent.BuildAgent;
import jetbrains.buildServer.agent.BuildAgentConfigurationEx;
import jetbrains.buildServer.util.EventDispatcher;
import org.jetbrains.annotations.NotNull;

import java.util.Map;

/**
 * Created by ekoshkin (<EMAIL>) on 07.06.17.
 */
public class KubeAgentConfigurationProvider {
    @NotNull
    private final BuildAgentConfigurationEx myAgentConfigurationEx;

    public KubeAgentConfigurationProvider(@NotNull EventDispatcher<AgentLifeCycleListener> agentEvents,
                                          @NotNull BuildAgentConfigurationEx agentConfigurationEx) {
        myAgentConfigurationEx = agentConfigurationEx;
        agentEvents.addListener(new AgentLifeCycleAdapter(){
            @Override
            public void afterAgentConfigurationLoaded(@NotNull BuildAgent agent) {
                super.afterAgentConfigurationLoaded(agent);
                appendKubeSpecificConfiguration();
            }
        });
    }

    private void appendKubeSpecificConfiguration() {
        Map<String, String> env = System.getenv();
        myAgentConfigurationEx.setName(env.get(KubeContainerEnvironment.AGENT_NAME));
        myAgentConfigurationEx.setServerUrl(env.get(KubeContainerEnvironment.SERVER_URL));

        myAgentConfigurationEx.addConfigurationParameter(KubeAgentProperties.IMAGE_NAME, env.get(KubeContainerEnvironment.IMAGE_NAME));
        myAgentConfigurationEx.addConfigurationParameter(KubeAgentProperties.INSTANCE_NAME, env.get(KubeContainerEnvironment.INSTANCE_NAME));
    }
}
{'fraction_non_alphanumeric': 0.07660398230088496, 'fraction_numerical': 0.00331858407079646, 'mean_word_length': 4.226878612716763, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6278538', 'n_tokens_mistral': 912, 'n_tokens_neox': 871, 'n_words': 130}