Sets up bot container recipe

This commit is contained in:
benbierens 2023-10-24 10:06:07 +02:00
parent b74349cc68
commit d4522f0d9c
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
4 changed files with 57 additions and 4 deletions

View File

@ -28,9 +28,18 @@ namespace CodexDiscordBotPlugin
{ {
} }
public RunningContainer Deploy() public RunningContainer Deploy(DiscordBotStartupConfig config)
{ {
throw new NotImplementedException(); var workflow = tools.CreateWorkflow();
var startupConfig = new StartupConfig();
startupConfig.NameOverride = config.Name;
startupConfig.Add(config);
var rc = workflow.Start(1, new DiscordBotContainerRecipe(), startupConfig);
// write deployment into endpoints folder.
return rc.Containers.Single();
} }
} }
} }

View File

@ -5,9 +5,9 @@ namespace CodexDiscordBotPlugin
{ {
public static class CoreInterfaceExtensions public static class CoreInterfaceExtensions
{ {
public static RunningContainer DeployMetricsCollector(this CoreInterface ci) public static RunningContainer DeployMetricsCollector(this CoreInterface ci, DiscordBotStartupConfig config)
{ {
return Plugin(ci).Deploy(); return Plugin(ci).Deploy(config);
} }
private static CodexDiscordBotPlugin Plugin(CoreInterface ci) private static CodexDiscordBotPlugin Plugin(CoreInterface ci)

View File

@ -0,0 +1,22 @@
using KubernetesWorkflow;
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";
protected override void Initialize(StartupConfig startupConfig)
{
var config = startupConfig.Get<DiscordBotStartupConfig>();
AddEnvVar("TOKEN", config.Token);
AddEnvVar("SERVERNAME", config.ServerName);
AddEnvVar("ADMINROLE", config.AdminRoleName);
AddEnvVar("ENDPOINTS", EndpointsPath);
}
}
}

View File

@ -0,0 +1,22 @@
using CodexPlugin;
namespace CodexDiscordBotPlugin
{
public class DiscordBotStartupConfig
{
public DiscordBotStartupConfig(string name, string token, string serverName, string adminRoleName, CodexDeployment codexDeployment)
{
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; }
}
}