示例#1
0
#pragma warning restore S107

        private static ITestcontainersBuilder <TDockerContainer> Build(
            TestcontainersBuilder <TDockerContainer> previous,
            ITestcontainersConfiguration next,
            Action <TDockerContainer> moduleConfiguration = null)
        {
            var cleanUp          = next.CleanUp && previous.configuration.CleanUp;
            var endpoint         = Merge(next.Endpoint, previous.configuration.Endpoint, DockerApiEndpoint.Local);
            var image            = Merge(next.Image, previous.configuration.Image);
            var name             = Merge(next.Name, previous.configuration.Name);
            var workingDirectory = Merge(next.WorkingDirectory, previous.configuration.WorkingDirectory);
            var entrypoint       = Merge(next.Entrypoint, previous.configuration.Entrypoint);
            var command          = Merge(next.Command, previous.configuration.Command);
            var environments     = Merge(next.Environments, previous.configuration.Environments);
            var labels           = Merge(next.Labels, previous.configuration.Labels);
            var exposedPorts     = Merge(next.ExposedPorts, previous.configuration.ExposedPorts);
            var portBindings     = Merge(next.PortBindings, previous.configuration.PortBindings);
            var mounts           = Merge(next.Mounts, previous.configuration.Mounts);

            var authConfig     = new[] { next.AuthConfig, previous.configuration.AuthConfig }.First(config => config != null);
            var outputConsumer = new[] { next.OutputConsumer, previous.configuration.OutputConsumer }.First(config => config != null);
            var waitStrategies = new[] { next.WaitStrategies, previous.configuration.WaitStrategies }.First(config => config != null);

            var mergedConfiguration = Apply(
                endpoint,
                authConfig,
                image,
                name,
                workingDirectory,
                entrypoint,
                command,
                environments,
                labels,
                exposedPorts,
                portBindings,
                mounts,
                outputConsumer,
                waitStrategies,
                cleanUp);

            return(new TestcontainersBuilder <TDockerContainer>(mergedConfiguration, moduleConfiguration ?? previous.moduleConfiguration));
        }