diff --git a/CRCTray.cs b/CRCTray.cs index c870e25..2e925a6 100755 --- a/CRCTray.cs +++ b/CRCTray.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Threading.Tasks; using System.Collections.Generic; +using System.IO; using CRCTray.Communication; using CRCTray.Helpers; @@ -228,19 +229,12 @@ await TaskHelpers.TryTaskAndNotify(TaskHandlers.Stop, async private void StartMenu_Click(object sender, EventArgs e) { // Check using get-config if pullSecret is configured - var configs = await TaskHelpers.TryTaskAndNotify(TaskHandlers.ConfigView, + var pullsecret = await TaskHelpers.TryTaskAndNotify(TaskHandlers.GetPullSecret, String.Empty, String.Empty, String.Empty); - if(configs == null) - { - // no config was returned, does this mean a communication error? - TrayIcon.NotifyError("Unable to read configuration. Is the CRC daemon running?"); - return; - } - - if (configs != null && configs.Configs.PullSecretFile == String.Empty) + if (!pullsecret) { var pullSecretForm = new PullSecretPickerForm(); var pullSecretPath = pullSecretForm.ShowFilePicker(); @@ -254,13 +248,13 @@ async private void StartMenu_Click(object sender, EventArgs e) ["pull-secret-file"] = pullSecretPath }; - await TaskHelpers.TryTaskAndNotify(TaskHandlers.SetConfig, pullSecretConfig, + string data = File.ReadAllText(pullSecretPath); + await TaskHelpers.TryTaskAndNotify(TaskHandlers.SetPullSecret, data, "Pull Secret stored", "Pull Secret not stored", String.Empty); } - TrayIcon.NotifyInfo(@"Starting Cluster"); var startResult = await TaskHelpers.TryTaskAndNotify(TaskHandlers.Start, diff --git a/Communication/DaemonCommander.cs b/Communication/DaemonCommander.cs index 86d4ef4..3fb8496 100755 --- a/Communication/DaemonCommander.cs +++ b/Communication/DaemonCommander.cs @@ -81,6 +81,17 @@ public static LogsResult GetLogs() return getResultsForBasicCommand(BasicCommands.Logs); } + public static bool GetPullSecret() + { + return getResultsForBasicCommand(BasicCommands.PullSecret); + } + + public static bool SetPullSecret(string data) + { + var result = postResponse(BasicCommands.PullSecret, data, 30); + return true; + } + private static string SendBasicCommand(string command, int timeout) { return getResponse(command, timeout).Result; diff --git a/Communication/Enums.cs b/Communication/Enums.cs index 2e9f967..2c6e163 100755 --- a/Communication/Enums.cs +++ b/Communication/Enums.cs @@ -14,5 +14,7 @@ static class BasicCommands internal const string ConfigSet = "config/set"; internal const string ConfigUnset = "config/unset"; internal const string Logs = "logs"; + + internal const string PullSecret = "pull-secret"; } } \ No newline at end of file diff --git a/Helpers/Handlers.cs b/Helpers/Handlers.cs index 9980512..30f70fa 100755 --- a/Helpers/Handlers.cs +++ b/Helpers/Handlers.cs @@ -126,6 +126,16 @@ public static SetUnsetConfig UnsetConfig(List cfg) return getTypedResults(DaemonCommander.UnsetConfig, config); } + public static bool GetPullSecret() + { + return getTypedResults(DaemonCommander.GetPullSecret); + } + + public static bool SetPullSecret(string data) + { + return getTypedResults(DaemonCommander.SetPullSecret, data); + } + public static ConsoleResult LoginForDeveloper() { return WebConsole();