Наследование: IVariableScopeValues
Пример #1
0
        public bool ShouldReturnVariable(VariableScopeValues scopeValues, VariableResource variable)
        {
            var scopes = BuildScopeMap(scopeValues, _filter);

            return variable
                .Scope
                .IsExcludedBy(scopes) == false;
        }
Пример #2
0
        public static Dictionary<ScopeField, ScopeValue> BuildScopeMap(VariableScopeValues scopeValues, FilterConfiguration filter)
        {
            var environments = MapScope(scopeValues.Environments, filter.Environments);
            var roles = MapScope(scopeValues.Roles, filter.Roles);
            var targets = MapScope(scopeValues.Machines, filter.Targets);

            return new Dictionary<ScopeField, ScopeValue>
            {
                { ScopeField.Environment , new ScopeValue(environments)},
                { ScopeField.Role , new ScopeValue(roles)},
                { ScopeField.Machine , new ScopeValue(targets)}
            };
        }
Пример #3
0
 VariableScopeValues UpdateScopeValues(IDictionary<string, EnvironmentResource> environments, IDictionary<string, MachineResource> machines, IDictionary<ScopeField, List<ReferenceDataItem>> scopeValuesUsed)
 {
     var scopeValues = new VariableScopeValues();
     Log.Debug("Updating the Environments of the Variable Sets Scope Values");
     scopeValues.Environments = new List<ReferenceDataItem>();
     foreach (var environment in scopeValuesUsed[ScopeField.Environment])
     {
         var newEnvironment = environments[environment.Id];
         scopeValues.Environments.Add(new ReferenceDataItem(newEnvironment.Id, newEnvironment.Name));
     }
     Log.Debug("Updating the Machines of the Variable Sets Scope Values");
     scopeValues.Machines = new List<ReferenceDataItem>();
     foreach (var machine in scopeValuesUsed[ScopeField.Machine])
     {
         var newMachine = machines[machine.Id];
         scopeValues.Machines.Add(new ReferenceDataItem(newMachine.Id, newMachine.Name));
     }
     return scopeValues;
 }
Пример #4
0
        protected Dictionary<ScopeField, List<ReferenceDataItem>> GetScopeValuesUsed(IList<VariableResource> variables, IList<DeploymentStepResource> steps, VariableScopeValues variableScopeValues)
        {
            var usedScopeValues = new Dictionary<ScopeField, List<ReferenceDataItem>>
            {
                {ScopeField.Environment, new List<ReferenceDataItem>()},
                {ScopeField.Machine, new List<ReferenceDataItem>()}
            };

            foreach (var variable in variables)
            {
                foreach (var variableScope in variable.Scope)
                {
                    switch (variableScope.Key)
                    {
                        case ScopeField.Environment:
                            var usedEnvironments = variableScope.Value;
                            foreach (var usedEnvironment in usedEnvironments)
                            {
                                var environment = variableScopeValues.Environments.Find(e => e.Id == usedEnvironment);
                                if (environment != null)
                                {
                                    usedScopeValues[ScopeField.Environment].Add(environment);
                                }
                            }
                            break;
                        case ScopeField.Machine:
                            var usedMachines = variableScope.Value;
                            foreach (var usedMachine in usedMachines)
                            {
                                var machine = variableScopeValues.Machines.Find(m => m.Id == usedMachine);
                                if (machine != null)
                                {
                                    usedScopeValues[ScopeField.Machine].Add(machine);
                                }
                            }
                            break;
                    }
                }
            }
            foreach (var step in steps)
            {
                foreach (var action in step.Actions)
                {
                    foreach (var usedEnvironment in action.Environments)
                    {
                        var environment = variableScopeValues.Environments.Find(e => e.Id == usedEnvironment);
                        if (environment != null && !usedScopeValues[ScopeField.Environment].Exists(env => env.Id == usedEnvironment))
                        {
                            usedScopeValues[ScopeField.Environment].Add(environment);
                        }
                    }
                }
            }

            return usedScopeValues;
        }
		private static IEnumerable<ReferenceDataItem> GetScopeValues(VariableScopeValues scopeValues, ScopeField scopeField)
		{
			switch (scopeField)
			{
				case ScopeField.Environment:
					return scopeValues.Environments;

				case ScopeField.Machine:
					return scopeValues.Machines;

				default:
					return new ReferenceDataItem[] { };
			}
		}