diff --git a/ProjectPlugins/CodexDiscordBotPlugin/CodexDiscordBotPlugin.cs b/ProjectPlugins/CodexDiscordBotPlugin/CodexDiscordBotPlugin.cs index 3ae596d..feed993 100644 --- a/ProjectPlugins/CodexDiscordBotPlugin/CodexDiscordBotPlugin.cs +++ b/ProjectPlugins/CodexDiscordBotPlugin/CodexDiscordBotPlugin.cs @@ -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(); } } } diff --git a/ProjectPlugins/CodexDiscordBotPlugin/CoreInterfaceExtensions.cs b/ProjectPlugins/CodexDiscordBotPlugin/CoreInterfaceExtensions.cs index 275e420..0600818 100644 --- a/ProjectPlugins/CodexDiscordBotPlugin/CoreInterfaceExtensions.cs +++ b/ProjectPlugins/CodexDiscordBotPlugin/CoreInterfaceExtensions.cs @@ -5,9 +5,9 @@ namespace CodexDiscordBotPlugin { 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) diff --git a/ProjectPlugins/CodexDiscordBotPlugin/DiscordBotContainerRecipe.cs b/ProjectPlugins/CodexDiscordBotPlugin/DiscordBotContainerRecipe.cs new file mode 100644 index 0000000..ea48b91 --- /dev/null +++ b/ProjectPlugins/CodexDiscordBotPlugin/DiscordBotContainerRecipe.cs @@ -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(); + + AddEnvVar("TOKEN", config.Token); + AddEnvVar("SERVERNAME", config.ServerName); + AddEnvVar("ADMINROLE", config.AdminRoleName); + + AddEnvVar("ENDPOINTS", EndpointsPath); + } + } +} diff --git a/ProjectPlugins/CodexDiscordBotPlugin/DiscordBotStartupConfig.cs b/ProjectPlugins/CodexDiscordBotPlugin/DiscordBotStartupConfig.cs new file mode 100644 index 0000000..d108388 --- /dev/null +++ b/ProjectPlugins/CodexDiscordBotPlugin/DiscordBotStartupConfig.cs @@ -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; } + } +}