Handy little CLI for interacting with OCI data

oci-tool

Handy little CLI for interacting with OCI data

Installation

go get github.com/csweichel/oci-tool

I use Gitpod for developing this tool; you should, too :)

Open in Gitpod

Common Tasks

Note: using a $ref is by no means a requirement - it's just really handy for the examples.

Fetching raw data

When exploring a registry's content, starting with some raw data is handy.

export ref=docker.io/library/alpine:latest

# download the manifest or manifest list of a reference
oci-tool fetch raw $ref

# download a concrete platform manifest by interpreting the manifest list
export digest=$(oci-tool fetch raw docker.io/library/alpine:latest | jq -r .manifests[0].digest)
oci-tool fetch --digest $digest raw $ref

# download OCI image metadata (see next section for a quicker way of doing this)
export cfgdigest=$(oci-tool fetch --digest $digest raw $ref | jq .config.digest)
oci-tool fetch --digest $cfgdigest raw $ref

Fetching an image manifest, image and config

Note: If ref points to an index rather than a manifest, you can also use --digest instead of --platform and point to a specific manifest directly.

export ref=docker.io/library/alpine:latest

# fetch the image manifest (in case of alpine, it's an index instead of a manifest)
oci-tool fetch manifest $ref

# choose an actual manifest, e.g. the linux on amd64
oci-tool fetch manifest --platform=linux-amd64 $ref

# fetch the image config
oci-tool fetch iamge --platform=linux-amd64 $ref

Inspecting image layer

Note: If ref points to an index rather than a manifest, you can also use --digest instead of --platform and point to a specific manifest directly.

export ref=docker.io/library/alpine:latest

# print the total downloadable layer size (sum of all layers)
oci-tool layer --platform=linux-amd64 size $ref

# list all layers before unpacking
oci-tool layer --platform=linux-amd64 list $ref

# list all layer digests after unpacking
oci-tool layer --platform=linux-amd64 list --unpacked $ref

Resolving references

# resolve alpine:latest to it's non-familiar digested name
oci-tool resolve name alpine:latest

# print the descriptor a reference resolves to
oci-tool resolve descriptor docker.io/library/alpine:latest

Uncommon tasks

With the primitives outlined above you can alrady to a lot of fun things, especially when combined with jq and some bash.

Finding the layer diff between two images

oci-tool layer --platform=linux-amd64 list docker.io/library/alpine:3.13 | jq .[].digest | sort > alpine-3.13.txt
oci-tool layer --platform=linux-amd64 list docker.io/library/alpine:3.14 | jq .[].digest | sort > alpine-3.14.txt

diff alpine-3.13.txt alpine-3.14.txt

Inspect a Helm chart stored in a registry

Helm 3 can save charts in an OCI registry. If you've ever wondered how those look in the registry, use oci-tool to inspect what's actually stored there.

# assuming $ref points to a chart

# fetch the manifest
oci-tool fetch manifest $ref

# fetch the helm chart config
export digest=$(oci-tool fetch manifest $ref | jq -r .config.digest)
oci-tool fetch --digest $digest --media-type application/vnd.cncf.helm.config.v1+json raw $ref
Owner
Christian Weichel
Working on @gitpod-io and werft
Christian Weichel
Similar Resources

Go-api-cli - Small CLI to fetch data from an API sync and async

Async API Cli CLI to fetch data on "todos" from a given API in a number of ways.

Jan 13, 2022

A CLI tool which loads data from yaml files into the Google Cloud Spanner tables

splanter A CLI tool which loads data from yaml files into the Google Cloud Spanner tables (mainly for the development).

Oct 27, 2022

traindown-cli is a command line tool for fitness data using the Traindrain specification.

traindown-cli traindown-cli is a command line tool for fitness data using Traindown. Installation go install github.com/OliverCardoza/traindown-cli@la

Mar 13, 2022

