Пример #1
0
        internal static InitContainerDefinitionContent DeserializeInitContainerDefinitionContent(JsonElement element)
        {
            string                     name    = default;
            Optional <string>          image   = default;
            Optional <IList <string> > command = default;
            Optional <IList <EnvironmentVariable> > environmentVariables          = default;
            Optional <InitContainerPropertiesDefinitionInstanceView> instanceView = default;
            Optional <IList <VolumeMount> > volumeMounts = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("image"))
                        {
                            image = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("command"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            command = array;
                            continue;
                        }
                        if (property0.NameEquals("environmentVariables"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <EnvironmentVariable> array = new List <EnvironmentVariable>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(EnvironmentVariable.DeserializeEnvironmentVariable(item));
                            }
                            environmentVariables = array;
                            continue;
                        }
                        if (property0.NameEquals("instanceView"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            instanceView = InitContainerPropertiesDefinitionInstanceView.DeserializeInitContainerPropertiesDefinitionInstanceView(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("volumeMounts"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <VolumeMount> array = new List <VolumeMount>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(VolumeMount.DeserializeVolumeMount(item));
                            }
                            volumeMounts = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new InitContainerDefinitionContent(name, image.Value, Optional.ToList(command), Optional.ToList(environmentVariables), instanceView.Value, Optional.ToList(volumeMounts)));
        }
Пример #2
0
        internal static ContainerInstanceContainer DeserializeContainerInstanceContainer(JsonElement element)
        {
            string name  = default;
            string image = default;
            Optional <IList <string> >                 command = default;
            Optional <IList <ContainerPort> >          ports   = default;
            Optional <IList <EnvironmentVariable> >    environmentVariables = default;
            Optional <ContainerPropertiesInstanceView> instanceView         = default;
            ResourceRequirements            resources      = default;
            Optional <IList <VolumeMount> > volumeMounts   = default;
            Optional <ContainerProbe>       livenessProbe  = default;
            Optional <ContainerProbe>       readinessProbe = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("image"))
                        {
                            image = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("command"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            command = array;
                            continue;
                        }
                        if (property0.NameEquals("ports"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ContainerPort> array = new List <ContainerPort>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ContainerPort.DeserializeContainerPort(item));
                            }
                            ports = array;
                            continue;
                        }
                        if (property0.NameEquals("environmentVariables"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <EnvironmentVariable> array = new List <EnvironmentVariable>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(EnvironmentVariable.DeserializeEnvironmentVariable(item));
                            }
                            environmentVariables = array;
                            continue;
                        }
                        if (property0.NameEquals("instanceView"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            instanceView = ContainerPropertiesInstanceView.DeserializeContainerPropertiesInstanceView(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("resources"))
                        {
                            resources = ResourceRequirements.DeserializeResourceRequirements(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("volumeMounts"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <VolumeMount> array = new List <VolumeMount>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(VolumeMount.DeserializeVolumeMount(item));
                            }
                            volumeMounts = array;
                            continue;
                        }
                        if (property0.NameEquals("livenessProbe"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            livenessProbe = ContainerProbe.DeserializeContainerProbe(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("readinessProbe"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            readinessProbe = ContainerProbe.DeserializeContainerProbe(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ContainerInstanceContainer(name, image, Optional.ToList(command), Optional.ToList(ports), Optional.ToList(environmentVariables), instanceView.Value, resources, Optional.ToList(volumeMounts), livenessProbe.Value, readinessProbe.Value));
        }