Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update specgen configuration to Docker Engine API 27.3.1 #2

Merged
merged 2 commits into from
Oct 30, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/Docker.DotNet.X509/CertificateCredentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override HttpMessageHandler GetHandler(HttpMessageHandler innerHandler)
_certificate
};

handler.ServerCertificateValidationCallback = this.ServerCertificateValidationCallback;
handler.ServerCertificateValidationCallback = ServerCertificateValidationCallback;

if (handler.ServerCertificateValidationCallback == null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Docker.DotNet.X509/RSAUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public static X509Certificate2 GetCertFromPEMFiles(string certFilePath, string keyFilePath)
{
var cert = new X509Certificate2(certFilePath);
cert.PrivateKey = RSAUtil.ReadFromPemFile(keyFilePath);
cert.PrivateKey = ReadFromPemFile(keyFilePath);

Check warning on line 27 in src/Docker.DotNet.X509/RSAUtil.cs

View workflow job for this annotation

GitHub Actions / build

'X509Certificate2.PrivateKey' is obsolete: 'X509Certificate2.PrivateKey is obsolete. Use the appropriate method to get the private key, such as GetRSAPrivateKey, or use the CopyWithPrivateKey method to create a new instance with a private key.' (https://aka.ms/dotnet-warnings/SYSLIB0028)
return cert;
}

Expand Down Expand Up @@ -84,14 +84,14 @@
};

// Use "1" to indicate RSA.
var csp = new CspParameters(1)

Check warning on line 87 in src/Docker.DotNet.X509/RSAUtil.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'CspParameters' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
{

// Set the KeyContainerName so that native code that looks up the private key
// can find it. This produces a keyset file on disk as a side effect.
KeyContainerName = pemFilePath

Check warning on line 92 in src/Docker.DotNet.X509/RSAUtil.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'CspParameters.KeyContainerName' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
};
var rsaProvider = new RSACryptoServiceProvider(csp)

Check warning on line 94 in src/Docker.DotNet.X509/RSAUtil.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'RSACryptoServiceProvider' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
{

// Setting to false makes sure the keystore file will be cleaned up
Expand Down
8 changes: 4 additions & 4 deletions src/Docker.DotNet/BinaryRequestContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public BinaryRequestContent(Stream stream, string mimeType)
throw new ArgumentNullException(nameof(mimeType));
}

this._stream = stream;
this._mimeType = mimeType;
_stream = stream;
_mimeType = mimeType;
}

public HttpContent GetContent()
{
var data = new StreamContent(this._stream);
data.Headers.ContentType = new MediaTypeHeaderValue(this._mimeType);
var data = new StreamContent(_stream);
data.Headers.ContentType = new MediaTypeHeaderValue(_mimeType);
return data;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Docker.DotNet/DockerApiException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class DockerApiException : Exception
public DockerApiException(HttpStatusCode statusCode, string responseBody)
: base($"Docker API responded with status code={statusCode}, response={responseBody}")
{
this.StatusCode = statusCode;
this.ResponseBody = responseBody;
StatusCode = statusCode;
ResponseBody = responseBody;
}
}
}
4 changes: 2 additions & 2 deletions src/Docker.DotNet/DockerApiResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ internal class DockerApiResponse

public DockerApiResponse(HttpStatusCode statusCode, string body)
{
this.StatusCode = statusCode;
this.Body = body;
StatusCode = statusCode;
Body = body;
}
}
}
3 changes: 1 addition & 2 deletions src/Docker.DotNet/DockerPipeStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
{
// The Docker daemon expects a write of zero bytes to signal the end of writes. Use native
// calls to achieve this since CoreCLR ignores a zero-byte write.
var overlapped = new NativeOverlapped();

Check warning on line 54 in src/Docker.DotNet/DockerPipeStream.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'NativeOverlapped' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 54 in src/Docker.DotNet/DockerPipeStream.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'NativeOverlapped' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

#if NET45
var handle = _event.SafeWaitHandle;
Expand All @@ -61,14 +61,13 @@

// Set the low bit to tell Windows not to send the result of this IO to the
// completion port.
overlapped.EventHandle = (IntPtr)(handle.DangerousGetHandle().ToInt64() | 1);

Check warning on line 64 in src/Docker.DotNet/DockerPipeStream.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'NativeOverlapped.EventHandle' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 64 in src/Docker.DotNet/DockerPipeStream.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'NativeOverlapped.EventHandle' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
if (WriteFile(_stream.SafePipeHandle, IntPtr.Zero, 0, IntPtr.Zero, ref overlapped) == 0)
{
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
18 changes: 9 additions & 9 deletions src/Docker.DotNet/Endpoints/ConfigsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ internal class ConfigOperations : IConfigOperations

internal ConfigOperations(DockerClient client)
{
this._client = client;
_client = client;
}

async Task<IList<SwarmConfig>> IConfigOperations.ListConfigsAsync(CancellationToken cancellationToken)
{
var response = await this._client.MakeRequestAsync(this._client.NoErrorHandlers, HttpMethod.Get, "configs", cancellationToken).ConfigureAwait(false);
return this._client.JsonSerializer.DeserializeObject<IList<SwarmConfig>>(response.Body);
var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, "configs", cancellationToken).ConfigureAwait(false);
return _client.JsonSerializer.DeserializeObject<IList<SwarmConfig>>(response.Body);
}

async Task<SwarmCreateConfigResponse> IConfigOperations.CreateConfigAsync(SwarmCreateConfigParameters body, CancellationToken cancellationToken)
Expand All @@ -29,9 +29,9 @@ async Task<SwarmCreateConfigResponse> IConfigOperations.CreateConfigAsync(SwarmC
throw new ArgumentNullException(nameof(body));
}

var data = new JsonRequestContent<SwarmConfigSpec>(body.Config, this._client.JsonSerializer);
var response = await this._client.MakeRequestAsync(this._client.NoErrorHandlers, HttpMethod.Post, "configs/create", null, data, cancellationToken).ConfigureAwait(false);
return this._client.JsonSerializer.DeserializeObject<SwarmCreateConfigResponse>(response.Body);
var data = new JsonRequestContent<SwarmConfigSpec>(body.Config, _client.JsonSerializer);
var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "configs/create", null, data, cancellationToken).ConfigureAwait(false);
return _client.JsonSerializer.DeserializeObject<SwarmCreateConfigResponse>(response.Body);
}

async Task<SwarmConfig> IConfigOperations.InspectConfigAsync(string id, CancellationToken cancellationToken)
Expand All @@ -41,8 +41,8 @@ async Task<SwarmConfig> IConfigOperations.InspectConfigAsync(string id, Cancella
throw new ArgumentNullException(nameof(id));
}

var response = await this._client.MakeRequestAsync(this._client.NoErrorHandlers, HttpMethod.Get, $"configs/{id}", cancellationToken).ConfigureAwait(false);
return this._client.JsonSerializer.DeserializeObject<SwarmConfig>(response.Body);
var response = await _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Get, $"configs/{id}", cancellationToken).ConfigureAwait(false);
return _client.JsonSerializer.DeserializeObject<SwarmConfig>(response.Body);
}

Task IConfigOperations.RemoveConfigAsync(string id, CancellationToken cancellationToken)
Expand All @@ -52,7 +52,7 @@ Task IConfigOperations.RemoveConfigAsync(string id, CancellationToken cancellati
throw new ArgumentNullException(nameof(id));
}

return this._client.MakeRequestAsync(this._client.NoErrorHandlers, HttpMethod.Delete, $"configs/{id}", cancellationToken);
return _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Delete, $"configs/{id}", cancellationToken);
}
}
}
Loading