Пример #1
0
 internal InitContainerDefinitionContent(string name, string image, IList<string> command, IList<EnvironmentVariable> environmentVariables, InitContainerPropertiesDefinitionInstanceView instanceView, IList<VolumeMount> volumeMounts)
 {
     Name = name;
     Image = image;
     Command = command;
     EnvironmentVariables = environmentVariables;
     InstanceView = instanceView;
     VolumeMounts = volumeMounts;
 }
Пример #2
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)));
        }