-
Notifications
You must be signed in to change notification settings - Fork 36
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
Consider using Docker.DotNet instead of docker cli #117
Comments
Does it offer full capability compared to cli commands? |
It should, but, just in case, we could |
OK, will take a look, it might take some time. Will let you know. |
The one I have and am using is for But, in the usage I have, I already have the image loaded into a So we need to have two options for the image:
Maybe we could have two overloads: public static void DockerApiImageLoad(this ICakeContext context, FilePath image, DockerApiImageLoadSettings settings);
public static void DockerApiImageLoad(this ICakeContext context, Stream image, DockerApiImageLoadSettings settings);
/// <summary>
/// Settings for docker image load [OPTIONS].
/// Load an image from a tar archive file or stream
/// </summary>
public class DockerApiImageLoadSettings
{
/// <summary>
/// Gets or sets whether to suppress or not the load output.
/// </summary>
/// <value><see langword="true" /> to suppress load output; <see langword="false" /> to not suppress load output. Default is <see langword="false" />.
/// <remarks>Same as command-line <c>--quiet</c>,<c>-q</c> option.</remarks>
public bool Quiet { get; set; }
} The invocation of the client would be something like: await dockerClient.Images.LoadImageAsync(
new ImageLoadParameters { Quiet = settings.Quiet },
imageStream, // the provided stream or the stream from the provided file path.
new Progress(context))
.ConfigureAwait(ConfigureAwaitOptions.None);
private sealed class Progress(BuildContext context) : IProgress<JSONMessage>
{
public void Report(JSONMessage value)
{
if (!string.IsNullOrEmpty(value.Stream))
{
context.Log.Information($"Stream: {value.Stream}");
}
if (!string.IsNullOrEmpty(value.Status))
{
context.Log.Information($"Status: {value.Status}");
}
if (value.Error is { } error)
{
context.Log.Error($"Error {error.Code}: {error.Message}");
throw new Exception(error.Message);
}
if (!string.IsNullOrEmpty(value.ProgressMessage))
{
context.Log.Information($"Progress: {value.ProgressMessage}");
}
}
} How's that for a start? |
TBH I'm mulling an idea that cake addin is not even required with this library. One could reference Docker.DotNet directly and use it as it deems appropriate. Even more so because it's stateful. But let's take it slowly. |
Using Docker.DotNet.
Maybe this could be a different addin to not break anyone and allow incremental implementation of aliases.
I can contribute.
The text was updated successfully, but these errors were encountered: