private static void ValidateApplicationTier(Runbook runbook, ConDepSettings settings) { var hasTier = runbook.GetType().GetCustomAttributes(typeof(TierAttribute), false).Any(); if (!hasTier) throw new ConDepNoRunbookTierDefinedException(runbook, settings); var hasSingleTier = runbook.GetType().GetCustomAttributes(typeof(TierAttribute), false).SingleOrDefault() != null; if (!hasSingleTier) throw new ConDepNoRunbookTierDefinedException(String.Format("Multiple tiers defined for {0}. Only one tier is allowed by Artifact.", runbook.GetType().Name)); }
public bool HasDependenciesDefined(Runbook artifact) { var typeName = typeof(IDependOn <>).Name; var interfaces = artifact.GetType().GetInterfaces(); return(interfaces.Any(x => x.Name == typeName)); }
public ConDepNoRunbookTierDefinedException(Runbook application, ConDepSettings settings) : base(string.Format("No Tiers defined for application {0}. You need to specify a tier using the {1} attribute on the {0} class. Tiers available in your configuration are {2}.", application.GetType().Name, typeof(TierAttribute).Name, string.Join(", ", settings.Config.Tiers.Select(x => x.Name)))) { }
public ConDepNoRunbookTierDefinedException(Runbook application, ConDepSettings settings) : base(string.Format("No Tiers defined for application {0}. You need to specify a tier using the {1} attribute on the {0} class. Tiers available in your configuration are {2}.", application.GetType().Name, typeof(TierAttribute).Name, string.Join(", ", settings.Config.Tiers.Select(x => x.Name)))) { }
private static void ValidateApplicationTier(Runbook runbook, ConDepSettings settings) { var hasTier = runbook.GetType().GetCustomAttributes(typeof(TierAttribute), false).Any(); if (!hasTier) { throw new ConDepNoRunbookTierDefinedException(runbook, settings); } var hasSingleTier = runbook.GetType().GetCustomAttributes(typeof(TierAttribute), false).SingleOrDefault() != null; if (!hasSingleTier) { throw new ConDepNoRunbookTierDefinedException(String.Format("Multiple tiers defined for {0}. Only one tier is allowed by Artifact.", runbook.GetType().Name)); } }
public IEnumerable<ServerConfig> GetServers(Runbook runbook, ConDepSettings settings) { if (settings.Config.UsingTiers) { ValidateApplicationTier(runbook, settings); var tier = runbook.GetType().GetCustomAttributes(typeof(TierAttribute), false).Single() as TierAttribute; if (!settings.Config.Tiers.Exists(tier.TierName)) { throw new ConDepTierDoesNotExistInConfigException(string.Format("Tier {0} does not exist in {1}.env.config", tier.TierName, settings.Options.Environment)); } return settings.Config.Tiers.Single(x => x.Name.Equals(tier.TierName, StringComparison.OrdinalIgnoreCase)) .Servers; } return settings.Config.Servers; }
public IEnumerable <ServerConfig> GetServers(Runbook runbook, ConDepSettings settings) { if (settings.Config.UsingTiers) { ValidateApplicationTier(runbook, settings); var tier = runbook.GetType().GetCustomAttributes(typeof(TierAttribute), false).Single() as TierAttribute; if (!settings.Config.Tiers.Exists(tier.TierName)) { throw new ConDepTierDoesNotExistInConfigException(string.Format("Tier {0} does not exist in {1}.env.config", tier.TierName, settings.Options.Environment)); } return (settings.Config.Tiers.Single(x => x.Name.Equals(tier.TierName, StringComparison.OrdinalIgnoreCase)) .Servers); } return(settings.Config.Servers); }
//public void PopulateWithDependencies(Runbook runbook, ConDepSettings settings) //{ // if (!HasDependenciesDefined(runbook)) return; // runbook.Dependencies = GetDependeciesForRunbook(runbook, settings); //} public List <Runbook> GetDependeciesForRunbook(Runbook runbook, ConDepSettings settings) { var typeName = typeof(IDependOn <>).Name; var typeInterfaces = runbook.GetType().GetInterfaces(); var dependencies = typeInterfaces.Where(x => x.Name == typeName); var dependencyInstances = new List <Runbook>(); foreach (var infraInterface in dependencies) { var dependencyType = infraInterface.GetGenericArguments().Single(); var dependencyInstance = settings.Options.Assembly.CreateInstance(dependencyType.FullName) as Runbook; dependencyInstances.AddRange(new RunbookDependencyHandler().GetDependeciesForRunbook(dependencyInstance, settings)); dependencyInstances.Add(dependencyInstance); } return(dependencyInstances); }
//public void PopulateWithDependencies(Runbook runbook, ConDepSettings settings) //{ // if (!HasDependenciesDefined(runbook)) return; // runbook.Dependencies = GetDependeciesForRunbook(runbook, settings); //} public List<Runbook> GetDependeciesForRunbook(Runbook runbook, ConDepSettings settings) { var typeName = typeof(IDependOn<>).Name; var typeInterfaces = runbook.GetType().GetInterfaces(); var dependencies = typeInterfaces.Where(x => x.Name == typeName); var dependencyInstances = new List<Runbook>(); foreach (var infraInterface in dependencies) { var dependencyType = infraInterface.GetGenericArguments().Single(); var dependencyInstance = settings.Options.Assembly.CreateInstance(dependencyType.FullName) as Runbook; dependencyInstances.AddRange(new RunbookDependencyHandler().GetDependeciesForRunbook(dependencyInstance, settings)); dependencyInstances.Add(dependencyInstance); } return dependencyInstances; }
public bool HasDependenciesDefined(Runbook artifact) { var typeName = typeof(IDependOn<>).Name; var interfaces = artifact.GetType().GetInterfaces(); return interfaces.Any(x => x.Name == typeName); }