Skip to content

Commit

Permalink
Merge pull request #4564 from Otiel/feature/4556-add-environment-vari…
Browse files Browse the repository at this point in the history
…able-to-disable-updates-check

Add environment variable to disable updates check
  • Loading branch information
andrueastman authored Apr 30, 2024
2 parents e7569f4 + 913c95a commit e0bfc35
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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: 0 additions & 1 deletion src/kiota/Handlers/Plugin/GenerateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,5 @@ public override async Task<int> InvokeAsync(InvocationContext context)
#endif
}
}
throw new NotImplementedException();
}
}
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 e0bfc35

Please sign in to comment.