示例#1
0
        public string GetImageDigest(string image, bool isDryRun)
        {
            IEnumerable <string> digests = DockerHelper.GetImageDigests(image, isDryRun);

            // A digest will not exist for images that have been built locally or have been manually installed
            if (!digests.Any())
            {
                return(null);
            }

            string digestSha = _manifestToolService.GetManifestDigestSha(ManifestMediaType.Any, image, isDryRun);

            if (digestSha is null)
            {
                return(null);
            }

            string digest = DockerHelper.GetDigestString(DockerHelper.GetRepo(image), digestSha);

            if (!digests.Contains(digest))
            {
                throw new InvalidOperationException(
                          $"Found published digest '{digestSha}' for tag '{image}' but could not find a matching digest value from " +
                          $"the set of locally pulled digests for this tag: { string.Join(", ", digests) }. This most likely means that " +
                          "this tag has been updated since it was last pulled.");
            }

            return(digest);
        }
示例#2
0
        private void SaveTagInfoToImageInfoFile(DateTime createdDate, ImageArtifactDetails imageArtifactDetails)
        {
            _loggerService.WriteSubheading("SETTING TAG INFO");

            IEnumerable <ImageData> images = imageArtifactDetails.Repos
                                             .SelectMany(repo => repo.Images)
                                             .Where(image => image.Manifest != null);

            Parallel.ForEach(images, image =>
            {
                image.Manifest.Created = createdDate;

                TagInfo sharedTag     = image.ManifestImage.SharedTags.First();
                image.Manifest.Digest = DockerHelper.GetDigestString(
                    image.ManifestRepo.FullModelName,
                    _manifestToolService.GetManifestDigestSha(
                        ManifestMediaType.ManifestList, sharedTag.FullyQualifiedName, Options.IsDryRun));
            });

            string imageInfoString = JsonHelper.SerializeObject(imageArtifactDetails);

            File.WriteAllText(Options.ImageInfoPath, imageInfoString);
        }