-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathIDockerService.cs
59 lines (52 loc) · 2.81 KB
/
IDockerService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
namespace Microsoft.ComponentDetection.Contracts;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ComponentDetection.Contracts.BcdeModels;
/// <summary>
/// Represents a service for interacting with the Docker daemon.
/// </summary>
public interface IDockerService
{
/// <summary>
/// Gets a value indicating whether the Docker daemon is running in Linux container mode.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Returns true if the Docker daemon is running and in Linux container mode, otherwise false.</returns>
Task<bool> CanRunLinuxContainersAsync(CancellationToken cancellationToken = default);
/// <summary>
/// Gets a value indicating whether the Docker daemon can be pinged.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Returns true if the Docker daemon can be pinged, otherwise false.</returns>
Task<bool> CanPingDockerAsync(CancellationToken cancellationToken = default);
/// <summary>
/// Gets a value indicating whether the container image exists locally.
/// </summary>
/// <param name="image">The image to check.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Returns true if the container image exists locally, otherwise false.</returns>
Task<bool> ImageExistsLocallyAsync(string image, CancellationToken cancellationToken = default);
/// <summary>
/// Pulls the container image from the Docker registry.
/// </summary>
/// <param name="image">The image to pull.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Returns true if the image was pulled successfully, otherwise false.</returns>
Task<bool> TryPullImageAsync(string image, CancellationToken cancellationToken = default);
/// <summary>
/// Gets the container image details.
/// </summary>
/// <param name="image">The image to inspect.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Returns the container image details.</returns>
Task<ContainerDetails> InspectImageAsync(string image, CancellationToken cancellationToken = default);
/// <summary>
/// Creates and runs a container with the given image and command.
/// </summary>
/// <param name="image">The image to inspect.</param>
/// <param name="command">The command to run in the container.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A tuple of stdout and stderr from the container.</returns>
Task<(string Stdout, string Stderr)> CreateAndRunContainerAsync(string image, IList<string> command, CancellationToken cancellationToken = default);
}