Skip to content
Permalink
Browse files
TC Bot engine module introduced: refactoring of TC Bot config
  • Loading branch information
dspavlov committed Jun 9, 2019
1 parent 6a54abd commit 6b725961e58c576a2aaef4681b22a6eadcd79a49
Show file tree
Hide file tree
Showing 61 changed files with 526 additions and 346 deletions.
@@ -2,7 +2,7 @@
#Enter email to send messages from, dev-list subsricption may be required
username=

#Use org.apache.ignite.ci.tcbot.conf.PasswordEncoder to encode password
#Use org.apache.ignite.tcbot.common.conf.PasswordEncoder to encode password
encoded_password=

#Specify slack Auth token
@@ -18,32 +18,22 @@
package org.apache.ignite.ci;

import com.google.common.base.Preconditions;
import com.google.gson.Gson;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Properties;

import org.apache.ignite.ci.tcbot.conf.BranchesTracked;
import org.apache.ignite.tcbot.common.util.Base64Util;
import org.apache.ignite.tcbot.common.conf.TcBotWorkDir;
import org.apache.ignite.tcbot.common.exeption.ExceptionUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Strings.isNullOrEmpty;

/**
* TC Helper Config access, tracked branches, etc stuff.
*/
public class HelperConfig {
public static final String CONFIG_FILE_NAME = "auth.properties";
public static final String MAIL_PROPS = "mail.auth.properties";
public static final String HOST = "host";
public static final String USERNAME = "username";
public static final String ENCODED_PASSWORD = "encoded_password";

/** GitHub authorization token property name. */
public static final String GITHUB_AUTH_TOKEN = "github.auth_token";
@@ -64,10 +54,6 @@ public class HelperConfig {
@Deprecated
public static final String JIRA_TICKET_TEMPLATE = "jira.ticket_template";

/** Slack authorization token property name. */
public static final String SLACK_AUTH_TOKEN = "slack.auth_token";
@Deprecated
public static final String SLACK_CHANNEL = "slack.channel";
public static final String LOGS = "logs";

public static Properties loadAuthProperties(File workDir, String cfgFileName) {
@@ -107,33 +93,4 @@ private static String prefixedWithServerName(@Nullable String tcName, String nam
return isNullOrEmpty(tcName) ? name : (tcName + "." + name);
}

@NotNull public static String userPwdToToken(String user, String pwd) {
return Base64Util.encodeUtf8String(user + ":" + pwd);
}

public static BranchesTracked getTrackedBranches() {
final File workDir = TcBotWorkDir.resolveWorkDir();
final File file = new File(workDir, "branches.json");

try (FileReader json = new FileReader(file)) {
return new Gson().fromJson(json, BranchesTracked.class);
}
catch (IOException e) {
throw ExceptionUtil.propagateException(e);
}
}

public static Properties loadEmailSettings() {
try {
String respConf = prefixedWithServerName(null, MAIL_PROPS);
final File workDir = TcBotWorkDir.resolveWorkDir();
File file = new File(workDir, respConf);
return loadProps(file);
}
catch (IOException e) {
e.printStackTrace();
return new Properties();
}
}

}
@@ -38,7 +38,7 @@
import org.apache.ignite.ci.github.GitHubBranchShort;
import org.apache.ignite.ci.github.PullRequest;
import org.apache.ignite.ci.github.pure.IGitHubConnection;
import org.apache.ignite.ci.tcbot.conf.IGitHubConfig;
import org.apache.ignite.tcbot.common.conf.IGitHubConfig;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -18,8 +18,8 @@

import java.util.List;
import org.apache.ignite.ci.github.PullRequest;
import org.apache.ignite.ci.tcbot.conf.IGitHubConfig;
import org.apache.ignite.ci.tcbot.conf.IJiraServerConfig;
import org.apache.ignite.tcbot.common.conf.IGitHubConfig;
import org.apache.ignite.tcbot.common.conf.IJiraServerConfig;

/**
*
@@ -23,8 +23,8 @@
import org.apache.ignite.tcbot.common.interceptor.AutoProfiling;
import org.apache.ignite.ci.github.GitHubBranchShort;
import org.apache.ignite.ci.github.PullRequest;
import org.apache.ignite.ci.tcbot.conf.IGitHubConfig;
import org.apache.ignite.ci.tcbot.conf.ITcBotConfig;
import org.apache.ignite.tcbot.common.conf.IGitHubConfig;
import org.apache.ignite.tcbot.engine.conf.ITcBotConfig;
import org.apache.ignite.tcbot.common.util.HttpUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -22,7 +22,7 @@
import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.ci.github.GitHubBranchShort;
import org.apache.ignite.ci.github.PullRequest;
import org.apache.ignite.ci.tcbot.conf.IGitHubConfig;
import org.apache.ignite.tcbot.common.conf.IGitHubConfig;
import org.jetbrains.annotations.Nullable;

import javax.annotation.Nonnull;
@@ -19,7 +19,7 @@
import java.io.IOException;
import java.util.Set;
import org.apache.ignite.ci.jira.pure.Ticket;
import org.apache.ignite.ci.tcbot.conf.IJiraServerConfig;
import org.apache.ignite.tcbot.common.conf.IJiraServerConfig;

/**
*
@@ -21,7 +21,7 @@
import javax.inject.Inject;
import org.apache.ignite.ci.jira.pure.IJiraIntegration;
import org.apache.ignite.ci.jira.pure.Ticket;
import org.apache.ignite.ci.tcbot.conf.IJiraServerConfig;
import org.apache.ignite.tcbot.common.conf.IJiraServerConfig;
import org.apache.ignite.tcignited.ITeamcityIgnited;

/**
@@ -30,7 +30,7 @@
import org.apache.ignite.ci.jira.pure.IJiraIntegration;
import org.apache.ignite.ci.jira.pure.IJiraIntegrationProvider;
import org.apache.ignite.ci.jira.pure.Ticket;
import org.apache.ignite.ci.tcbot.conf.IJiraServerConfig;
import org.apache.ignite.tcbot.common.conf.IJiraServerConfig;
import org.apache.ignite.tcignited.ITeamcityIgnited;
import org.apache.ignite.internal.util.typedef.F;
import org.jetbrains.annotations.NotNull;
@@ -19,7 +19,7 @@

import java.io.IOException;
import org.apache.ignite.ci.jira.Tickets;
import org.apache.ignite.ci.tcbot.conf.IJiraServerConfig;
import org.apache.ignite.tcbot.common.conf.IJiraServerConfig;

/**
* Reperesents methods to provide interaction with Jira servers.
@@ -21,8 +21,8 @@
import com.google.gson.Gson;
import org.apache.ignite.tcbot.common.interceptor.AutoProfiling;
import org.apache.ignite.ci.jira.Tickets;
import org.apache.ignite.ci.tcbot.conf.IJiraServerConfig;
import org.apache.ignite.ci.tcbot.conf.ITcBotConfig;
import org.apache.ignite.tcbot.common.conf.IJiraServerConfig;
import org.apache.ignite.tcbot.engine.conf.ITcBotConfig;
import org.apache.ignite.tcbot.common.util.HttpUtil;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;

0 comments on commit 6b72596

Please sign in to comment.