Skip to content

Commit 44ad593

Browse files
committed
fix CA2007
1 parent 325fa2c commit 44ad593

File tree

20 files changed

+160
-160
lines changed

20 files changed

+160
-160
lines changed

examples/attach/Attach.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ private static async Task Main(string[] args)
1818

1919
var list = client.ListNamespacedPod("default");
2020
var pod = list.Items[0];
21-
await AttachToPod(client, pod);
21+
await AttachToPod(client, pod).ConfigureAwait(false);
2222
}
2323

2424
private async static Task AttachToPod(IKubernetes client, V1Pod pod)
2525
{
2626
var webSocket =
2727
await client.WebSocketNamespacedPodAttachAsync(pod.Metadata.Name, "default",
28-
pod.Spec.Containers[0].Name);
28+
pod.Spec.Containers[0].Name).ConfigureAwait(false);
2929

3030
var demux = new StreamDemuxer(webSocket);
3131
demux.Start();

examples/exec/Exec.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ private static async Task Main(string[] args)
1515

1616
var list = client.ListNamespacedPod("default");
1717
var pod = list.Items[0];
18-
await ExecInPod(client, pod);
18+
await ExecInPod(client, pod).ConfigureAwait(false);
1919
}
2020

2121
private async static Task ExecInPod(IKubernetes client, V1Pod pod)
2222
{
2323
var webSocket =
2424
await client.WebSocketNamespacedPodExecAsync(pod.Metadata.Name, "default", "ls",
25-
pod.Spec.Containers[0].Name);
25+
pod.Spec.Containers[0].Name).ConfigureAwait(false);
2626

2727
var demux = new StreamDemuxer(webSocket);
2828
demux.Start();

examples/httpClientFactory/PodListHostedService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public async Task StartAsync(CancellationToken cancellationToken)
2323
{
2424
_logger.LogInformation("Starting Request!");
2525

26-
var list = await _kubernetesClient.ListNamespacedPodAsync("default", cancellationToken: cancellationToken);
26+
var list = await _kubernetesClient.ListNamespacedPodAsync("default", cancellationToken: cancellationToken).ConfigureAwait(false);
2727
foreach (var item in list.Items)
2828
{
2929
_logger.LogInformation(item.Metadata.Name);

examples/logs/Logs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private static async Task Main(string[] args)
2323
var pod = list.Items[0];
2424

2525
var response = await client.ReadNamespacedPodLogWithHttpMessagesAsync(pod.Metadata.Name,
26-
pod.Metadata.NamespaceProperty, follow: true);
26+
pod.Metadata.NamespaceProperty, follow: true).ConfigureAwait(false);
2727
var stream = response.Body;
2828
stream.CopyTo(Console.OpenStandardOutput());
2929
}

