Skip to content

Commit

Permalink
fix conditional compilation for net 5.0+ (kubernetes-client#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiweiv authored Apr 19, 2022
1 parent 199ec8b commit abebb2c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/KubernetesClient/Authentication/TokenFileAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public TokenFileAuth(string tokenFile)
TokenFile = tokenFile;
}

#if NETSTANDARD2_1_OR_GREATER
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
public async Task<AuthenticationHeaderValue> GetAuthenticationHeaderAsync(CancellationToken cancellationToken)
#else
public Task<AuthenticationHeaderValue> GetAuthenticationHeaderAsync(CancellationToken cancellationToken)
#endif
{
if (TokenExpiresAt < DateTime.UtcNow)
{
#if NETSTANDARD2_1_OR_GREATER
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
token = await File.ReadAllTextAsync(TokenFile, cancellationToken)
.ContinueWith(r => r.Result.Trim(), cancellationToken)
.ConfigureAwait(false);
Expand All @@ -40,7 +40,7 @@ public Task<AuthenticationHeaderValue> GetAuthenticationHeaderAsync(Cancellation
// < 10-8-1 minute.
TokenExpiresAt = DateTime.UtcNow.AddMinutes(1);
}
#if NETSTANDARD2_1_OR_GREATER
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
return new AuthenticationHeaderValue("Bearer", token);
#else
return Task.FromResult(new AuthenticationHeaderValue("Bearer", token));
Expand Down

0 comments on commit abebb2c

Please sign in to comment.