Example #1
0
        internal static OCIManifest DeserializeOCIManifest(JsonElement element)
        {
            Optional <Descriptor> config = default;
            Optional <IReadOnlyList <Descriptor> > layers = default;
            Optional <Annotations> annotations            = default;
            int    schemaVersion = default;
            string mediaType     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("config"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    config = Descriptor.DeserializeDescriptor(property.Value);
                    continue;
                }
                if (property.NameEquals("layers"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Descriptor> array = new List <Descriptor>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Descriptor.DeserializeDescriptor(item));
                    }
                    layers = array;
                    continue;
                }
                if (property.NameEquals("annotations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        annotations = null;
                        continue;
                    }
                    annotations = Annotations.DeserializeAnnotations(property.Value);
                    continue;
                }
                if (property.NameEquals("schemaVersion"))
                {
                    schemaVersion = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("mediaType"))
                {
                    mediaType = property.Value.GetString();
                    continue;
                }
            }
            return(new OCIManifest(schemaVersion, mediaType, config.Value, Optional.ToList(layers), annotations.Value));
        }
Example #2
0
        internal static Descriptor DeserializeDescriptor(JsonElement element)
        {
            Optional <string> mediaType                    = default;
            Optional <long>   size                         = default;
            Optional <string> digest                       = default;
            Optional <IReadOnlyList <string> > urls        = default;
            Optional <Annotations>             annotations = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("mediaType"))
                {
                    mediaType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("size"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    size = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("digest"))
                {
                    digest = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("urls"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    urls = array;
                    continue;
                }
                if (property.NameEquals("annotations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        annotations = null;
                        continue;
                    }
                    annotations = Annotations.DeserializeAnnotations(property.Value);
                    continue;
                }
            }
            return(new Descriptor(mediaType.Value, Optional.ToNullable(size), digest.Value, Optional.ToList(urls), annotations.Value));
        }
Example #3
0
        internal static OCIIndex DeserializeOCIIndex(JsonElement element)
        {
            Optional <IReadOnlyList <ManifestListAttributes> > manifests = default;
            Optional <Annotations> annotations = default;
            int    schemaVersion = default;
            string mediaType     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("manifests"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ManifestListAttributes> array = new List <ManifestListAttributes>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ManifestListAttributes.DeserializeManifestListAttributes(item));
                    }
                    manifests = array;
                    continue;
                }
                if (property.NameEquals("annotations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        annotations = null;
                        continue;
                    }
                    annotations = Annotations.DeserializeAnnotations(property.Value);
                    continue;
                }
                if (property.NameEquals("schemaVersion"))
                {
                    schemaVersion = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("mediaType"))
                {
                    mediaType = property.Value.GetString();
                    continue;
                }
            }
            return(new OCIIndex(schemaVersion, mediaType, Optional.ToList(manifests), annotations.Value));
        }
Example #4
0
        internal static ManifestWrapper DeserializeManifestWrapper(JsonElement element)
        {
            Optional <IReadOnlyList <ManifestListAttributes> > manifests = default;
            Optional <Descriptor> config = default;
            Optional <IReadOnlyList <Descriptor> > layers = default;
            Optional <Annotations> annotations            = default;
            Optional <string>      architecture           = default;
            Optional <string>      name = default;
            Optional <string>      tag  = default;
            Optional <IReadOnlyList <FsLayer> >        fsLayers   = default;
            Optional <IReadOnlyList <History> >        history    = default;
            Optional <IReadOnlyList <ImageSignature> > signatures = default;
            int    schemaVersion = default;
            string mediaType     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("manifests"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ManifestListAttributes> array = new List <ManifestListAttributes>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ManifestListAttributes.DeserializeManifestListAttributes(item));
                    }
                    manifests = array;
                    continue;
                }
                if (property.NameEquals("config"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    config = Descriptor.DeserializeDescriptor(property.Value);
                    continue;
                }
                if (property.NameEquals("layers"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Descriptor> array = new List <Descriptor>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Descriptor.DeserializeDescriptor(item));
                    }
                    layers = array;
                    continue;
                }
                if (property.NameEquals("annotations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        annotations = null;
                        continue;
                    }
                    annotations = Annotations.DeserializeAnnotations(property.Value);
                    continue;
                }
                if (property.NameEquals("architecture"))
                {
                    architecture = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tag"))
                {
                    tag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("fsLayers"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <FsLayer> array = new List <FsLayer>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(FsLayer.DeserializeFsLayer(item));
                    }
                    fsLayers = array;
                    continue;
                }
                if (property.NameEquals("history"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <History> array = new List <History>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Models.History.DeserializeHistory(item));
                    }
                    history = array;
                    continue;
                }
                if (property.NameEquals("signatures"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ImageSignature> array = new List <ImageSignature>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ImageSignature.DeserializeImageSignature(item));
                    }
                    signatures = array;
                    continue;
                }
                if (property.NameEquals("schemaVersion"))
                {
                    schemaVersion = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("mediaType"))
                {
                    mediaType = property.Value.GetString();
                    continue;
                }
            }
            return(new ManifestWrapper(schemaVersion, mediaType, Optional.ToList(manifests), config.Value, Optional.ToList(layers), annotations.Value, architecture.Value, name.Value, tag.Value, Optional.ToList(fsLayers), Optional.ToList(history), Optional.ToList(signatures)));
        }