Sets up deploying discordbot with geth env vars
This commit is contained in:
parent
fde19383df
commit
c3fb7384e3
@ -22,6 +22,14 @@ namespace CodexDiscordBotPlugin
|
|||||||
AddEnvVar("KUBECONFIG", "/opt/kubeconfig.yaml");
|
AddEnvVar("KUBECONFIG", "/opt/kubeconfig.yaml");
|
||||||
AddEnvVar("KUBENAMESPACE", config.KubeNamespace);
|
AddEnvVar("KUBENAMESPACE", config.KubeNamespace);
|
||||||
|
|
||||||
|
var gethInfo = config.GethInfo;
|
||||||
|
AddEnvVar("GETH_HOST", gethInfo.Host);
|
||||||
|
AddEnvVar("GETH_HTTP_PORT", gethInfo.Port.ToString());
|
||||||
|
AddEnvVar("GETH_PRIVATE_KEY", gethInfo.PrivKey);
|
||||||
|
AddEnvVar("CODEXCONTRACTS_MARKETPLACEADDRESS", gethInfo.MarketplaceAddress);
|
||||||
|
AddEnvVar("CODEXCONTRACTS_TOKENADDRESS", gethInfo.TokenAddress);
|
||||||
|
AddEnvVar("CODEXCONTRACTS_ABI", gethInfo.Abi);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(config.DataPath))
|
if (!string.IsNullOrEmpty(config.DataPath))
|
||||||
{
|
{
|
||||||
AddEnvVar("DATAPATH", config.DataPath);
|
AddEnvVar("DATAPATH", config.DataPath);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class DiscordBotStartupConfig
|
public class DiscordBotStartupConfig
|
||||||
{
|
{
|
||||||
public DiscordBotStartupConfig(string name, string token, string serverName, string adminRoleName, string adminChannelName, string kubeNamespace)
|
public DiscordBotStartupConfig(string name, string token, string serverName, string adminRoleName, string adminChannelName, string kubeNamespace, DiscordBotGethInfo gethInfo)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
Token = token;
|
Token = token;
|
||||||
@ -10,6 +10,7 @@
|
|||||||
AdminRoleName = adminRoleName;
|
AdminRoleName = adminRoleName;
|
||||||
AdminChannelName = adminChannelName;
|
AdminChannelName = adminChannelName;
|
||||||
KubeNamespace = kubeNamespace;
|
KubeNamespace = kubeNamespace;
|
||||||
|
GethInfo = gethInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
@ -18,6 +19,27 @@
|
|||||||
public string AdminRoleName { get; }
|
public string AdminRoleName { get; }
|
||||||
public string AdminChannelName { get; }
|
public string AdminChannelName { get; }
|
||||||
public string KubeNamespace { get; }
|
public string KubeNamespace { get; }
|
||||||
|
public DiscordBotGethInfo GethInfo { get; }
|
||||||
public string? DataPath { get; set; }
|
public string? DataPath { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DiscordBotGethInfo
|
||||||
|
{
|
||||||
|
public DiscordBotGethInfo(string host, int port, string privKey, string marketplaceAddress, string tokenAddress, string abi)
|
||||||
|
{
|
||||||
|
Host = host;
|
||||||
|
Port = port;
|
||||||
|
PrivKey = privKey;
|
||||||
|
MarketplaceAddress = marketplaceAddress;
|
||||||
|
TokenAddress = tokenAddress;
|
||||||
|
Abi = abi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Host { get; }
|
||||||
|
public int Port { get; }
|
||||||
|
public string PrivKey { get; }
|
||||||
|
public string MarketplaceAddress { get; }
|
||||||
|
public string TokenAddress { get; }
|
||||||
|
public string Abi { get; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ namespace CodexNetDeployer
|
|||||||
|
|
||||||
var codexInstances = CreateCodexInstances(startResults);
|
var codexInstances = CreateCodexInstances(startResults);
|
||||||
|
|
||||||
var discordBotContainer = DeployDiscordBot(ci);
|
var discordBotContainer = DeployDiscordBot(ci, gethDeployment, contractsDeployment);
|
||||||
|
|
||||||
return new CodexDeployment(codexInstances, gethDeployment, contractsDeployment, metricsService, discordBotContainer, CreateMetadata(startUtc));
|
return new CodexDeployment(codexInstances, gethDeployment, contractsDeployment, metricsService, discordBotContainer, CreateMetadata(startUtc));
|
||||||
}
|
}
|
||||||
@ -120,18 +120,29 @@ namespace CodexNetDeployer
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private RunningContainers? DeployDiscordBot(CoreInterface ci)
|
private RunningContainers? DeployDiscordBot(CoreInterface ci, GethDeployment gethDeployment, CodexContractsDeployment contractsDeployment)
|
||||||
{
|
{
|
||||||
if (!config.DeployDiscordBot) return null;
|
if (!config.DeployDiscordBot) return null;
|
||||||
Log("Deploying Discord bot...");
|
Log("Deploying Discord bot...");
|
||||||
|
|
||||||
|
var addr = gethDeployment.Container.GetInternalAddress(GethContainerRecipe.HttpPortTag);
|
||||||
|
var info = new DiscordBotGethInfo(
|
||||||
|
host: addr.Host,
|
||||||
|
port: addr.Port,
|
||||||
|
privKey: gethDeployment.Account.PrivateKey,
|
||||||
|
marketplaceAddress: contractsDeployment.MarketplaceAddress,
|
||||||
|
tokenAddress: contractsDeployment.TokenAddress,
|
||||||
|
abi: contractsDeployment.Abi
|
||||||
|
);
|
||||||
|
|
||||||
var rc = ci.DeployCodexDiscordBot(new DiscordBotStartupConfig(
|
var rc = ci.DeployCodexDiscordBot(new DiscordBotStartupConfig(
|
||||||
name: "discordbot-" + config.DeploymentName,
|
name: "discordbot-" + config.DeploymentName,
|
||||||
token: config.DiscordBotToken,
|
token: config.DiscordBotToken,
|
||||||
serverName: config.DiscordBotServerName,
|
serverName: config.DiscordBotServerName,
|
||||||
adminRoleName: config.DiscordBotAdminRoleName,
|
adminRoleName: config.DiscordBotAdminRoleName,
|
||||||
adminChannelName: config.DiscordBotAdminChannelName,
|
adminChannelName: config.DiscordBotAdminChannelName,
|
||||||
kubeNamespace: config.KubeNamespace)
|
kubeNamespace: config.KubeNamespace,
|
||||||
|
gethInfo: info)
|
||||||
{
|
{
|
||||||
DataPath = config.DiscordBotDataPath
|
DataPath = config.DiscordBotDataPath
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user