#pragma warning disable S107 private static ITestcontainersConfiguration Apply( Uri endpoint = null, IAuthenticationConfiguration authConfig = null, IDockerImage image = null, string name = null, string workingDirectory = null, IEnumerable <string> entrypoint = null, IEnumerable <string> command = null, IReadOnlyDictionary <string, string> environments = null, IReadOnlyDictionary <string, string> labels = null, IReadOnlyDictionary <string, string> exposedPorts = null, IReadOnlyDictionary <string, string> portBindings = null, IEnumerable <IBind> mounts = null, IOutputConsumer outputConsumer = null, IEnumerable <IWaitUntil> waitStrategies = null, bool cleanUp = true) { return(new TestcontainersConfiguration( endpoint ?? DockerApiEndpoint.Local, authConfig, image, name, workingDirectory, entrypoint, command, environments, labels, exposedPorts, portBindings, mounts, outputConsumer, waitStrategies, cleanUp)); }
public ITestcontainersBuilder <T> WithOutputConsumer(IOutputConsumer outputConsumer) { return(Build(this, new TestcontainersConfiguration { OutputConsumer = outputConsumer, })); }
#pragma warning disable S107 public TestcontainersConfiguration( Uri endpoint, IAuthenticationConfiguration authenticationConfigurations, IDockerImage image, string name, string workingDirectory, IEnumerable <string> entrypoint, IEnumerable <string> command, IReadOnlyDictionary <string, string> environments, IReadOnlyDictionary <string, string> labels, IReadOnlyDictionary <string, string> exposedPorts, IReadOnlyDictionary <string, string> portBindings, IEnumerable <IBind> mounts, IOutputConsumer outputConsumer, IEnumerable <IWaitUntil> waitStrategies, bool cleanUp = true) { this.CleanUp = cleanUp; this.Endpoint = endpoint; this.AuthConfig = authenticationConfigurations; this.Image = image; this.Name = name; this.WorkingDirectory = workingDirectory; this.Entrypoint = entrypoint; this.Command = command; this.Environments = environments; this.Labels = labels; this.ExposedPorts = exposedPorts; this.PortBindings = portBindings; this.Mounts = mounts; this.OutputConsumer = outputConsumer; this.WaitStrategies = waitStrategies; }
public async Task AttachAsync(string id, IOutputConsumer outputConsumer, CancellationToken ct = default) { Logger.LogInformation("Attaching {outputConsumer} at container {id}", outputConsumer.GetType(), id); var attachParameters = new ContainerAttachParameters { Stdout = true, Stderr = true, Stream = true, }; var stream = await this.Docker.Containers.AttachContainerAsync(id, false, attachParameters, ct) .ConfigureAwait(false); _ = stream.CopyOutputToAsync(Stream.Null, outputConsumer.Stdout, outputConsumer.Stderr, ct) .ConfigureAwait(false); }
public async Task AttachAsync(string id, IOutputConsumer outputConsumer, CancellationToken ct = default) { if (outputConsumer is null) { return; } var attachParameters = new ContainerAttachParameters { Stdout = true, Stderr = true, Stream = true, }; var stream = await this.Docker.Containers.AttachContainerAsync(id, false, attachParameters, ct); _ = stream.CopyOutputToAsync(Stream.Null, outputConsumer.Stdout, outputConsumer.Stderr, ct); }
#pragma warning disable S107 /// <summary> /// Initializes a new instance of the <see cref="TestcontainersConfiguration" /> class. /// </summary> /// <param name="dockerEndpointAuthenticationConfiguration">The Docker endpoint authentication configuration.</param> /// <param name="dockerRegistryAuthenticationConfiguration">The Docker registry authentication configuration.</param> /// <param name="image">The Docker image.</param> /// <param name="name">The name.</param> /// <param name="hostname">The hostname.</param> /// <param name="workingDirectory">The working directory.</param> /// <param name="entrypoint">The entrypoint.</param> /// <param name="command">The command.</param> /// <param name="environments">The environment variables.</param> /// <param name="labels">The labels.</param> /// <param name="exposedPorts">The exposed ports.</param> /// <param name="portBindings">The port bindings.</param> /// <param name="mounts">The volumes.</param> /// <param name="networks">The networks.</param> /// <param name="networkAliases">The container network aliases.</param> /// <param name="outputConsumer">The output consumer.</param> /// <param name="waitStrategies">The wait strategies.</param> /// <param name="startupCallback">The startup callback.</param> /// <param name="autoRemove">A value indicating whether the Testcontainer is removed by the Docker daemon or not.</param> /// <param name="privileged">A value indicating whether the Testcontainer has extended privileges or not.</param> public TestcontainersConfiguration( IDockerEndpointAuthenticationConfiguration dockerEndpointAuthenticationConfiguration = null, IDockerRegistryAuthenticationConfiguration dockerRegistryAuthenticationConfiguration = null, IDockerImage image = null, string name = null, string hostname = null, string workingDirectory = null, IEnumerable <string> entrypoint = null, IEnumerable <string> command = null, IReadOnlyDictionary <string, string> environments = null, IReadOnlyDictionary <string, string> labels = null, IReadOnlyDictionary <string, string> exposedPorts = null, IReadOnlyDictionary <string, string> portBindings = null, IEnumerable <IMount> mounts = null, IEnumerable <IDockerNetwork> networks = null, IEnumerable <string> networkAliases = null, IOutputConsumer outputConsumer = null, IEnumerable <IWaitUntil> waitStrategies = null, Func <ITestcontainersContainer, CancellationToken, Task> startupCallback = null, bool?autoRemove = null, bool?privileged = null) : base(dockerEndpointAuthenticationConfiguration, labels) { this.AutoRemove = autoRemove; this.Privileged = privileged; this.DockerRegistryAuthConfig = dockerRegistryAuthenticationConfiguration; this.Image = image; this.Name = name; this.Hostname = hostname; this.WorkingDirectory = workingDirectory; this.Entrypoint = entrypoint; this.Command = command; this.Environments = environments; this.ExposedPorts = exposedPorts; this.PortBindings = portBindings; this.Mounts = mounts; this.Networks = networks; this.NetworkAliases = networkAliases; this.OutputConsumer = outputConsumer; this.WaitStrategies = waitStrategies; this.StartupCallback = startupCallback; }
public async Task AttachAsync(string id, IOutputConsumer outputConsumer, CancellationToken ct = default) { if (!outputConsumer.Enabled) { return; } this.logger.AttachToDockerContainer(id, outputConsumer.GetType()); var attachParameters = new ContainerAttachParameters { Stdout = true, Stderr = true, Stream = true, }; var stream = await this.Docker.Containers.AttachContainerAsync(id, false, attachParameters, ct) .ConfigureAwait(false); _ = stream.CopyOutputToAsync(Stream.Null, outputConsumer.Stdout, outputConsumer.Stderr, ct) .ConfigureAwait(false); }
public Task AttachAsync(string id, IOutputConsumer outputConsumer, CancellationToken ct = default) { return(this.containers.AttachAsync(id, outputConsumer, ct)); }
public void UnregisterConsumer(IOutputConsumer consumer) { lock (featureSyncObject) { OutputConsumers.Remove(consumer); } }
public void RegisterConsumer(IOutputConsumer consumer) { lock (featureSyncObject) { OutputConsumers.Add(consumer); } }
/// <inheritdoc cref="ITestcontainersBuilder{TDockerContainer}" /> public ITestcontainersBuilder <TDockerContainer> WithOutputConsumer(IOutputConsumer outputConsumer) { return(this.MergeNewConfiguration(new TestcontainersConfiguration(outputConsumer: outputConsumer))); }
/// <inheritdoc /> public ITestcontainersBuilder <TDockerContainer> WithOutputConsumer(IOutputConsumer outputConsumer) { return(Build(this, Apply(outputConsumer: outputConsumer))); }