cs-codex-dist-tests/ProjectPlugins/CodexDiscordBotPlugin/CodexDiscordBotPlugin.cs

47 lines
1.3 KiB
C#
Raw Normal View History

2023-10-24 07:51:29 +00:00
using Core;
using KubernetesWorkflow;
namespace CodexDiscordBotPlugin
{
public class CodexDiscordBotPlugin : IProjectPlugin, IHasLogPrefix, IHasMetadata
{
private readonly IPluginTools tools;
public CodexDiscordBotPlugin(IPluginTools tools)
{
this.tools = tools;
}
public string LogPrefix => "(DiscordBot) ";
public void Announce()
{
tools.GetLog().Log($"Codex DiscordBot (BiblioTech) loaded.");
}
public void AddMetadata(IAddMetadata metadata)
{
metadata.Add("codexdiscordbotid", new DiscordBotContainerRecipe().Image);
2023-10-24 07:51:29 +00:00
}
public void Decommission()
{
}
2023-10-24 08:06:07 +00:00
public RunningContainer Deploy(DiscordBotStartupConfig config)
2023-10-24 07:51:29 +00:00
{
2023-10-24 08:06:07 +00:00
var workflow = tools.CreateWorkflow();
return StartContainer(workflow, config);
}
private RunningContainer StartContainer(IStartupWorkflow workflow, DiscordBotStartupConfig config)
{
2023-10-24 08:06:07 +00:00
var startupConfig = new StartupConfig();
startupConfig.NameOverride = config.Name;
startupConfig.Add(config);
var rc = workflow.Start(1, new DiscordBotContainerRecipe(), startupConfig);
return rc.Containers.Single();
}
2023-10-24 07:51:29 +00:00
}
}