Removes codexdeployment from input of discord bot.
This commit is contained in:
parent
ade08a27fe
commit
dfe477d192
|
@ -1,6 +1,5 @@
|
|||
using Core;
|
||||
using KubernetesWorkflow;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace CodexDiscordBotPlugin
|
||||
{
|
||||
|
@ -22,7 +21,7 @@ namespace CodexDiscordBotPlugin
|
|||
|
||||
public void AddMetadata(IAddMetadata metadata)
|
||||
{
|
||||
metadata.Add("codexdiscordbotid", "todo");
|
||||
metadata.Add("codexdiscordbotid", new DiscordBotContainerRecipe().Image);
|
||||
}
|
||||
|
||||
public void Decommission()
|
||||
|
@ -32,9 +31,7 @@ namespace CodexDiscordBotPlugin
|
|||
public RunningContainer Deploy(DiscordBotStartupConfig config)
|
||||
{
|
||||
var workflow = tools.CreateWorkflow();
|
||||
var container = StartContainer(workflow, config);
|
||||
WriteCodexDeploymentToContainerFile(workflow, container, config);
|
||||
return container;
|
||||
return StartContainer(workflow, config);
|
||||
}
|
||||
|
||||
private RunningContainer StartContainer(IStartupWorkflow workflow, DiscordBotStartupConfig config)
|
||||
|
@ -45,20 +42,5 @@ namespace CodexDiscordBotPlugin
|
|||
var rc = workflow.Start(1, new DiscordBotContainerRecipe(), startupConfig);
|
||||
return rc.Containers.Single();
|
||||
}
|
||||
|
||||
private void WriteCodexDeploymentToContainerFile(IStartupWorkflow workflow, RunningContainer rc, DiscordBotStartupConfig config)
|
||||
{
|
||||
var lines = JsonConvert.SerializeObject(config.CodexDeployment, Formatting.Indented).Split('\n');
|
||||
if (lines.Length < 10) throw new Exception("Didn't expect that.");
|
||||
|
||||
var targetFile = DiscordBotContainerRecipe.EndpointsPath;
|
||||
var op = ">";
|
||||
|
||||
foreach (var line in lines)
|
||||
{
|
||||
workflow.ExecuteCommand(rc, $"echo \"{line}\" {op} {targetFile}");
|
||||
op = ">>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace CodexDiscordBotPlugin
|
|||
{
|
||||
public class DiscordBotContainerRecipe : ContainerRecipeFactory
|
||||
{
|
||||
public const string EndpointsPath = "/var/endpoints";
|
||||
public override string AppName => "discordbot-bibliotech";
|
||||
public override string Image => "thatbenbierens/codex-discordbot:initial";
|
||||
|
||||
|
@ -15,8 +14,6 @@ namespace CodexDiscordBotPlugin
|
|||
AddEnvVar("TOKEN", config.Token);
|
||||
AddEnvVar("SERVERNAME", config.ServerName);
|
||||
AddEnvVar("ADMINROLE", config.AdminRoleName);
|
||||
|
||||
AddEnvVar("ENDPOINTS", EndpointsPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,19 +4,17 @@ namespace CodexDiscordBotPlugin
|
|||
{
|
||||
public class DiscordBotStartupConfig
|
||||
{
|
||||
public DiscordBotStartupConfig(string name, string token, string serverName, string adminRoleName, CodexDeployment codexDeployment)
|
||||
public DiscordBotStartupConfig(string name, string token, string serverName, string adminRoleName)
|
||||
{
|
||||
Name = name;
|
||||
Token = token;
|
||||
ServerName = serverName;
|
||||
AdminRoleName = adminRoleName;
|
||||
CodexDeployment = codexDeployment;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
public string Token { get; }
|
||||
public string ServerName { get; }
|
||||
public string AdminRoleName { get; }
|
||||
public CodexDeployment CodexDeployment { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,13 +82,12 @@ namespace CodexNetDeployer
|
|||
|
||||
var codexContainers = startResults.Select(s => s.CodexNode.Container).ToArray();
|
||||
|
||||
var deployment = new CodexDeployment(codexContainers, gethDeployment, contractsDeployment, metricsService, null, CreateMetadata(startUtc));
|
||||
var discordBotContainer = DeployDiscordBot(ci, deployment);
|
||||
var discordBotContainer = DeployDiscordBot(ci);
|
||||
|
||||
return new CodexDeployment(codexContainers, gethDeployment, contractsDeployment, metricsService, discordBotContainer, CreateMetadata(startUtc));
|
||||
}
|
||||
|
||||
private RunningContainer? DeployDiscordBot(CoreInterface ci, CodexDeployment deployment)
|
||||
private RunningContainer? DeployDiscordBot(CoreInterface ci)
|
||||
{
|
||||
if (!config.DeployDiscordBot) return null;
|
||||
Log("Deploying Discord bot...");
|
||||
|
@ -97,8 +96,7 @@ namespace CodexNetDeployer
|
|||
name: "discordbot-" + config.DeploymentName,
|
||||
token: config.DiscordBotToken,
|
||||
serverName: config.DiscordBotServerName,
|
||||
adminRoleName: config.DiscordBotAdminRoleName,
|
||||
deployment));
|
||||
adminRoleName: config.DiscordBotAdminRoleName));
|
||||
|
||||
Log("Discord bot deployed.");
|
||||
return rc;
|
||||
|
|
Loading…
Reference in New Issue