/** * Makes a list of {@link BuildAndCacheApplicationLayerStep} for dependencies, resources, and * classes layers. Optionally adds an extra layer if configured to do so. */ public static IAsyncStep <IReadOnlyList <ICachedLayer> > MakeList( IBuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory) { buildConfiguration = buildConfiguration ?? throw new ArgumentNullException(nameof(buildConfiguration)); int layerCount = buildConfiguration.GetLayerConfigurations().Length; using (ProgressEventDispatcher progressEventDispatcher = progressEventDispatcherFactory.Create( "setting up to build application layers", layerCount)) using (TimerEventDispatcher ignored = new TimerEventDispatcher(buildConfiguration.GetEventHandlers(), Description)) { List <Task <ICachedLayer> > buildAndCacheApplicationLayerSteps = new List <Task <ICachedLayer> >(); foreach (LayerConfiguration layerConfiguration in buildConfiguration.GetLayerConfigurations()) { // Skips the layer if empty. if (layerConfiguration.LayerEntries.Length == 0) { continue; } buildAndCacheApplicationLayerSteps.Add( new BuildAndCacheApplicationLayerStep( buildConfiguration, progressEventDispatcher.NewChildProducer(), layerConfiguration.Name, layerConfiguration).GetFuture()); } return(AsyncSteps.FromTasks(buildAndCacheApplicationLayerSteps)); } }
public async Task <BuildResult> CallAsync() { IReadOnlyList <BlobDescriptor> baseImageDescriptors = await pushBaseImageLayersStep.GetFuture().ConfigureAwait(false); IReadOnlyList <BlobDescriptor> appLayerDescriptors = await pushApplicationLayersStep.GetFuture().ConfigureAwait(false); BlobDescriptor containerConfigurationBlobDescriptor = await pushContainerConfigurationStep.GetFuture().ConfigureAwait(false); ImmutableHashSet <string> targetImageTags = buildConfiguration.GetAllTargetImageTags(); using (var progressEventDispatcher = progressEventDispatcherFactory.Create("pushing image manifest", this.Index)) using (var factory = progressEventDispatcher.NewChildProducer()("[child progress]pushing image manifest", targetImageTags.Count)) using (TimerEventDispatcher ignored = new TimerEventDispatcher(buildConfiguration.GetEventHandlers(), DESCRIPTION)) { RegistryClient registryClient = buildConfiguration .NewTargetImageRegistryClientFactory() .SetAuthorization(await authenticatePushStep.GetFuture().ConfigureAwait(false)) .NewRegistryClient(); // Constructs the image. ImageToJsonTranslator imageToJsonTranslator = new ImageToJsonTranslator(await buildImageStep.GetFuture().ConfigureAwait(false)); // Gets the image manifest to push. IBuildableManifestTemplate manifestTemplate = imageToJsonTranslator.GetManifestTemplate( buildConfiguration.GetTargetFormat(), containerConfigurationBlobDescriptor); // Pushes to all target image tags. IList <Task <DescriptorDigest> > pushAllTagsFutures = new List <Task <DescriptorDigest> >(); var idx = 0; ProgressEventDispatcher.Factory progressEventDispatcherFactory = factory.NewChildProducer(); foreach (string tag in targetImageTags) { idx++; using (progressEventDispatcherFactory.Create("tagging with " + tag, idx)) { buildConfiguration.GetEventHandlers().Dispatch(LogEvent.Info("Tagging with " + tag + "...")); pushAllTagsFutures.Add(registryClient.PushManifestAsync(manifestTemplate, tag)); } } DescriptorDigest imageDigest = await Digests.ComputeJsonDigestAsync(manifestTemplate).ConfigureAwait(false); DescriptorDigest imageId = containerConfigurationBlobDescriptor.GetDigest(); BuildResult result = new BuildResult(imageDigest, imageId); await Task.WhenAll(pushAllTagsFutures).ConfigureAwait(false); return(result); } }
public PullBaseImageStep( BuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory) { this.buildConfiguration = buildConfiguration; this.progressEventDispatcherFactory = progressEventDispatcherFactory; listenableFuture = Task.Run(CallAsync); }
/** Retrieves credentials for the target image. */ public static RetrieveRegistryCredentialsStep ForTargetImage( BuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory) { buildConfiguration = buildConfiguration ?? throw new ArgumentNullException(nameof(buildConfiguration)); return(new RetrieveRegistryCredentialsStep( buildConfiguration, progressEventDispatcherFactory, buildConfiguration.GetTargetImageConfiguration().GetImageRegistry(), buildConfiguration.GetTargetImageConfiguration().GetCredentialRetrievers())); }
private async Task <BlobDescriptor> PushBlobAsync( ICachedLayer cachedLayer, ProgressEventDispatcher.Factory progressEventDispatcherFactory) { return(await new PushBlobStep( buildConfiguration, progressEventDispatcherFactory, authenticatePushStep, new BlobDescriptor(cachedLayer.GetSize(), cachedLayer.GetDigest()), cachedLayer.GetBlob()).GetFuture().ConfigureAwait(false)); }
public PullAndCacheBaseImageLayersStep( BuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory, PullBaseImageStep pullBaseImageStep) { this.buildConfiguration = buildConfiguration; this.progressEventDispatcherFactory = progressEventDispatcherFactory; this.pullBaseImageStep = pullBaseImageStep; listenableFuture = CallAsync(); }
public AuthenticatePushStep( BuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory, RetrieveRegistryCredentialsStep retrieveTargetRegistryCredentialsStep) { this.buildConfiguration = buildConfiguration; this.progressEventDispatcherFactory = progressEventDispatcherFactory; this.retrieveTargetRegistryCredentialsStep = retrieveTargetRegistryCredentialsStep; listenableFuture = CallAsync(); }
private RetrieveRegistryCredentialsStep( BuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory, string registry, ImmutableArray <CredentialRetriever> credentialRetrievers) { this.buildConfiguration = buildConfiguration; this.progressEventDispatcherFactory = progressEventDispatcherFactory; this.registry = registry; this.credentialRetrievers = credentialRetrievers; listenableFuture = Task.Run(Call); }
public PullAndCacheBaseImageLayerStep( BuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory, DescriptorDigest layerDigest, Authorization pullAuthorization) { this.buildConfiguration = buildConfiguration; this.progressEventDispatcherFactory = progressEventDispatcherFactory; this.layerDigest = layerDigest; this.pullAuthorization = pullAuthorization; listenableFuture = Task.Run(CallAsync); }
public PushLayersStep( BuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory, AuthenticatePushStep authenticatePushStep, IAsyncStep <IReadOnlyList <ICachedLayer> > cachedLayerStep) { this.buildConfiguration = buildConfiguration; this.progressEventDispatcherFactory = progressEventDispatcherFactory; this.authenticatePushStep = authenticatePushStep; this.cachedLayerStep = cachedLayerStep; listenableFuture = CallAsync(); }
private BuildAndCacheApplicationLayerStep( IBuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory, string layerType, LayerConfiguration layerConfiguration) { this.buildConfiguration = buildConfiguration; this.progressEventDispatcherFactory = progressEventDispatcherFactory; this.layerType = layerType; this.layerConfiguration = layerConfiguration; listenableFuture = Task.Run(CallAsync); }
public PushContainerConfigurationStep( BuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory, AuthenticatePushStep authenticatePushStep, BuildImageStep buildImageStep) { this.buildConfiguration = buildConfiguration; this.progressEventDispatcherFactory = progressEventDispatcherFactory; this.authenticatePushStep = authenticatePushStep; this.buildImageStep = buildImageStep; listenableFuture = CallAsync(); }
public PushBlobStep( BuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDipatcherFactory, AuthenticatePushStep authenticatePushStep, BlobDescriptor blobDescriptor, IBlob blob) { this.buildConfiguration = buildConfiguration; this.progressEventDipatcherFactory = progressEventDipatcherFactory; this.authenticatePushStep = authenticatePushStep; this.blobDescriptor = blobDescriptor; this.blob = blob; listenableFuture = CallAsync(); }
public BuildImageStep( IBuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory, IAsyncStep <BaseImageWithAuthorization> pullBaseImageStep, IAsyncStep <IReadOnlyList <ICachedLayer> > pullAndCacheBaseImageLayersStep, IAsyncStep <IReadOnlyList <ICachedLayer> > buildAndCacheApplicationLayerSteps) { this.buildConfiguration = buildConfiguration; this.progressEventDispatcherFactory = progressEventDispatcherFactory; this.pullBaseImageStep = pullBaseImageStep; this.pullAndCacheBaseImageLayersStep = pullAndCacheBaseImageLayersStep; buildAndCacheApplicationLayersStep = buildAndCacheApplicationLayerSteps; listenableFuture = CallAsync(); }
public LoadDockerStep( BuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory, DockerClient dockerClient, PullAndCacheBaseImageLayersStep pullAndCacheBaseImageLayersStep, IAsyncStep <IReadOnlyList <ICachedLayer> > buildAndCacheApplicationLayersStep, BuildImageStep buildImageStep) { this.buildConfiguration = buildConfiguration; this.progressEventDispatcherFactory = progressEventDispatcherFactory; this.dockerClient = dockerClient; this.pullAndCacheBaseImageLayersStep = pullAndCacheBaseImageLayersStep; this.buildAndCacheApplicationLayersStep = buildAndCacheApplicationLayersStep; this.buildImageStep = buildImageStep; listenableFuture = CallAsync(); }
public WriteTarFileStep( BuildConfiguration buildConfiguration, ProgressEventDispatcher.Factory progressEventDispatcherFactory, SystemPath outputPath, PullAndCacheBaseImageLayersStep pullAndCacheBaseImageLayersStep, IAsyncStep <IReadOnlyList <ICachedLayer> > buildAndCacheApplicationLayersStep, BuildImageStep buildImageStep) { this.buildConfiguration = buildConfiguration; this.progressEventDispatcherFactory = progressEventDispatcherFactory; this.outputPath = outputPath; this.pullAndCacheBaseImageLayersStep = pullAndCacheBaseImageLayersStep; this.buildAndCacheApplicationLayersStep = buildAndCacheApplicationLayersStep; this.buildImageStep = buildImageStep; listenableFuture = CallAsync(); }
public ThrottledProgressEventDispatcherWrapper( ProgressEventDispatcher.Factory progressEventDispatcherFactory, string description) { this.progressEventDispatcherFactory = progressEventDispatcherFactory; this.description = description; }
/** * Creates the {@link ProgressEventDispatcher} with an associated {@link Allocation}. * * @param description user-facing description of what the allocation represents * @param allocationUnits number of allocation units * @return the new {@link ProgressEventDispatcher} */ public static ProgressEventDispatcher Create(this ProgressEventDispatcher.Factory f, string description, long allocationUnits) { f = f ?? throw new ArgumentNullException(nameof(f)); return(f(description, allocationUnits)); }