From 258f32ea891c8e45c24fd09063bd12b937205a64 Mon Sep 17 00:00:00 2001 From: Otiel Date: Sat, 27 Apr 2024 23:33:21 +0200 Subject: [PATCH 1/3] Cleanup: remove unreachable code --- src/kiota/Handlers/Plugin/GenerateHandler.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/kiota/Handlers/Plugin/GenerateHandler.cs b/src/kiota/Handlers/Plugin/GenerateHandler.cs index db85404d61..8201897d32 100644 --- a/src/kiota/Handlers/Plugin/GenerateHandler.cs +++ b/src/kiota/Handlers/Plugin/GenerateHandler.cs @@ -84,6 +84,5 @@ public override async Task InvokeAsync(InvocationContext context) #endif } } - throw new NotImplementedException(); } } From dbd479b720c228caaf5a8aee664f3bea7a70342d Mon Sep 17 00:00:00 2001 From: Otiel Date: Sat, 27 Apr 2024 23:34:30 +0200 Subject: [PATCH 2/3] Skip updates check when KIOTA_OFFLINE_ENABLED environment variable is set to true --- src/kiota/Handlers/BaseKiotaCommandHandler.cs | 5 +++++ src/kiota/KiotaConfigurationExtensions.cs | 1 + 2 files changed, 6 insertions(+) diff --git a/src/kiota/Handlers/BaseKiotaCommandHandler.cs b/src/kiota/Handlers/BaseKiotaCommandHandler.cs index 11db4586b1..2646ccc4e3 100644 --- a/src/kiota/Handlers/BaseKiotaCommandHandler.cs +++ b/src/kiota/Handlers/BaseKiotaCommandHandler.cs @@ -97,6 +97,11 @@ public int Invoke(InvocationContext context) } protected async Task CheckForNewVersionAsync(ILogger logger, CancellationToken cancellationToken) { + if (Configuration.Update.Disabled) + { + return; + } + var updateService = new UpdateService(httpClient, logger, Configuration.Update); var result = await updateService.GetUpdateMessageAsync(Kiota.Generated.KiotaVersion.Current(), cancellationToken).ConfigureAwait(false); if (!string.IsNullOrEmpty(result)) diff --git a/src/kiota/KiotaConfigurationExtensions.cs b/src/kiota/KiotaConfigurationExtensions.cs index d9704e485f..f0c6b89f44 100644 --- a/src/kiota/KiotaConfigurationExtensions.cs +++ b/src/kiota/KiotaConfigurationExtensions.cs @@ -17,6 +17,7 @@ public static void BindConfiguration(this KiotaConfiguration configObject, IConf { ArgumentNullException.ThrowIfNull(configObject); ArgumentNullException.ThrowIfNull(configuration); + configObject.Update.Disabled = bool.TryParse(configuration["OFFLINE_ENABLED"], out var disableUpdate) && disableUpdate; configObject.Download.CleanOutput = bool.TryParse(configuration[$"{nameof(configObject.Download)}:{nameof(DownloadConfiguration.CleanOutput)}"], out var downloadCleanOutput) && downloadCleanOutput; configObject.Download.ClearCache = bool.TryParse(configuration[$"{nameof(configObject.Download)}:{nameof(DownloadConfiguration.ClearCache)}"], out var downloadClearCache) && downloadClearCache; configObject.Download.OutputPath = configuration[$"{nameof(configObject.Download)}:{nameof(DownloadConfiguration.OutputPath)}"] is string value && !string.IsNullOrEmpty(value) ? value : configObject.Download.OutputPath; From 913c95a1c9eb46698e29ae69b818de473ea97ed5 Mon Sep 17 00:00:00 2001 From: Otiel Date: Mon, 29 Apr 2024 22:25:22 +0200 Subject: [PATCH 3/3] CHANGELOG: add entry for KIOTA_OFFLINE_ENABLED environment variable support --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8d8c116a9..e181101aeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Suppress CS1591 when generating CSharp code and documentation is not available - Added file name suffix escaping in Go to avoid generating files with reserved suffixes. [#4407](https://github.com/microsoft/kiota/issues/4407) +- Added `KIOTA_OFFLINE_ENABLED` environment variable to disable checking for updates before each command. [#4556](https://github.com/microsoft/kiota/issues/4556) ### Changed