Ejemplo n.º 1
0
        private static void HandleIngressMapping(YamlMappingNode yamlMappingNode, ConfigIngress configIngress)
        {
            foreach (var child in yamlMappingNode !.Children)
            {
                var key = YamlParser.GetScalarValue(child.Key);

                switch (key)
                {
                case "name":
                    configIngress.Name = YamlParser.GetScalarValue(key, child.Value).ToLowerInvariant();
                    break;

                case "replicas":
                    if (!int.TryParse(YamlParser.GetScalarValue(key, child.Value), out var replicas))
                    {
                        throw new TyeYamlException(child.Value.Start, CoreStrings.FormatMustBeAnInteger(key));
                    }

                    if (replicas < 0)
                    {
                        throw new TyeYamlException(child.Value.Start, CoreStrings.FormatMustBePositive(key));
                    }

                    configIngress.Replicas = replicas;
                    break;

                case "rules":
                    if (child.Value.NodeType != YamlNodeType.Sequence)
                    {
                        throw new TyeYamlException(child.Value.Start, CoreStrings.FormatExpectedYamlSequence(key));
                    }
                    HandleIngressRules((child.Value as YamlSequenceNode) !, configIngress.Rules);
                    break;

                case "bindings":
                    if (child.Value.NodeType != YamlNodeType.Sequence)
                    {
                        throw new TyeYamlException(child.Value.Start, CoreStrings.FormatExpectedYamlSequence(key));
                    }
                    HandleIngressBindings((child.Value as YamlSequenceNode) !, configIngress.Bindings);
                    break;

                case "tags":
                    if (child.Value.NodeType != YamlNodeType.Sequence)
                    {
                        throw new TyeYamlException(child.Value.Start, CoreStrings.FormatExpectedYamlSequence(key));
                    }

                    HandleIngressTags((child.Value as YamlSequenceNode) !, configIngress.Tags);
                    break;

                default:
                    throw new TyeYamlException(child.Key.Start, CoreStrings.FormatUnrecognizedKey(key));
                }
            }
        }
Ejemplo n.º 2
0
 public static void HandleIngress(YamlSequenceNode yamlSequenceNode, List <ConfigIngress> ingress)
 {
     foreach (var child in yamlSequenceNode.Children)
     {
         YamlParser.ThrowIfNotYamlMapping(child);
         var configIngress = new ConfigIngress();
         HandleIngressMapping((YamlMappingNode)child, configIngress);
         ingress.Add(configIngress);
     }
 }