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 CachedLayerWithType(ICachedLayer cachedLayer, string layerType) { CachedLayer = cachedLayer; this.layerType = layerType; }
public void SetUp() { testDescriptorDigest = DescriptorDigest.FromHash( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); Mock.Get(mockBuildConfiguration).Setup(m => m.GetEventHandlers()).Returns(mockEventHandlers); Mock.Get(mockBuildConfiguration).Setup(m => m.GetContainerConfiguration()).Returns(mockContainerConfiguration); Mock.Get(mockBuildConfiguration).Setup(m => m.GetToolName()).Returns(() => null); Mock.Get(mockContainerConfiguration).Setup(m => m.GetCreationTime()).Returns(Instant.FromUnixTimeSeconds(0)); Mock.Get(mockContainerConfiguration).Setup(m => m.GetEnvironmentMap()).Returns(ImmutableDictionary.Create <string, string>()); Mock.Get(mockContainerConfiguration).Setup(m => m.GetProgramArguments()).Returns(ImmutableArray.Create <string>()); Mock.Get(mockContainerConfiguration).Setup(m => m.GetExposedPorts()).Returns(ImmutableHashSet.Create <Port>()); Mock.Get(mockContainerConfiguration).Setup(m => m.GetEntrypoint()).Returns(ImmutableArray.Create <string>()); Mock.Get(mockContainerConfiguration).Setup(m => m.GetUser()).Returns("root"); Mock.Get(mockCachedLayer).Setup(m => m.GetBlobDescriptor()).Returns(new BlobDescriptor(0, testDescriptorDigest)); nonEmptyLayerHistory = HistoryEntry.CreateBuilder() .SetCreationTimestamp(Instant.FromUnixTimeSeconds(0)) .SetAuthor("FibBase") .SetCreatedBy("fib-test") .Build(); emptyLayerHistory = HistoryEntry.CreateBuilder() .SetCreationTimestamp(Instant.FromUnixTimeSeconds(0)) .SetAuthor("FibBase") .SetCreatedBy("fib-test") .SetEmptyLayer(true) .Build(); Image baseImage = Image.CreateBuilder(ManifestFormat.V22) .SetArchitecture("wasm") .SetOs("js") .AddEnvironment(ImmutableDic.Of("BASE_ENV", "BASE_ENV_VALUE", "BASE_ENV_2", "DEFAULT")) .AddLabel("base.label", "base.label.value") .AddLabel("base.label.2", "default") .SetWorkingDirectory("/base/working/directory") .SetEntrypoint(ImmutableArray.Create("baseImageEntrypoint")) .SetProgramArguments(ImmutableArray.Create("catalina.sh", "run")) .SetHealthCheck( DockerHealthCheck.FromCommand(ImmutableArray.Create("CMD-SHELL", "echo hi")) .SetInterval(Duration.FromSeconds(3)) .SetTimeout(Duration.FromSeconds(2)) .SetStartPeriod(Duration.FromSeconds(1)) .SetRetries(20) .Build()) .AddExposedPorts(ImmutableHashSet.Create(Port.Tcp(1000), Port.Udp(2000))) .AddVolumes( ImmutableHashSet.Create( AbsoluteUnixPath.Get("/base/path1"), AbsoluteUnixPath.Get("/base/path2"))) .AddHistory(nonEmptyLayerHistory) .AddHistory(emptyLayerHistory) .AddHistory(emptyLayerHistory) .Build(); Mock.Get(mockPullAndCacheBaseImageLayerStep).Setup(m => m.GetFuture()).Returns(Futures.ImmediateFutureAsync(mockCachedLayer)); Mock.Get(mockPullAndCacheBaseImageLayersStep).Setup(m => m.GetFuture()).Returns( Futures.ImmediateFutureAsync <IReadOnlyList <ICachedLayer> >( ImmutableArray.Create( mockCachedLayer, mockCachedLayer, mockCachedLayer))); Mock.Get(mockPullBaseImageStep).Setup(m => m.GetFuture()).Returns( Futures.ImmediateFutureAsync( new BaseImageWithAuthorization(baseImage, null))); mockClassesLayer = new CachedLayerWithType(mockCachedLayer, "classes"); mockDependenciesLayer = new CachedLayerWithType(mockCachedLayer, "dependencies"); mockExtraFilesLayer = new CachedLayerWithType(mockCachedLayer, "extra files"); mockResourcesLayer = new CachedLayerWithType(mockCachedLayer, "resources"); }