examples/namespace/Namespace.cs renamed to examples/namespace/NamespaceExample.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ private static async Task DeleteAsync(IKubernetes client, string name, int delay
2626
{
2727
while (true)
2828
{
29-
await Task.Delay(delayMillis);
29+
await Task.Delay(delayMillis).ConfigureAwait(false);
3030
try
3131
{
32-
await client.ReadNamespaceAsync(name);
32+
await client.ReadNamespaceAsync(name).ConfigureAwait(false);
3333
}
3434
catch (AggregateException ex)
3535
{

gen/KubernetesWatchGenerator/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private static async Task Main(string[] args)
3131

3232
// Read the spec trimmed
3333
// here we cache all name in gen project for later use
34-
var swagger = await SwaggerDocument.FromFileAsync(Path.Combine(args[1], "swagger.json"));
34+
var swagger = await SwaggerDocument.FromFileAsync(Path.Combine(args[1], "swagger.json")).ConfigureAwait(false);
3535
foreach (var (k, v) in swagger.Definitions)
3636
{
3737
if (v.ExtensionData?.TryGetValue("x-kubernetes-group-version-kind", out var _) == true)
@@ -47,7 +47,7 @@ private static async Task Main(string[] args)
4747
}
4848

4949
// gen project removed all watch operations, so here we switch back to unprocessed version
50-
swagger = await SwaggerDocument.FromFileAsync(Path.Combine(args[1], "swagger.json.unprocessed"));
50+
swagger = await SwaggerDocument.FromFileAsync(Path.Combine(args[1], "swagger.json.unprocessed")).ConfigureAwait(false);
5151
_schemaToNameMap = swagger.Definitions.ToDictionary(x => x.Value, x => x.Key);
5252
_schemaDefinitionsInMultipleGroups = _schemaToNameMap.Values.Select(x =>
5353
{

src/KubernetesClient/Authentication/GcpTokenProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public async Task<AuthenticationHeaderValue> GetAuthenticationHeaderAsync(Cancel
2424
{
2525
if (DateTime.UtcNow.AddSeconds(30) > _expiry)
2626
{
27-
await RefreshToken();
27+
await RefreshToken().ConfigureAwait(false);
2828
}
2929

3030
return new AuthenticationHeaderValue("Bearer", _token);
@@ -54,14 +54,14 @@ private async Task RefreshToken()
5454
var output = process.StandardOutput.ReadToEndAsync();
5555
var err = process.StandardError.ReadToEndAsync();
5656

57-
await Task.WhenAll(tcs.Task, output, err);
57+
await Task.WhenAll(tcs.Task, output, err).ConfigureAwait(false);
5858

5959
if (process.ExitCode != 0)
6060
{
6161
throw new KubernetesClientException($"Unable to obtain a token via gcloud command. Error code {process.ExitCode}. \n {err}");
6262
}
6363

64-
var json = JToken.Parse(await output);
64+
var json = JToken.Parse(await output.ConfigureAwait(false));
6565
_token = json["credential"]["access_token"].Value<string>();
6666
_expiry = json["credential"]["token_expiry"].Value<DateTime>();
6767
}

src/KubernetesClient/StreamDemuxer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public StreamDemuxer(WebSocket webSocket, StreamType streamType = StreamType.Rem
5858
/// </summary>
5959
public void Start()
6060
{
61-
this.runLoop = Task.Run(async () => await this.RunLoop(this.cts.Token));
61+
this.runLoop = Task.Run(async () => await RunLoop(cts.Token).ConfigureAwait(false));
6262
}
6363

6464
/// <inheritdoc/>

src/KubernetesClient/Watcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public Watcher(Func<Task<TextReader>> streamReaderCreator, Action<WatchEventType
9393
OnClosed += onClosed;
9494

9595
_cts = new CancellationTokenSource();
96-
_watcherLoop = Task.Run(async () => await this.WatcherLoop(_cts.Token));
96+
_watcherLoop = Task.Run(async () => await WatcherLoop(_cts.Token).ConfigureAwait(false));
9797
}
9898

9999
/// <inheritdoc/>

tests/KubernetesClient.Tests/ByteBufferTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,15 @@ public async Task ReadBlocksUntilDataAvailableTest()
256256

257257
// Kick off a read operation
258258
var readTask = Task.Run(() => read = buffer.Read(readData, 0, readData.Length));
259-
await Task.Delay(250);
259+
await Task.Delay(250).ConfigureAwait(false);
260260
Assert.False(readTask.IsCompleted, "Read task completed before data was available.");
261261

262262
// Write data to the buffer
263263
buffer.Write(this.writeData, 0, 0x03);
264264

265265
await TaskAssert.Completed(readTask,
266266
timeout: TimeSpan.FromMilliseconds(1000),
267-
message: "Timed out waiting for read task to complete.");
267+
message: "Timed out waiting for read task to complete.").ConfigureAwait(false);
268268

269269
Assert.Equal(3, read);
270270
Assert.Equal(0xF0, readData[0]);
@@ -411,10 +411,10 @@ public async Task ReadFirstTest()
411411
byte[] output = new byte[buffer.Size + 1];
412412

413413
var readTask = Task.Run(() => buffer.Read(output, 0, output.Length));
414-
await Task.Delay(TimeSpan.FromSeconds(1));
414+
await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
415415

416416
buffer.Write(data, 0, data.Length);
417-
await readTask;
417+
await readTask.ConfigureAwait(false);
418418
}
419419

420420
#if NETCOREAPP2_0
@@ -437,12 +437,12 @@ var generatorTask
437437
var consumerTask
438438
= Task.Run(() => this.Consume(buffer, SHA256.Create()));
439439

440-
await Task.WhenAll(generatorTask, consumerTask);
440+
await Task.WhenAll(generatorTask, consumerTask).ConfigureAwait(false);
441441

442442
var generatorHash
443-
= await generatorTask;
443+
= await generatorTask.ConfigureAwait(false);
444444
var consumerHash
445-
= await consumerTask;
445+
= await consumerTask.ConfigureAwait(false);
446446

447447
Assert.Equal(generatorHash, consumerHash);
448448
}

tests/KubernetesClient.Tests/GcpTokenProviderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public async Task GetToken()
2121
}
2222

2323
var sut = new GcpTokenProvider(cmd);
24-
var result = await sut.GetAuthenticationHeaderAsync(CancellationToken.None);
24+
var result = await sut.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(false);
2525
result.Scheme.Should().Be("Bearer");
2626
result.Parameter.Should().Be("ACCESS-TOKEN");
2727
}

tests/KubernetesClient.Tests/Kubernetes.Exec.Tests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public async Task Exec_DefaultContainer_StdOut()
5151
TimeSpan.FromSeconds(5));
5252
}
5353

54-
await Host.StartAsync(TestCancellation);
54+
await Host.StartAsync(TestCancellation).ConfigureAwait(false);
5555

5656
using (Kubernetes client = CreateTestClient())
5757
{
@@ -66,7 +66,7 @@ public async Task Exec_DefaultContainer_StdOut()
6666
stdin: false,
6767
stdout: true,
6868
webSocketSubProtol: WebSocketProtocol.ChannelWebSocketProtocol,
69-
cancellationToken: TestCancellation);
69+
cancellationToken: TestCancellation).ConfigureAwait(false);
7070
Assert.Equal(WebSocketProtocol.ChannelWebSocketProtocol,
7171
clientSocket
7272
.SubProtocol); // For WebSockets, the Kubernetes API defaults to the binary channel (v1) protocol.
@@ -81,10 +81,10 @@ public async Task Exec_DefaultContainer_StdOut()
8181
const int STDOUT = 1;
8282
const string expectedOutput = "This is text send to STDOUT.";
8383

