public async Task <bool> CheckConfigExists(ManifestV2 manifest) { var configExists = await _registry.BlobExists(_targetImageName, manifest.config.digest); _logger.LogDebug($"config {manifest.config.digest} ({manifest.config.size}) - {(configExists.HasValue ? "Exists" : "To be uploaded")}"); return(configExists.HasValue); }
public async Task UploadManifest(string name, string reference, ManifestV2 manifest) { var request = new HttpRequestMessage(HttpMethod.Put, $"/v2/{name}/manifests/{reference}"); request.Content = new StringContent(FileHelper.JsonSerialize(manifest)); request.Content.Headers.ContentType = new MediaTypeHeaderValue(ManifestV2.MimeType); var response = await HttpClient.SendAsync(request); await EnsureSuccessWithErrorContent(response); }
private void AddLayerToConfigAndManifest(BuilderLayer layer, ManifestV2 manifest, ImageV1 image) { image.rootfs.diff_ids.Add(layer.DiffId); image.history.Add(ImageV1History.Create(layer.Description, null)); var(imageBytes, imageDigest) = ToJson(image); manifest.config.digest = imageDigest; manifest.config.size = imageBytes.Length; manifest.layers.Add(new ManifestV2Layer { digest = layer.Digest, size = layer.Size, }); }
public async Task <IEnumerable <ManifestV2Layer> > FindMissingLayers(ManifestV2 manifest, bool tryMount) { var missingLayers = new List <ManifestV2Layer>(); foreach (var layer in manifest.layers) { var existsBlobSize = await _registry.BlobExists(_targetImageName, layer.digest); var exists = existsBlobSize.HasValue; var toAdd = _addedLayers.Any(x => x.Digest.Equals(layer.digest)); bool mounted = false; if (!exists && !toAdd) { if (tryMount) { try { await MountLayer(layer); mounted = true; } catch { missingLayers.Add(layer); } } else { missingLayers.Add(layer); } } string logMsg; if (toAdd && exists) { logMsg = $"Exists (unchanged?)"; } else if (toAdd) { logMsg = $"To be uploaded"; } else if (!exists && !toAdd) { if (mounted) { logMsg = $"Was missing, Mount sucessful!"; } else if (tryMount) { logMsg = $"Missing! (tried to mount)"; } else { logMsg = $"Missing!"; } } else { logMsg = $"Exists"; } _logger.LogDebug($"layer {layer.digest} ({layer.size}) - {logMsg}"); } return(missingLayers); }
private void UpdateConfigInManifest(ManifestV2 manifest, ImageV1 image) { var(imageBytes, imageDigest) = ToJson(image); manifest.config.digest = imageDigest; manifest.config.size = imageBytes.Length; }