Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Docker.DotNet/DockerPipeStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public override void CloseWrite()
const int ERROR_IO_PENDING = 997;
if (Marshal.GetLastWin32Error() == ERROR_IO_PENDING)
{
int written;
if (GetOverlappedResult(_stream.SafePipeHandle, ref overlapped, out written, 1) == 0)
if (GetOverlappedResult(_stream.SafePipeHandle, ref overlapped, out var _, 1) == 0)
{
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Docker.DotNet/Endpoints/IImageOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public interface IImageOperations
/// <exception cref="ArgumentNullException">One or more of the inputs was <see langword="null"/>.</exception>
/// <exception cref="DockerApiException">The input is invalid or the daemon experienced an error.</exception>
/// <exception cref="HttpRequestException">The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.</exception>
[ObsoleteAttribute("This method does not wait for build to complete. Use new BuildImageFromDockerfileAsync(contents, parameters, authConfigs, headers, progress, cancellationToken, instead.)", false)]
[Obsolete("This method does not wait for build to complete. Use new BuildImageFromDockerfileAsync(contents, parameters, authConfigs, headers, progress, cancellationToken, instead.)", false)]
Task<Stream> BuildImageFromDockerfileAsync(Stream contents, ImageBuildParameters parameters, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Docker.DotNet/Endpoints/IVolumeOperations.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Docker.DotNet.Models;
using System.Threading;
Expand Down
3 changes: 1 addition & 2 deletions src/Docker.DotNet/Endpoints/StreamUtil.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Text;
Expand Down Expand Up @@ -48,7 +47,7 @@ internal static async Task MonitorResponseForMessagesAsync<T>(Task<HttpResponseM
{
using (var response = await responseTask)
{
await MonitorStreamForMessagesAsync<T>(response.Content.ReadAsStreamAsync(), client, cancel, progress);
await MonitorStreamForMessagesAsync(response.Content.ReadAsStreamAsync(), client, cancel, progress);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Docker.DotNet/Endpoints/VolumeOperations.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Docker.DotNet.Models;
using System;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
Expand Down
4 changes: 2 additions & 2 deletions src/Docker.DotNet/Microsoft.Net.Http.Client/HttpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private string SerializeRequest(HttpRequestMessage request)
builder.Append(request.Version.ToString(2));
builder.Append("\r\n");

builder.Append(request.Headers.ToString());
builder.Append(request.Headers);

if (request.Content != null)
{
Expand All @@ -79,7 +79,7 @@ private string SerializeRequest(HttpRequestMessage request)
request.Content.Headers.ContentLength = contentLength.Value;
}

builder.Append(request.Content.Headers.ToString());
builder.Append(request.Content.Headers);
if (!contentLength.HasValue)
{
// Add header for chunked mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ private async Task TunnelThroughProxyAsync(HttpRequestMessage request, Stream tr
if ((int)connectResponse.StatusCode < 200 || 300 <= (int)connectResponse.StatusCode)
{
transport.Dispose();
throw new HttpRequestException("Failed to negotiate the proxy tunnel: " + connectResponse.ToString());
throw new HttpRequestException("Failed to negotiate the proxy tunnel: " + connectResponse);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ public class ContainerPathStatParameters // (main.ContainerPathStatParameters)
{
[QueryStringParameter("path", true)]
public string Path { get; set; }

[QueryStringParameter("noOverwriteDirNonDir", false, typeof(BoolQueryStringConverter))]
public bool? AllowOverwriteDirWithFile { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ public class ContainerRestartParameters // (main.ContainerRestartParameters)
{
[QueryStringParameter("t", false)]
public uint? WaitBeforeKillSeconds { get; set; }

[QueryStringParameter("signal", false)]
public string Signal { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Docker.DotNet/Models/ContainerStopParameters.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ public class ContainerStopParameters // (main.ContainerStopParameters)
{
[QueryStringParameter("t", false)]
public uint? WaitBeforeKillSeconds { get; set; }

[QueryStringParameter("signal", false)]
public string Signal { get; set; }
}
}
19 changes: 9 additions & 10 deletions src/Docker.DotNet/Models/EmptyStruct.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

namespace Docker.DotNet.Models
{
/// <summary>
/// In go something like map[string]struct{} has no correct match so we create
/// the empty type here that can be used for something like IDictionary<string, EmptyStruct>;
/// </summary>
public struct EmptyStruct
{
}
namespace Docker.DotNet.Models
{
/// <summary>
/// In go something like map[string]struct{} has no correct match so we create the
/// empty type here that can be used for something like IDictionary&lt;string, EmptyStruct&gt;.
/// </summary>
public struct EmptyStruct
{
}
}
11 changes: 0 additions & 11 deletions src/Docker.DotNet/Models/ImageInspectParameters.Generated.cs

This file was deleted.

3 changes: 0 additions & 3 deletions src/Docker.DotNet/Models/ImagePushParameters.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ namespace Docker.DotNet.Models
[DataContract]
public class ImagePushParameters // (main.ImagePushParameters)
{
[QueryStringParameter("fromImage", false)]
public string ImageID { get; set; }

[QueryStringParameter("tag", false)]
public string Tag { get; set; }

Expand Down
3 changes: 0 additions & 3 deletions src/Docker.DotNet/Models/ImageTagParameters.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@ public class ImageTagParameters // (main.ImageTagParameters)

[QueryStringParameter("tag", false)]
public string Tag { get; set; }

[QueryStringParameter("force", false, typeof(BoolQueryStringConverter))]
public bool? Force { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Docker.DotNet/Models/ImagesListParameters.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ public class ImagesListParameters // (main.ImagesListParameters)

[QueryStringParameter("digests", false, typeof(BoolQueryStringConverter))]
public bool? Digests { get; set; }

[QueryStringParameter("shared-size", false, typeof(BoolQueryStringConverter))]
public bool? SharedSize { get; set; }
}
}
3 changes: 1 addition & 2 deletions src/Docker.DotNet/Models/ObjectExtensionData.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace Docker.DotNet.Models
{
public class ObjectExtensionData
{
[JsonExtensionDataAttribute]
[JsonExtensionData]
public IDictionary<string, object> ExtensionData { get; set; }
}
}
1 change: 0 additions & 1 deletion src/Docker.DotNet/MultiplexedStream.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Net.Http.Client;
Expand Down
4 changes: 2 additions & 2 deletions src/Docker.DotNet/TimeSpanNanoSecondsConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
{
return null;
}
var miliSecondValue = valueInNanoSeconds.Value / MiliSecondToNanoSecond;
var milliSecondValue = valueInNanoSeconds.Value / MiliSecondToNanoSecond;

return TimeSpan.FromMilliseconds((long)miliSecondValue);
return TimeSpan.FromMilliseconds(milliSecondValue);
}
}
}
1 change: 0 additions & 1 deletion src/Docker.DotNet/TimeSpanSecondsConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Docker.DotNet
{
Expand Down
13 changes: 4 additions & 9 deletions test/Docker.DotNet.Tests/IConfigOperationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ namespace Docker.DotNet.Tests
[Collection(nameof(TestCollection))]
public class IConfigOperationsTests
{
private readonly DockerClientConfiguration _dockerClientConfiguration;
private readonly DockerClient _dockerClient;
private readonly TestOutput _output;

public IConfigOperationsTests(TestFixture testFixture, ITestOutputHelper outputHelper)
{
_dockerClientConfiguration = testFixture.DockerClientConfiguration;
_dockerClient = _dockerClientConfiguration.CreateClient();
_dockerClient = testFixture.DockerClient;
_output = new TestOutput(outputHelper);
}

Expand All @@ -25,7 +24,7 @@ public async void SwarmConfig_CanCreateAndRead()
var currentConfigs = await _dockerClient.Configs.ListConfigsAsync();

_output.WriteLine($"Current Configs: {currentConfigs.Count}");

var testConfigSpec = new SwarmConfigSpec
{
Name = $"Config-{Guid.NewGuid().ToString().Substring(1, 10)}",
Expand Down Expand Up @@ -59,12 +58,8 @@ public async void SwarmConfig_CanCreateAndRead()
_output.WriteLine($"Config created is the same.");

await _dockerClient.Configs.RemoveConfigAsync(createdConfig.ID);

await Assert.ThrowsAsync<Docker.DotNet.DockerApiException>(() => _dockerClient.Configs.InspectConfigAsync(createdConfig.ID));



await Assert.ThrowsAsync<Docker.DotNet.DockerApiException>(() => _dockerClient.Configs.InspectConfigAsync(createdConfig.ID));
}
}
}

4 changes: 2 additions & 2 deletions test/Docker.DotNet.Tests/IContainerOperationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ public async Task WaitContainerAsync_TokenIsCancelled_OperationCancelledExceptio

_output.WriteLine($"CreateContainerResponse: '{JsonConvert.SerializeObject(createContainerResponse)}'");

var startContainerResult = await _dockerClient.Containers.StartContainerAsync(createContainerResponse.ID, new ContainerStartParameters(), waitContainerCts.Token);
_ = await _dockerClient.Containers.StartContainerAsync(createContainerResponse.ID, new ContainerStartParameters(), waitContainerCts.Token);

_output.WriteLine("Starting timeout to cancel WaitContainer operation.");

Expand All @@ -744,7 +744,7 @@ public async Task WaitContainerAsync_TokenIsCancelled_OperationCancelledExceptio
// Will wait forever here if cancelation fails.
var waitContainerTask = _dockerClient.Containers.WaitContainerAsync(createContainerResponse.ID, waitContainerCts.Token);

var exception = await Assert.ThrowsAsync<TaskCanceledException>(() => waitContainerTask);
_ = await Assert.ThrowsAsync<TaskCanceledException>(() => waitContainerTask);

stopWatch.Stop();

Expand Down
1 change: 0 additions & 1 deletion test/Docker.DotNet.Tests/IImageOperationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ await _dockerClient.Images.TagImageAsync(
{
RepositoryName = newRepositoryName,
Tag = newTag,
Force = true
},
cts.Token
);
Expand Down
24 changes: 12 additions & 12 deletions test/Docker.DotNet.Tests/ISwarmOperationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task GetFilteredServicesByName_Succeeds()
{
Filters = new ServiceFilter
{
Name = new string[]
Name = new[]
{
firstServiceName
}
Expand All @@ -74,9 +74,9 @@ public async Task GetFilteredServicesByName_Succeeds()

Assert.Single(services);

await _dockerClient.Swarm.RemoveServiceAsync(firstServiceId, default);
await _dockerClient.Swarm.RemoveServiceAsync(secondServiceId, default);
await _dockerClient.Swarm.RemoveServiceAsync(thirdServiceid, default);
await _dockerClient.Swarm.RemoveServiceAsync(firstServiceId);
await _dockerClient.Swarm.RemoveServiceAsync(secondServiceId);
await _dockerClient.Swarm.RemoveServiceAsync(thirdServiceid);
}

[Fact]
Expand Down Expand Up @@ -109,12 +109,12 @@ public async Task GetFilteredServicesById_Succeeds()
}
}).Result.ID;

var services = await _dockerClient.Swarm.ListServicesAsync(new ServicesListParameters { Filters = new ServiceFilter { Id = new string[] { firstServiceId } } }, CancellationToken.None);
var services = await _dockerClient.Swarm.ListServicesAsync(new ServicesListParameters { Filters = new ServiceFilter { Id = new[] { firstServiceId } } }, CancellationToken.None);
Assert.Single(services);

await _dockerClient.Swarm.RemoveServiceAsync(firstServiceId, default);
await _dockerClient.Swarm.RemoveServiceAsync(secondServiceId, default);
await _dockerClient.Swarm.RemoveServiceAsync(thirdServiceid, default);
await _dockerClient.Swarm.RemoveServiceAsync(firstServiceId);
await _dockerClient.Swarm.RemoveServiceAsync(secondServiceId);
await _dockerClient.Swarm.RemoveServiceAsync(thirdServiceid);
}

[Fact]
Expand Down Expand Up @@ -153,9 +153,9 @@ public async Task GetServices_Succeeds()

Assert.True(services.Count() > initialServiceCount);

await _dockerClient.Swarm.RemoveServiceAsync(firstServiceId, default);
await _dockerClient.Swarm.RemoveServiceAsync(secondServiceId, default);
await _dockerClient.Swarm.RemoveServiceAsync(thirdServiceid, default);
await _dockerClient.Swarm.RemoveServiceAsync(firstServiceId);
await _dockerClient.Swarm.RemoveServiceAsync(secondServiceId);
await _dockerClient.Swarm.RemoveServiceAsync(thirdServiceid);
}

[Fact]
Expand Down Expand Up @@ -253,7 +253,7 @@ public async Task GetServiceLogs_Succeeds()
Assert.True(logLines.Any());
Assert.Contains("[INF]", logLines.First());

await _dockerClient.Swarm.RemoveServiceAsync(serviceId, default);
await _dockerClient.Swarm.RemoveServiceAsync(serviceId);
}
}
}
8 changes: 2 additions & 6 deletions test/Docker.DotNet.Tests/ISystemOperations.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Docker.DotNet.Models;
Expand Down Expand Up @@ -40,7 +39,7 @@ public ISystemOperationsTests(TestFixture testFixture, ITestOutputHelper outputH
[Fact]
public void Docker_IsRunning()
{
var dockerProcess = Process.GetProcesses().FirstOrDefault(_ => _.ProcessName.Equals("docker", StringComparison.InvariantCultureIgnoreCase) || _.ProcessName.Equals("dockerd", StringComparison.InvariantCultureIgnoreCase));
var dockerProcess = Process.GetProcesses().FirstOrDefault(process => process.ProcessName.Equals("docker", StringComparison.InvariantCultureIgnoreCase) || process.ProcessName.Equals("dockerd", StringComparison.InvariantCultureIgnoreCase));
Assert.NotNull(dockerProcess); // docker is not running
}

Expand Down Expand Up @@ -154,9 +153,7 @@ public async Task MonitorEventsAsync_IsCancelled_NoStreamCorruption()
{
RepositoryName = _repositoryName,
Tag = newImageTag,
Force = true
},
default);
});

// (4) Wait for a short bit again and cancel the monitor task - if we get lucky, we the list images call will grab the same buffer while
sw.Restart();
Expand All @@ -178,7 +175,6 @@ public async Task MonitorEventsAsync_IsCancelled_NoStreamCorruption()
{
RepositoryName = _repositoryName,
Tag = newImageTag,
Force = true
}
).GetAwaiter().GetResult();

Expand Down
3 changes: 1 addition & 2 deletions test/Docker.DotNet.Tests/IVolumeOperationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Threading;
using System.Threading.Tasks;
using Docker.DotNet.Models;
using Newtonsoft.Json;
using Xunit;
using Xunit.Abstractions;

Expand All @@ -17,7 +16,7 @@ public class IVolumeOperationsTests

private readonly DockerClient _dockerClient;

public IVolumeOperationsTests(TestFixture testFixture, ITestOutputHelper outputHelper)
public IVolumeOperationsTests(TestFixture testFixture)
{
_dockerClient = testFixture.DockerClient;

Expand Down
Loading