Merge pull request #123 from Kukks/feature/exclude-fragments

Introduce Exclude Fragments option
This commit is contained in:
Nicolas Dorier
2019-04-08 17:37:46 +09:00
committed by GitHub
6 changed files with 18 additions and 1 deletions

View File

@@ -27,6 +27,11 @@ namespace DockerGenerator
get;
set;
} = new string[0];
public string[] ExcludeFragments
{
get;
set;
} = new string[0];
public static DockerComposition FromEnvironmentVariables()
{
@@ -46,6 +51,11 @@ namespace DockerGenerator
.Where(t => !string.IsNullOrWhiteSpace(t))
.Select(t => t.EndsWith(".yml") ? t.Substring(0, t.Length - ".yml".Length) : t)
.ToArray();
composition.ExcludeFragments = (Environment.GetEnvironmentVariable("BTCPAYGEN_EXCLUDE_FRAGMENTS") ?? "").ToLowerInvariant()
.Split(new char[] { ';' , ',' })
.Where(t => !string.IsNullOrWhiteSpace(t))
.Select(t => t.EndsWith(".yml") ? t.Substring(0, t.Length - ".yml".Length) : t)
.ToArray();
return composition;
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -72,6 +72,7 @@ namespace DockerGenerator
{
fragments.Add(fragment.Trim());
}
fragments = fragments.Where(s => !composition.ExcludeFragments.Contains(s)).ToHashSet();
var def = new DockerComposeDefinition(name, fragments.ToList());
def.FragmentLocation = fragmentLocation;
def.BuildOutputDirectory = output;