Sig - Statistics in Go - CLI tool for quick statistical analysis of data streams

Statistics in Go - CLI tool for quick statistical analysis of data streams

May 16, 2022

Esdump is a migration CLI written in Go for migrating index mapping and data from one elasticsearch to another.

esdump Introduction esdump is a migration CLI written in Go for migrating index mapping and data from one elasticsearch to another. Compatibility Elas

Jul 23, 2022

Elegant CLI wrapper for kubeseal CLI

Overview This is a wrapper CLI ofkubeseal CLI, specifically the raw mode. If you just need to encrypt your secret on RAW mode, this CLI will be the ea

Jan 8, 2022

CLI to run a docker image with R. CLI built using cobra library in go.

CLI  to run a docker image with R. CLI built using cobra library in go.

BlueBeak Installation Guide Task 1: Building the CLI The directory structure looks like Fastest process: 1)cd into bbtools 2)cd into bbtools/bin 3)I h

Dec 20, 2021

A wrapper of aliyun-cli subcommand alidns, run aliyun-cli in Declarative mode.

aliyun-dns A wrapper of aliyun-cli subcommand alidns, run aliyun-cli in Declarative mode. Installation Install aliyun-cli. Usage $ aliyun-dns -h A wra

Dec 21, 2021

Symfony-cli - The Symfony CLI tool For Golang

Symfony CLI Install To install Symfony CLI, please download the appropriate vers

Dec 28, 2022
Comments
  • Typo fixes

    Typo fixes

    Just a couple of typo fixes in the README I stumbled upon while looking at this incredible thing.

    With love from IDE ๐Ÿงก (just used OCI tool for testing of https://github.com/gitpod-io/gitpod/pull/14055)

Runc: a CLI tool for spawning and running containers on Linux according to the OCI specification

runc Introduction runc is a CLI tool for spawning and running containers on Linux according to the OCI specification. This repo contains a lightly mod

Dec 16, 2021
Handy commands to run in Go projects

Handy commands to run in Go projects

Jan 3, 2023
a lightweight CLI client for interacting with the Akash Network

Akash Command Center A lite weight client for communicating with the Akash Network. There are no provider, or validator bits in this project. Install

Feb 12, 2022
Buildkite-cli - Command line tool for interacting with Buildkite pipelines, builds, and more

Buildkite CLI Command line tool for interacting with Buildkite pipelines, builds

Jan 7, 2022
Tabouli: a TUI for interacting with firmware/embedded devices that support a CLI via serial interface/virtual COM Port
Tabouli: a TUI for interacting with firmware/embedded devices that support a CLI via serial interface/virtual COM Port

Tabouli Information Tabouli is a TUI for interacting with firmware/embedded devi

Apr 2, 2022
CLI tool for interacting with Nostr-based wikis

nwiki Command line client for the Nostr wiki. Run in container, without installation If you don't have go installed or don't like installing stuff jus

Dec 18, 2022
Bk - Command line tool for interacting with Buildkite pipelines, builds, and more

Buildkite CLI Command line tool for interacting with Buildkite pipelines, builds

Jan 7, 2022
A powerful little TUI framework ๐Ÿ—
A powerful little TUI framework ๐Ÿ—

Bubble Tea The fun, functional and stateful way to build terminal apps. A Go framework based on The Elm Architecture. Bubble Tea is well-suited for si

Dec 27, 2022
Go-Suit is a very very wacky version of a bash terminal but in go, however with a little twitst

Go-Suit Go-Suit is a very very wacky version of a bash terminal but in go, however with a little twitst languages -> Go-Lang packages Third Party -> g

May 19, 2022
Little golang app that allows you to download a youtube video as mp3, and optionally embed ID3 tags -Cover Art, Artist ...-

yt2mp3 Little golang app that allows you to download a youtube video as mp3, and optionally embed ID3 tags -Cover Art, Artist ...- Instructions At the

Dec 25, 2021