Skip to content

a generic driver interface around OCI based runtime engines.

License

Notifications You must be signed in to change notification settings

Menahem-Mendel/oci

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

THE LIBRARY IS UNDER DEVELOPMENT

OCI

oci is a generic driver interface around OCI (Open Container Initiative) based runtime engines. This library provides an abstraction layer for connecting to and interacting with OCI compliant runtime engines, offering a unified interface regardless of the underlying engine (Docker, Podman, etc.).

This library simplifies the process of developing containerized applications and services, offering consistent interfaces for common operations like pulling images and executing requests. It allows developers to switch between different runtime engines with minimal code changes.

Features

  • Interface-based design that enables loose coupling and easy interchangeability of runtime engines.
  • Operations for pulling images from registries.
  • Request execution that aligns with the standard OCI specifications.
  • Standardized error handling and response structures.
  • Concurrency safety for multi-threaded workloads.

Getting Started

import "oci"

Creating a New Client

To create a new client with a driver:

driver := NewDriver() // This should be your custom driver that implements the Driver interface
client, err := oci.NewClient(context.Background(), driver, "unix:///var/run/docker.sock")
if err != nil {
    log.Fatal(err)
}
defer client.Close()

Executing Commands

After setting up the client, you can execute OCI compliant commands. For example, to pull an image:

response, err := client.Pull(context.Background(), "alpine:latest")
if err != nil {
    log.Fatal(err)
}
// Process the response...

Interfaces

Driver

This interface is to be implemented by different runtime engines (adapters). It provides methods for connecting to the runtime engine and handling requests.

Conn

This interface represents a connection to the runtime engine and must be implemented by the adapters. It provides methods to close the connection.

Writing Custom Adapters

If you want to write a custom adapter for a runtime engine not currently supported, implement the Driver and Conn interfaces. For example:

type MyDriver struct {
	// ...
}

func (d *MyDriver) Connect(ctx context.Context, sock string) (oci.Conn, error) {
	// Implement connection logic...
}

func (d *MyDriver) Handler(method string) oci.Handler {
	// Implement handler logic...
}

Then you can define handlers which have same signature as the HandlerFunc

var handlers map[string]oci.HandlerFunc{
    string(oci.PULL): oci.HandlerFunc(MyHandler),
}

func MyHandler(req *oci.Request) (*oci.Response, error) {
	// Implement handler logic...
}

Contributing

Contributions to oci are welcomed! Whether it's bug reports, feature requests, or pull requests, we appreciate all help in improving this library.

License

oci is open source software [licensed under BSD 3-Clause License].

About

a generic driver interface around OCI based runtime engines.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages