public static EnvironmentSettings ReadFrom(string environmentFile) { var environment = new EnvironmentSettings(); new FileSystem().ReadTextFile(environmentFile, environment.ReadText); return environment; }
public static HostManifest ReadFrom(string fileName, EnvironmentSettings environment) { var parser = new SettingsParser(fileName, environment.Overrides.ToDictionary()); new FileSystem().ReadTextFile(fileName, parser.ParseText); var hostName = Path.GetFileNameWithoutExtension(fileName); var host = new HostManifest(hostName); var settings = parser.Settings; host.RegisterSettings(settings); host.RegisterBottles(parser.References); return host; }
public static Recipe ReadFrom(string recipeDirectory, EnvironmentSettings environment) { var recipeName = Path.GetFileName(recipeDirectory); var recipe = new Recipe(recipeName); var fileSystem = new FileSystem(); fileSystem.ReadTextFile(FileSystem.Combine(recipeDirectory, ProfileFiles.RecipesControlFile), s => { //TODO: Harden this for bad syntax var parts = s.Split(':'); recipe.RegisterDependency(parts[1]); }); fileSystem.FindFiles(recipeDirectory, new FileSet(){ Include = "*.host" }).Each(file => { var host = HostReader.ReadFrom(file, environment); recipe.RegisterHost(host); }); return recipe; }
public void SetUp() { var writer = new DeploymentWriter("starwars"); var recipeDefinition = writer.RecipeFor("r1"); var host = recipeDefinition.HostFor("h1"); host.AddDirective(new SimpleSettings { One = "one", Two = "two" }); host.AddDirective(new OneSettings() { Name = "Jeremy", Age = 37 }); host.AddReference(new BottleReference() { Name = "bottle1" }); host.AddReference(new BottleReference() { Name = "bottle2" }); recipeDefinition.HostFor("h2").AddProperty<ThreeSettings>(x => x.Direction, "North"); recipeDefinition.HostFor("h3").AddProperty<TwoSettings>(x => x.City, "Austin"); writer.RecipeFor("r2").HostFor("h3").AddProperty<SimpleSettings>(x => x.One, "one"); writer.RecipeFor("r3").HostFor("h3").AddProperty<SimpleSettings>(x => x.Two, "two"); writer.RecipeFor("r4").HostFor("h4").AddProperty<SimpleSettings>(x => x.Two, "ten"); writer.RecipeFor("r4").HostFor("h5").AddProperty<SimpleSettings>(x => x.Two, "ten"); writer.RecipeFor("r4").HostFor("h5").AddProperty<SimpleSettings>(x => x.One, "setting is {setting}"); writer.Flush(FlushOptions.Wipeout); var environmentSettings = new EnvironmentSettings(); environmentSettings.Overrides["setting"] = "environment setting"; theRecipes = RecipeReader.ReadRecipes("starwars\\recipes", environmentSettings); }
public static IEnumerable<Recipe> ReadRecipes(string recipesDir, EnvironmentSettings environment) { return Directory.GetDirectories(recipesDir).Select(dir => ReadFrom(dir, environment)); }
public void SetUp() { theEnvironmentSettings = new EnvironmentSettings(); }
private static void addEnvironmentSettingsToHosts(EnvironmentSettings environment, IEnumerable<HostManifest> hosts) { hosts.Each(host => host.RegisterSettings(environment.DataForHost(host.Name))); }