casengine

package module
v0.0.0-...-3ed0888 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

README

OCI CAS-Protocol Go implementations

This repository implements:

There are command-line bindings in oci-cas, which reads a CAS-engine configurations from stdin, resolves digests given as arguments, and writes their verified content to stdout.

$ cat cas-engines.json
[
  {
    "config": {
      "protocol": "oci-cas-template-v1",
      "uri": "cas/{algorithm}/{encoded}"
    },
    "uri": "https://example.com"
  }
]
$ oci-cas get sha256:c98c24b677eff44860afea6f493bbaec5bb1c4cbb209c6fc2bbb47f66ff2ad31 <cas-engines.json
Hello, World!

For more information, see oci-cas help.

Documentation

Overview

Package casengine defines common interfaces for CAS engines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlgorithmCallback

type AlgorithmCallback func(ctx context.Context, algorithm digest.Algorithm) (err error)

AlgorithmCallback templates an AlgorithmLister.Algorithms callback used for processing algorithms. AlgorithmLister.Algorithms for more details.

type AlgorithmLister

type AlgorithmLister interface {

	// Algorithms returns available algorithms from the store.  The set
	// of algorithms must include those which currently have stored
	// digests, but may or may not include algorithms which may have stored
	// digests in the future.
	//
	// Results are sorted alphabetically.
	//
	// Arguments:
	//
	// * ctx: gives callers a way to gracefully cancel a long-running
	//   list.
	// * prefix: limits the result set to algorithms starting with that
	//   value.
	// * size: limits the length of the result set to the first 'size'
	//   matches.  A value of -1 means "all results".
	// * from: shifts the result set to start from the 'from'th match.
	// * callback: called for every matching algorithm.  Algorithms
	//   returns any errors returned by callback and aborts further
	//   listing.
	//
	// For example, a store with digests like:
	//
	// * sha256:dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f
	// * sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
	// * sha512:cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
	//
	// which also supports sha384 may have the following call/result pairs:
	//
	// * Algorithms(ctx, "", -1, 0, printAlgorithm) -> "sha256", "sha512"
	//   or
	//   Algorithms(ctx, "", -1, 0, printAlgorithm) -> "sha256", "sha384", "sha512"
	// * Algorithms(ctx, "", 1, 0, printAlgorithm) -> "sha256"
	// * Algorithms(ctx, "", 2, 1, printAlgorithm) -> "sha512"
	//   or
	//   Algorithms(ctx, "", 2, 1, printAlgorithm) -> "sha384", "sha512"
	// * Algorithms(ctx, "sha5", -1, 0, printAlgorithm) -> "sha512"
	Algorithms(ctx context.Context, prefix string, size int, from int, callback AlgorithmCallback) (err error)
}

AlgorithmLister represents a content-addressable storage engine algorithm lister.

type Closer

type Closer interface {

	// Close releases resources held by the engine.  Subsequent engine
	// method calls will fail.
	Close(ctx context.Context) (err error)
}

Closer represents a content-addressable storage engine closer.

type Deleter

type Deleter interface {

	// Delete removes a blob from the store. The action is idempotent; a
	// nil return means "that content is not in the store" without
	// implying "because of your Delete()".
	Delete(ctx context.Context, digest digest.Digest) (err error)
}

Deleter represents a content-addressable storage engine deleter.

type DigestCallback

type DigestCallback func(ctx context.Context, digest digest.Digest) (err error)

DigestCallback templates an DigestLister.Digests callback used for processing algorithms. DigestLister.Digests for more details.

type DigestLister

