Beispiel #1
0
        public static RepoInfo Create(
            Repo model,
            string registry,
            string modelRegistryName,
            ManifestFilter manifestFilter,
            IManifestOptionsInfo options,
            VariableHelper variableHelper,
            string baseDirectory)
        {
            RepoInfo repoInfo = new RepoInfo
            {
                Model         = model,
                FullModelName = (string.IsNullOrEmpty(modelRegistryName) ? string.Empty : $"{modelRegistryName}/") + model.Name,
                Id            = model.Id ?? model.Name
            };

            registry = string.IsNullOrEmpty(registry) ? string.Empty : $"{registry}/";
            repoInfo.QualifiedName = registry + options.RepoPrefix + model.Name;

            if (model.Readme != null)
            {
                repoInfo.ReadmePath = Path.Combine(baseDirectory, model.Readme);
            }
            if (model.ReadmeTemplate != null)
            {
                repoInfo.ReadmeTemplatePath = Path.Combine(baseDirectory, model.ReadmeTemplate);
            }

            repoInfo.AllImages = model.Images
                                 .Select(image => ImageInfo.Create(image, repoInfo.FullModelName, repoInfo.QualifiedName, manifestFilter, variableHelper, baseDirectory))
                                 .ToArray();

            repoInfo.FilteredImages = repoInfo.AllImages
                                      .Where(image => image.FilteredPlatforms.Any())
                                      .ToArray();

            return(repoInfo);
        }
Beispiel #2
0
        public static RepoInfo Create(
            Repo model, string registry, ManifestFilter manifestFilter, IOptionsInfo options, VariableHelper variableHelper)
        {
            RepoInfo repoInfo = new RepoInfo();

            repoInfo.Model = model;
            repoInfo.Id    = model.Id ?? model.Name;

            if (options.RepoOverrides.TryGetValue(model.Name, out string nameOverride))
            {
                repoInfo.Name = nameOverride;
            }
            else
            {
                registry      = String.IsNullOrEmpty(registry) ? "" : $"{registry}/";
                repoInfo.Name = registry + options.RepoPrefix + model.Name;
            }

            repoInfo.AllImages = model.Images
                                 .Select(image => ImageInfo.Create(image, model, repoInfo.Name, manifestFilter, variableHelper))
                                 .ToArray();

            repoInfo.FilteredImages = repoInfo.AllImages
                                      .Where(image => image.FilteredPlatforms.Any())
                                      .ToArray();

            return(repoInfo);
        }
Beispiel #3
0
        public static ImageInfo Create(Image model, string repoName, ManifestFilter manifestFilter, VariableHelper variableHelper)
        {
            ImageInfo imageInfo = new ImageInfo();

            imageInfo.Model = model;

            if (model.SharedTags == null)
            {
                imageInfo.SharedTags = Enumerable.Empty <TagInfo>();
            }
            else
            {
                imageInfo.SharedTags = model.SharedTags
                                       .Select(kvp => TagInfo.Create(kvp.Key, kvp.Value, repoName, variableHelper))
                                       .ToArray();
            }

            imageInfo.Platforms = manifestFilter.GetPlatforms(model)
                                  .Select(platform => PlatformInfo.Create(platform, repoName, variableHelper))
                                  .ToArray();

            IEnumerable <Platform> activePlatformModels = manifestFilter.GetActivePlatforms(model);

            imageInfo.ActivePlatforms = imageInfo.Platforms
                                        .Where(platform => activePlatformModels.Contains(platform.Model));

            return(imageInfo);
        }
Beispiel #4
0
        public static ImageInfo Create(
            Image model, string fullRepoModelName, string repoName, ManifestFilter manifestFilter, VariableHelper variableHelper, string baseDirectory)
        {
            ImageInfo imageInfo = new ImageInfo();

            imageInfo.Model = model;

            imageInfo.ProductVersion = variableHelper.SubstituteValues(model.ProductVersion);

            if (model.SharedTags == null)
            {
                imageInfo.SharedTags = Enumerable.Empty <TagInfo>();
            }
            else
            {
                imageInfo.SharedTags = model.SharedTags
                                       .Select(kvp => TagInfo.Create(kvp.Key, kvp.Value, repoName, variableHelper))
                                       .ToArray();
            }

            imageInfo.AllPlatforms = model.Platforms
                                     .Select(platform => PlatformInfo.Create(platform, fullRepoModelName, repoName, variableHelper, baseDirectory))
                                     .ToArray();

            IEnumerable <Platform> filteredPlatformModels = manifestFilter.GetPlatforms(model);

            imageInfo.FilteredPlatforms = imageInfo.AllPlatforms
                                          .Where(platform => filteredPlatformModels.Contains(platform.Model));

            return(imageInfo);
        }
Beispiel #5
0
        public static RepoInfo Create(Repo model, ManifestFilter manifestFilter, string repoOwner, VariableHelper variableHelper)
        {
            RepoInfo repoInfo = new RepoInfo();

            repoInfo.Model = model;
            repoInfo.Name  = string.IsNullOrWhiteSpace(repoOwner) ?
                             model.Name : DockerHelper.ReplaceImageOwner(model.Name, repoOwner);
            repoInfo.Images = model.Images
                              .Select(image => ImageInfo.Create(image, repoInfo.Name, manifestFilter, variableHelper))
                              .ToArray();

            return(repoInfo);
        }
Beispiel #6
0
        public static RepoInfo Create(Repo model, ManifestFilter manifestFilter, IOptionsInfo options, VariableHelper variableHelper)
        {
            RepoInfo repoInfo = new RepoInfo();

            repoInfo.Model             = model;
            repoInfo.HasOverriddenName = options.RepoOverrides.TryGetValue(model.Name, out string nameOverride);
            repoInfo.Name   = repoInfo.HasOverriddenName ? nameOverride : model.Name;
            repoInfo.Images = model.Images
                              .Select(image => ImageInfo.Create(image, repoInfo.Name, manifestFilter, variableHelper))
                              .ToArray();

            return(repoInfo);
        }