OCI Runtime, Image and Distribution Spec in Rust

Related tags

rust spec oci
Overview

oci-spec-rs

ci gh-pages crates.io codecov docs docs.rs dependencies license

Open Container Initiative (OCI) Specifications for Rust

This library provides a convenient way to interact with the specifications defined by the Open Container Initiative (OCI).

[dependencies]
oci-spec = "0.5.1"

Compiler support: requires rustc 1.54+

Image Format Spec Examples

  • Load image manifest from filesystem
use oci_spec::image::ImageManifest;

let image_manifest = ImageManifest::from_file("manifest.json").unwrap();
assert_eq!(image_manifest.layers().len(), 5);
  • Create new image manifest using builder
= [ ( 32654, "sha256:9834876dcfb05cb167a5c24953eba58c4ac89b1adf57f28f2f9d09af107ee8f0", ), ( 16724, "sha256:3c3a4604a545cdc127456d94e421cd355bca5b528f4a9c1905b15da2eb4a4c6b", ), ( 73109, "sha256:ec4b8955958665577945c89419d1af06b5f7636b4ac3da7f12184802ad867736", ), ] .iter() .map(|l| { DescriptorBuilder::default() .media_type(MediaType::ImageLayerGzip) .size(l.0) .digest(l.1.to_owned()) .build() .expect("build layer") }) .collect(); let image_manifest = ImageManifestBuilder::default() .schema_version(SCHEMA_VERSION) .config(config) .layers(layers) .build() .expect("build image manifest"); image_manifest.to_file_pretty("my-manifest.json").unwrap(); ">
use oci_spec::image::{
    Descriptor, 
    DescriptorBuilder, 
    ImageManifest, 
    ImageManifestBuilder, 
    MediaType, 
    SCHEMA_VERSION
};

let config = DescriptorBuilder::default()
            .media_type(MediaType::ImageConfig)
            .size(7023)
            .digest("sha256:b5b2b2c507a0944348e0303114d8d93aaaa081732b86451d9bce1f432a537bc7")
            .build()
            .expect("build config descriptor");

let layers: Vec<Descriptor> = [
    (
        32654,
        "sha256:9834876dcfb05cb167a5c24953eba58c4ac89b1adf57f28f2f9d09af107ee8f0",
    ),
    (
        16724,
        "sha256:3c3a4604a545cdc127456d94e421cd355bca5b528f4a9c1905b15da2eb4a4c6b",
    ),
    (
        73109,
        "sha256:ec4b8955958665577945c89419d1af06b5f7636b4ac3da7f12184802ad867736",
    ),
]
    .iter()
    .map(|l| {
    DescriptorBuilder::default()
        .media_type(MediaType::ImageLayerGzip)
        .size(l.0)
        .digest(l.1.to_owned())
        .build()
        .expect("build layer")
    })
    .collect();

let image_manifest = ImageManifestBuilder::default()
    .schema_version(SCHEMA_VERSION)
    .config(config)
    .layers(layers)
    .build()
    .expect("build image manifest");

image_manifest.to_file_pretty("my-manifest.json").unwrap();
  • Content of my-manifest.json
{
  "schemaVersion": 2,
  "config": {
    "mediaType": "application/vnd.oci.image.config.v1+json",
    "digest": "sha256:b5b2b2c507a0944348e0303114d8d93aaaa081732b86451d9bce1f432a537bc7",
    "size": 7023
  },
  "layers": [
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
      "digest": "sha256:9834876dcfb05cb167a5c24953eba58c4ac89b1adf57f28f2f9d09af107ee8f0",
      "size": 32654
    },
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
      "digest": "sha256:3c3a4604a545cdc127456d94e421cd355bca5b528f4a9c1905b15da2eb4a4c6b",
      "size": 16724
    },
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
      "digest": "sha256:ec4b8955958665577945c89419d1af06b5f7636b4ac3da7f12184802ad867736",
      "size": 73109
    }
  ]
}

Distribution Spec Examples

  • Create a list of repositories
use oci_spec::distribution::RepositoryListBuilder;

let list = RepositoryListBuilder::default()
            .repositories(vec!["busybox".to_owned()])
            .build().unwrap();

Contributing

This project welcomes your PRs and issues. Should you wish to work on an issue, please claim it first by commenting on the issue that you want to work on it. This is to prevent duplicated efforts from contributers on the same issue.

Issues
  • Setup CI

    Setup CI

    I think we should set up a basic CI pipeline for the crate, which does:

    • [x] build
    • [x] unit test including code coverage
    • [x] clippy lint
    • [x] rustfmt
    • [x] build docs and push to gh-pages branch
    • [x] crates.io publishing
    opened by saschagrunert 11
  • `ErrorInfo` detail field is object in registry responses

    `ErrorInfo` detail field is object in registry responses

    Although spec says that detail field in ErrorInfo is string with unstructured data it seems that all registries make detail field an object.

    For example, Dockerhub returns this for unknown manifest:

    {
        "errors": [
            {
                "code": "MANIFEST_UNKNOWN",
                "message": "manifest unknown",
                "detail": {
                    "Tag": "lates"
                }
            }
        ]
    }
    

    Quay:

    {
        "errors": [
            {
                "code": "MANIFEST_UNKNOWN",
                "detail": {},
                "message": "manifest unknown"
            }
        ]
    }
    

    Microsoft's MCR :

    {
        "errors": [
            {
                "code": "MANIFEST_UNKNOWN",
                "message": "manifest tagged by \"lates\" is not found",
                "detail": {
                    "Tag": "lates"
                }
            }
        ]
    }
    

    This results in failure to deserialize any of the above ErrorResponse structs.

    Is this the problem of registry implementers, this library or the spec itself?

    opened by petkovicdanilo 4
  • Add image spec

    Add image spec

    We should add the image spec to this repository as well. I am interested in working on this.

    opened by Furisto 3
  • Release 0.4.0

    Release 0.4.0

    I'll tag 3ff79a8 as 0.4.0 after this merges and publish it to crates.io.

    opened by saschagrunert 3
  • The type a of device was needed to mean All.

    The type a of device was needed to mean All.

    ref. https://github.com/containers/youki/pull/266#issuecomment-915201298

    opened by utam0k 3
  • Add OCI distribution spec

    Add OCI distribution spec

    Closes #21

    opened by saschagrunert 3
  • Implement image spec

    Implement image spec

    Solves #10. Another PR with additional tests will follow.

    opened by Furisto 3
  • Replace anyhow

    Replace anyhow

    The anyhow result type appears in our public api, which is not ideal. Should we switch to thiserror or write our own error types? What do you think?

    opened by Furisto 3
  • Remove nix dependency

    Remove nix dependency

    Now that the oci spec is decoupled from youki, we should not expose nix types as part of the api.

    opened by Furisto 3
  • Add rootless for spec

    Add rootless for spec

    null

    opened by chenyukang 23
Releases(v0.5.1)
Owner
Containers
Open Repository for Container Tools
Containers
A project for automatically generating and maintaining Debian repositories from a TOML spec.

Debian Repository Builder A simple utility for constructing and maintaining Debian repositories. Configuration of a repo is based on the directory hie

Pop!_OS 48 Aug 6, 2021
Parallel finance a decentralized lending protocol built on top of the Polkadot ecosystem. Our unique approach will allow users to earn "double interests" from staking and lending their tokens simultaneously.

Parallel Finance A new Cumulus-based Substrate node, ready for hacking ?? Getting Started Follow these steps to get started with the Cumulus Template

parallel-finance 34 Sep 18, 2021
minimalistic command launcher in rust

rrun Note: Apart from the occasional fix, this project is not actively developed anymore. rrun works fine and should run/compile for the time being on

null 96 Aug 8, 2021
Mirror of https://gitlab.redox-os.org/redox-os/ion

Introduction Ion is a modern system shell that features a simple, yet powerful, syntax. It is written entirely in Rust, which greatly increases the ov

Redox OS 1.2k Sep 15, 2021
A faster way to navigate your filesystem

zoxide A faster way to navigate your filesystem Table of contents Introduction Examples Getting started Step 1: Install zoxide Step 2: Install fzf (op

Ajeet D'Souza 3.7k Sep 13, 2021
The next gen ls command

LSD (LSDeluxe) Table of Contents Description Screenshot Installation Configuration External Configurations Required Optional F.A.Q. Contributors Credi

Pierre Peltier 6.3k Sep 19, 2021
A simple and fast download accelerator, written in Rust

zou A simple and fast download accelerator, written in Rust Zou is a Snatch fork by @k0pernicus. Snatch is a fast and interruptable download accelerat

Antonin Carette 162 Sep 15, 2021
Your project’s nix-env [[email protected]]

lorri https://github.com/nix-community/lorri lorri is a nix-shell replacement for project development. lorri is based around fast direnv integration f

Nix community projects 128 Sep 11, 2021
Basic system information fetcher, with a focus on performance.

Table of Contents: About Changelog Dependencies Benchmarks Features Installation Platform Support About Macchina Macchina lets you view basic system i

null 214 Sep 14, 2021
Multiple USB File Flasher

Popsicle Popsicle is a Linux utility for flashing multiple USB devices in parallel, written in Rust. Build Dependencies If building the GTK front end,

Pop!_OS 337 Aug 29, 2021
Cross-platform Rust rewrite of the GNU coreutils

uutils coreutils uutils is an attempt at writing universal (as in cross-platform) CLI utilities in Rust. This repository is intended to aggregate GNU

null 9k Sep 13, 2021
Fuzzy Finder in rust!

Life is short, skim! Half of our life is spent on navigation: files, lines, commands… You need skim! It is a general fuzzy finder that saves you time.

Jinzhou Zhang 2.8k Sep 16, 2021
A tool to simplify reprovisioning a fresh OS. Installs packages and manages dotfiles.

[[TOC]] Comtrya This is better, yes? Warning This tool is ridiculously early in its development. I'm building out features as I migrate my dotfiles ov

David McKay 1 Aug 12, 2021
A tool to simplify reprovisioning a fresh OS. Installs packages and manages dotfiles.

Comtrya This is better, yes? Warning This tool is ridiculously early in its development. I'm building out features as I migrate my dotfiles over. Thos

Comtrya 126 Sep 5, 2021
A safe and ergonomic alternative to rm

rip (Rm ImProved) rip is a command-line deletion tool focused on safety, ergonomics, and performance. It favors a simple interface, and does not imple

Kevin Liu 419 Sep 8, 2021
Synapse BitTorrent Daemon

synapse Synapse is a flexible and fast BitTorrent daemon. It currently supports most systems which implement epoll or kqueue, with a focus on 64-bit l

Ezra 745 Sep 1, 2021
Linux Kernel Manager and Activity Monitor 🐧💻

Linux Kernel Manager and Activity Monitor ?? ?? The kernel is the part of the operating system that facilitates interactions between hardware and soft

Orhun Parmaksız 1.3k Sep 14, 2021
This project now lives on in a rewrite at https://gitlab.redox-os.org/redox-os/parallel

MIT/Rust Parallel: A Command-line CPU Load Balancer Written in Rust This is an attempt at recreating the functionality of GNU Parallel, a work-stealer

Michael Murphy 1.2k Sep 6, 2021
Executes commands in response to file modifications

watchexec Software development often involves running the same commands over and over. Boring! watchexec is a simple, standalone tool that watches a p

null 2.5k Sep 18, 2021