84-
int bytesSent = await SendMultiplexed(serverSocket, STDOUT, expectedOutput);
84+
int bytesSent = await SendMultiplexed(serverSocket, STDOUT, expectedOutput).ConfigureAwait(false);
8585
testOutput.WriteLine($"Sent {bytesSent} bytes to server socket; receiving from client socket...");
8686

87-
(string receivedText, byte streamIndex, int bytesReceived) = await ReceiveTextMultiplexed(clientSocket);
87+
(string receivedText, byte streamIndex, int bytesReceived) = await ReceiveTextMultiplexed(clientSocket).ConfigureAwait(false);
8888
testOutput.WriteLine(
8989
$"Received {bytesReceived} bytes from client socket ('{receivedText}', stream {streamIndex}).");
9090

@@ -93,7 +93,7 @@ public async Task Exec_DefaultContainer_StdOut()
9393

9494
await Disconnect(clientSocket, serverSocket,
9595
closeStatus: WebSocketCloseStatus.NormalClosure,
96-
closeStatusDescription: "Normal Closure");
96+
closeStatusDescription: "Normal Closure").ConfigureAwait(false);
9797

9898
WebSocketTestAdapter.CompleteTest();
9999
}

tests/KubernetesClient.Tests/Mock/MockKubeApiServer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public MockKubeApiServer(ITestOutputHelper testOutput, Func<HttpContext, Task<bo
3232
_webHost = WebHost.CreateDefaultBuilder()
3333
.Configure(app => app.Run(async httpContext =>
3434
{
35-
if (await shouldNext(httpContext))
35+
if (await shouldNext(httpContext).ConfigureAwait(false))
3636
{
37-
await httpContext.Response.WriteAsync(resp);
37+
await httpContext.Response.WriteAsync(resp).ConfigureAwait(false);
3838
}
3939
}))
4040
.UseKestrel(options => { options.Listen(IPAddress.Loopback, 0, listenConfigure); })

tests/KubernetesClient.Tests/Mock/Server/Controllers/PodExecController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ public async Task<IActionResult> Exec(string kubeNamespace, string podName)
5252
}
5353

5454
WebSocket webSocket = await HttpContext.WebSockets.AcceptWebSocketAsync(
55-
subProtocol: WebSocketProtocol.ChannelWebSocketProtocol);
55+
subProtocol: WebSocketProtocol.ChannelWebSocketProtocol).ConfigureAwait(false);
5656

5757
WebSocketTestAdapter.AcceptedPodExecV1Connection.AcceptServerSocket(webSocket);
5858

59-
await WebSocketTestAdapter.TestCompleted;
59+
await WebSocketTestAdapter.TestCompleted.ConfigureAwait(false);
6060

6161
return Ok();
6262
}

tests/KubernetesClient.Tests/Mock/Server/Controllers/PodPortForwardController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ public async Task<IActionResult> Exec(string kubeNamespace, string podName, IEnu
5656
}
5757

5858
WebSocket webSocket = await HttpContext.WebSockets.AcceptWebSocketAsync(
59-
subProtocol: WebSocketProtocol.ChannelWebSocketProtocol);
59+
subProtocol: WebSocketProtocol.ChannelWebSocketProtocol).ConfigureAwait(false);
6060

6161
WebSocketTestAdapter.AcceptedPodPortForwardV1Connection.AcceptServerSocket(webSocket);
6262

63-
await WebSocketTestAdapter.TestCompleted;
63+
await WebSocketTestAdapter.TestCompleted.ConfigureAwait(false);
6464

6565
return Ok();
6666
}

0 commit comments

Comments
 (0)