Ejemplo n.º 1
0
        public static Profile ReadFrom(DeploymentSettings settings, string profileName, string settingsProfileName = null)
        {
            var profile = new Profile(profileName);
            var profileFile = settings.ProfileFileNameFor(profileName);

            var fileSystem = new FileSystem();
            if (!fileSystem.FileExists(profileFile))
            {
                var sb = new StringBuilder();
                sb.AppendFormat("Couldn't find the profile '{0}'", profileFile);
                sb.AppendLine();
                sb.AppendLine("Looked in:");
                settings.Directories.Each(d => sb.AppendLine("  {0}".ToFormat(d)));

                throw new Exception(sb.ToString());
            }

            // Settings profile goes first
            if (settingsProfileName != null)
            {
                profile.AddProfileDependency(settingsProfileName);
            }

            fileSystem.ReadTextFile(profileFile, profile.ReadText);

            profile._childProfileNames.Each(childName =>
                {
                    var childProfile = ReadFrom(settings, childName);
                    profile._childProfiles.Add(childProfile);
                    childProfile.Data.AllKeys.Each(childKey =>
                        {
                            // do not override main profile settings from dependencies.
                            // NOTE: Has(childKey) doesn't work here because SettingsData has a weird inner dictionary with a special key structure
                            if (profile.Data.AllKeys.Any(k => k == childKey)) return;

                            profile.Data[childKey] = childProfile.Data[childKey];
                        });
                });

            return profile;
        }
Ejemplo n.º 2
0
        public static Profile ReadFrom(DeploymentSettings settings, string profileName)
        {
            var profile = new Profile(profileName);
            var profileFile = settings.ProfileFileNameFor(profileName);

            var fileSystem = new FileSystem();
            if (!fileSystem.FileExists(profileFile))
            {
                var sb = new StringBuilder();
                sb.AppendFormat("Couldn't find the profile '{0}'", profileFile);
                sb.AppendLine();
                sb.AppendLine("Looked in:");
                settings.Directories.Each(d => sb.AppendLine("  {0}".ToFormat(d)));

                throw new Exception(sb.ToString());
            }

            fileSystem.ReadTextFile(profileFile, profile.ReadText);

            return profile;
        }
        public void HostManifest_can_create_all_directives_for_itself()
        {
            var host = new HostManifest("h1");
            host.RegisterValue<BottleDeployers1.OneDirective>(x => x.Age, 11);
            host.RegisterValue<BottleDeployers1.OneDirective>(x => x.Name, "Robert");

            host.RegisterValue<BottleDeployers2.SixDirective>(x => x.Direction, "North");
            host.RegisterValue<BottleDeployers2.SixDirective>(x => x.Threshold, 5);

            var registry = theContainer.GetInstance<DirectiveTypeRegistry>();

            var factory = theContainer.GetInstance<DirectiveRunnerFactory>();

            var profile = new Profile("profile1");
            profile.AddRecipe("something");

            var plan = new DeploymentPlan(new DeploymentOptions(), new DeploymentGraph(){
                Environment = new EnvironmentSettings(),
                Profile = profile,
                Recipes = new Recipe[]{new Recipe("something"), },
                Settings = new DeploymentSettings()

            });

            factory.BuildDirectives(plan, host, registry);
            var directives = host.Directives;

            directives.Count().ShouldEqual(2);
            var directiveOne = directives.OfType<BottleDeployers1.OneDirective>().Single();
            directiveOne.Age.ShouldEqual(11);
            directiveOne.Name.ShouldEqual("Robert");

            var directiveSix = directives.OfType<SixDirective>().Single();
            directiveSix.Direction.ShouldEqual("North");
            directiveSix.Threshold.ShouldEqual(5);
        }
Ejemplo n.º 4
0
 public void SetUp()
 {
     theProfile = new Profile("something");
 }
 private void readDotProfileFile()
 {
     var settings = new DeploymentSettings(_deploymentFolderPath);
     _theProfile = Profile.ReadFrom(settings, "main", "mainsettings");
 }
Ejemplo n.º 6
0
        public void SetUp()
        {
            theEnvironment = new EnvironmentSettings();
            theEnvironment.Data["Env1"] = "Env1-Val";
            theEnvironment.Data["Shared"] = "Shared-Env-Val";

            theProfile = new Profile("profile1");
            theProfile.AddRecipe("something");

            theProfile.Data["Shared"] = "Shared-Profile-Val";
            theProfile.Data["Profile1"] = "Profile1-Val";

            theRecipes = new Recipe[] { new Recipe("something"), };
        }