public async Task <int> Execute() { try { KongConfiguration = await KongReader.GetConfiguration(); } catch (Exception e) when(e is KongException || e is HttpRequestException) { return(ExitWithCode.Return(ExitCode.HostUnreachable, e.Message)); } var versionSubStr = KongConfiguration.Version.Substring(0, 4); var version = double.Parse(versionSubStr[3] == '.' ? versionSubStr.Substring(0, 3) : versionSubStr); if (KongConfiguration.Version.Contains("enterprise-edition")) { const double lowestSupportedVersion = 0.36; if (version < lowestSupportedVersion) { return(ExitWithCode.Return(ExitCode.HostVersionNotSupported, $"This version of Kongverge can only support Kong enterprise from version {lowestSupportedVersion}-x")); } } else { const double lowestSupportedVersion = 1.4; if (version < lowestSupportedVersion) { return(ExitWithCode.Return(ExitCode.HostVersionNotSupported, $"This version of Kongverge can only support Kong from version {lowestSupportedVersion}.x")); } } return(await DoExecute()); }
public async Task <int> Execute() { var reachable = await KongReader.KongIsReachable(); if (!reachable) { return(ExitWithCode.Return(ExitCode.HostUnreachable)); } return(await DoExecute()); }
public async Task <int> Execute() { try { KongConfiguration = await KongReader.GetConfiguration(); } catch { return(ExitWithCode.Return(ExitCode.HostUnreachable)); } return(await DoExecute()); }
public async Task<int> Execute() { try { KongConfiguration = await KongReader.GetConfiguration(); } catch (Exception e) when (e is KongException || e is HttpRequestException) { return ExitWithCode.Return(ExitCode.HostUnreachable, e.Message); } return await DoExecute(); }
public override async Task <int> DoExecute() { _availablePlugins = KongConfiguration.Plugins.Available .Where(x => x.Value) .Select(x => x.Key) .ToDictionary(x => x, x => new AsyncLazy <KongPluginSchema>(() => KongReader.GetPluginSchema(x))); KongvergeConfiguration targetConfiguration; try { targetConfiguration = await _configReader.ReadConfiguration(_arguments.InputFolder, _availablePlugins); } catch (DirectoryNotFoundException ex) { return(ExitWithCode.Return(ExitCode.InputFolderUnreachable, ex.Message)); } catch (InvalidConfigurationFilesException ex) { return(ExitWithCode.Return(ExitCode.InvalidConfigurationFiles, ex.Message)); } var existingConfiguration = await _configBuilder.FromKong(KongReader); try { await ConvergeConfiguration(existingConfiguration, targetConfiguration); } catch (KongException e) when(e.StatusCode == HttpStatusCode.BadRequest) { Log.Error(e, $"Error converging target configuration: {e}"); Log.Information("Attempting rollback to previous configuration..."); var currentConfiguration = await _configBuilder.FromKong(KongReader); await ConvergeConfiguration(currentConfiguration, existingConfiguration); return(ExitWithCode.Return(ExitCode.UnspecifiedError, "An error occurred while attempting to converge target configuration. Rollback was successful.")); } return(ExitWithCode.Return(ExitCode.Success)); }