In our code, we have a construct like this, that takes an IEnumerable<VariableResource>
and tries to figure out which one is applicable given a specific environment:
var environmentId = "Environment-3"; // input to the function
var variables = GetAllVariablesForProject(); // fetches all project variables and all variables
// from linked library sets, and concats the lists
var scope = new Dictionary<ScopeField, ScopeValue>
{
{ ScopeField.Environment, new ScopeValue(environmentId) }
};
return variables
.Where(variable => variable.Scope.IsApplicableTo(scope))
.GroupBy(variable => variable.Name)
.Select(group => group.OrderByDescending(variable => variable.Scope.Rank()).First())
.ToDictionary(variable => variable.Name, variable => variable.Value);
However, it seems ScopeSpecification.IsApplicableTo
was removed in Octopus.Client 3.4.0. Is the functionality implemented somewhere else instead?