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); }
public static RepoInfo Create( Repo model, string registry, string modelRegistryName, ManifestFilter manifestFilter, IOptionsInfo options, VariableHelper variableHelper) { RepoInfo repoInfo = new RepoInfo(); repoInfo.Model = model; repoInfo.FullModelName = (string.IsNullOrEmpty(modelRegistryName) ? string.Empty : $"{modelRegistryName}/") + model.Name; repoInfo.Id = model.Id ?? model.Name; if (options.RepoOverrides.TryGetValue(model.Name, out string nameOverride)) { repoInfo.Name = nameOverride; } else { registry = string.IsNullOrEmpty(registry) ? string.Empty : $"{registry}/"; repoInfo.Name = registry + options.RepoPrefix + model.Name; } repoInfo.AllImages = model.Images .Select(image => ImageInfo.Create(image, repoInfo.FullModelName, repoInfo.Name, manifestFilter, variableHelper)) .ToArray(); repoInfo.FilteredImages = repoInfo.AllImages .Where(image => image.FilteredPlatforms.Any()) .ToArray(); return(repoInfo); }
public static ManifestInfo Create(Manifest model, ManifestFilter manifestFilter, IOptionsInfo options) { ManifestInfo manifestInfo = new ManifestInfo(); manifestInfo.Model = model; manifestInfo.Registry = options.RegistryOverride ?? model.Registry; manifestInfo.VariableHelper = new VariableHelper(model, options, manifestInfo.GetTagById, manifestInfo.GetRepoById); manifestInfo.AllRepos = manifestInfo.Model.Repos .Select(repo => RepoInfo.Create( repo, manifestInfo.Registry, model.Registry, manifestFilter, options, manifestInfo.VariableHelper)) .ToArray(); IEnumerable <string> repoNames = manifestInfo.AllRepos.Select(repo => repo.Name).ToArray(); foreach (PlatformInfo platform in manifestInfo.AllRepos.SelectMany(repo => repo.AllImages).SelectMany(image => image.AllPlatforms)) { platform.Initialize(repoNames, manifestInfo.Registry); } IEnumerable <Repo> filteredRepoModels = manifestFilter.GetRepos(manifestInfo.Model); manifestInfo.FilteredRepos = manifestInfo.AllRepos .Where(repo => filteredRepoModels.Contains(repo.Model)) .ToArray(); return(manifestInfo); }
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); }
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; 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); }
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); }
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); }
private static ManifestInfo Create(string manifestPath, ManifestFilter manifestFilter, IManifestOptionsInfo options) { string manifestDirectory = PathHelper.GetNormalizedDirectory(manifestPath); Manifest model = LoadModel(manifestPath, manifestDirectory); model.Validate(manifestDirectory); ManifestInfo manifestInfo = new ManifestInfo { Model = model, Registry = options.RegistryOverride ?? model.Registry, Directory = manifestDirectory }; manifestInfo.VariableHelper = new VariableHelper(model, options, manifestInfo.GetRepoById); manifestInfo.AllRepos = manifestInfo.Model.Repos .Select(repo => RepoInfo.Create( repo, manifestInfo.Registry, model.Registry, manifestFilter, options, manifestInfo.VariableHelper, manifestInfo.Directory)) .ToArray(); if (model.Readme != null) { manifestInfo.ReadmePath = Path.Combine(manifestInfo.Directory, model.Readme.Path); if (model.Readme.TemplatePath != null) { manifestInfo.ReadmeTemplatePath = Path.Combine(manifestInfo.Directory, model.Readme.TemplatePath); } } IEnumerable <string> repoNames = manifestInfo.AllRepos.Select(repo => repo.QualifiedName).ToArray(); foreach (PlatformInfo platform in manifestInfo.GetAllPlatforms()) { platform.Initialize(repoNames, manifestInfo.Registry); } IEnumerable <Repo> filteredRepoModels = manifestFilter.GetRepos(manifestInfo.Model); manifestInfo.FilteredRepos = manifestInfo.AllRepos .Where(repo => filteredRepoModels.Contains(repo.Model)) .ToArray(); return(manifestInfo); }
public static ManifestInfo Create(Manifest model, ManifestFilter manifestFilter, IOptionsInfo options) { ManifestInfo manifestInfo = new ManifestInfo(); manifestInfo.Model = model; manifestInfo.ManifestFilter = manifestFilter; manifestInfo.VariableHelper = new VariableHelper(model, options, manifestInfo.GetTagById); manifestInfo.Repos = manifestFilter.GetRepos(manifestInfo.Model) .Select(repo => RepoInfo.Create(repo, manifestFilter, options, manifestInfo.VariableHelper)) .ToArray(); manifestInfo.ActiveImages = manifestInfo.Repos .SelectMany(repo => repo.Images) .Where(image => image.ActivePlatforms.Any()) .ToArray(); return(manifestInfo); }
private static ManifestInfo Create(string manifestPath, ManifestFilter manifestFilter, IManifestOptionsInfo options) { string manifestJson = File.ReadAllText(manifestPath); Manifest model = JsonConvert.DeserializeObject <Manifest>(manifestJson); string manifestDirectory = PathHelper.GetNormalizedDirectory(manifestPath); model.Validate(manifestDirectory); ManifestInfo manifestInfo = new ManifestInfo { Model = model, Registry = options.RegistryOverride ?? model.Registry, Directory = manifestDirectory }; manifestInfo.VariableHelper = new VariableHelper(model, options, manifestInfo.GetRepoById); manifestInfo.AllRepos = manifestInfo.Model.Repos .Select(repo => RepoInfo.Create( repo, manifestInfo.Registry, model.Registry, manifestFilter, options, manifestInfo.VariableHelper, manifestInfo.Directory)) .ToArray(); IEnumerable <string> repoNames = manifestInfo.AllRepos.Select(repo => repo.QualifiedName).ToArray(); foreach (PlatformInfo platform in manifestInfo.GetAllPlatforms()) { platform.Initialize(repoNames, manifestInfo.Registry); } IEnumerable <Repo> filteredRepoModels = manifestFilter.GetRepos(manifestInfo.Model); manifestInfo.FilteredRepos = manifestInfo.AllRepos .Where(repo => filteredRepoModels.Contains(repo.Model)) .ToArray(); return(manifestInfo); }
public static ManifestInfo Create(Manifest model, ManifestFilter manifestFilter, string repoOwner) { ManifestInfo manifestInfo = new ManifestInfo(); manifestInfo.Model = model; manifestInfo.Repos = manifestFilter.GetRepos(manifestInfo.Model) .Select(repo => RepoInfo.Create(repo, manifestInfo.Model, manifestFilter, repoOwner)) .ToArray(); manifestInfo.Images = manifestInfo.Repos .SelectMany(repo => repo.Images) .ToArray(); manifestInfo.ActiveImages = manifestInfo.Images .Where(image => image.ActivePlatform != null) .ToArray(); manifestInfo.ActivePlatformFullyQualifiedTags = manifestInfo.ActiveImages .SelectMany(image => image.ActivePlatform.Tags) .Select(tag => tag.FullyQualifiedName) .ToArray(); manifestInfo.TestCommands = manifestFilter.GetTestCommands(manifestInfo.Model); return(manifestInfo); }
public IEnumerable <string> GetTestCommands() { return(ManifestFilter.GetTestCommands(Model) .Select(command => VariableHelper.SubstituteValues(command))); }
public static ImageInfo Create(Image model, Manifest manifest, string repoName, ManifestFilter manifestFilter) { 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, manifest, repoName)) .ToArray(); } imageInfo.Platforms = manifestFilter.GetPlatforms(model) .Select(platform => PlatformInfo.Create(platform, manifest, repoName)) .ToArray(); Platform activePlatformModel = manifestFilter.GetActivePlatform(model); if (activePlatformModel != null) { imageInfo.ActivePlatform = imageInfo.Platforms .First(platform => platform.Model == activePlatformModel); imageInfo.ActiveFullyQualifiedTags = imageInfo.SharedTags .Select(tag => tag.FullyQualifiedName) .Concat(imageInfo.ActivePlatform.Tags.Select(tag => tag.FullyQualifiedName)); } return(imageInfo); }