Skip to content

Commit

Permalink
Skip updates check when KIOTA_OFFLINE_ENABLED environment variable is…
Browse files Browse the repository at this point in the history
… set to true
  • Loading branch information
Otiel committed Apr 27, 2024
1 parent 142f88c commit 45ea7ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/kiota/Handlers/BaseKiotaCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions src/kiota/KiotaConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 45ea7ae

Please sign in to comment.