type DigestLister interface {

	// Digests returns available digests from the store.
	//
	// Results are sorted alphabetically.
	//
	// Arguments:
	//
	// * ctx: gives callers a way to gracefully cancel a long-running
	//   list.
	// * algorithm: limits the result set to digests whose algorithm
	//   matches this value.  An empty-string value means "all
	//   algorithms".
	// * prefix: limits the result set to digests whose encoded part
	//   starts with that value.
	// * size: limits the length of the result set to the first 'size'
	//   matches.  A value of -1 means "all results".
	// * from: shifts the result set to start from the 'from'th match.
	// * callback: called for every matching digest.  Digests returns
	//   any errors returned by callback and aborts further listing.
	//
	// For example, a store with digests like:
	//
	// * sha256:dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f
	// * sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
	// * sha512:374d794a95cdcfd8b35993185fef9ba368f160d8daf432d08ba9f1ed1e5abe6cc69291e0fa2fe0006a52570ef18c19def4e617c33ce52ef0a6e5fbe318cb0387
	//
	// will have the following call/result pairs:
	//
	// * Digests(ctx, "", "", -1, 0, printDigest) ->
	//     "sha256:dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f"
	//     "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
	//     "sha512:374d794a95cdcfd8b35993185fef9ba368f160d8daf432d08ba9f1ed1e5abe6cc69291e0fa2fe0006a52570ef18c19def4e617c33ce52ef0a6e5fbe318cb0387"
	// * Digests(ctx, "sha256", "", -1, 0, printDigest) ->
	//     "sha256:dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f"
	//     "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
	// * Digests(ctx, "sha256", "e", -1, 0, printDigest) ->
	//     "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
	// * Digests(ctx, "", "", 2, 0, printDigest) ->
	//     "sha256:dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f"
	//     "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
	// * Digests(ctx, "", "", 2, 1, printDigest) ->
	//     "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
	//     "sha512:374d794a95cdcfd8b35993185fef9ba368f160d8daf432d08ba9f1ed1e5abe6cc69291e0fa2fe0006a52570ef18c19def4e617c33ce52ef0a6e5fbe318cb0387"
	Digests(ctx context.Context, algorithm digest.Algorithm, prefix string, size int, from int, callback DigestCallback) (err error)
}

DigestLister represents a content-addressable storage engine digest lister.

type DigestListerEngine

type DigestListerEngine interface {
	Engine
	DigestLister
}

DigestListerEngine is the interface that groups all the basic interfaces defined in this package.

type Engine

type Engine interface {
	Reader
	AlgorithmLister
	Writer
	Deleter
	Closer
}

Engine is the interface that groups all the basic interfaces defined in this package except for DigestLister.

type ListDeleter

type ListDeleter interface {
	AlgorithmLister
	DigestLister
	Deleter
}

ListDeleter is the interface that groups the basic AlgorithmLister, DigestLister, and Deleter interfaces. This combination is useful for garbage collection.

type ReadCloser

type ReadCloser interface {
	Reader
	Closer
}

ReadCloser is the interface that groups the basic Reader and Closer interfaces.

type Reader

type Reader interface {

	// Get returns a reader for retrieving a blob from the store.
	// Returns os.ErrNotExist if the digest is not found.
	//
	// Implementations are *not* required to verify that the returned
	// reader content matches the requested digest.  Callers that need
	// that verification are encouraged to use something like:
	//
	//   rawReader, err := engine.Get(ctx, digest)
	//   defer rawReader.Close()
	//   verifier := digest.Verifier()
	//   verifiedReader := io.TeeReader(rawReader, verifier)
	//   consume(verifiedReader)
	//   if !verifier.Verified() {
	//     dieScreaming()
	//   }
	//
	// for streaming verification.
	Get(ctx context.Context, digest digest.Digest) (reader io.ReadCloser, err error)
}

Reader represents a content-addressable storage engine reader.

type WriteCloser

type WriteCloser interface {
	Writer
	Closer
}

WriteCloser is the interface that groups the basic Writer and Closer interfaces.

type Writer

type Writer interface {

	// Put adds a new blob to the store.  The action is idempotent; a
	// nil return means "that content is stored at DIGEST" without
	// implying "because of your Put()".
	//
	// The algorithm argument allows you to require a particular digest
	// algorithm.  Set to the empty string to allow the Writer to use
	// its preferred algorithm.
	Put(ctx context.Context, algorithm digest.Algorithm, reader io.Reader) (digest digest.Digest, err error)
}

Writer represents a content-addressable storage engine writer.

Directories

Path Synopsis
cmd
Package counter defines a byte-counting writer.
Package counter defines a byte-counting writer.
Package dir implements a directory-based CAS engine.
Package dir implements a directory-based CAS engine.
Package read implements the CAS-engine protocol registry.
Package read implements the CAS-engine protocol registry.
template
Package template implements the OCI CAS Template Protocol v1.
Package template implements the OCI CAS Template Protocol v1.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL