provider

package
v0.17.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractHost

func ExtractHost(image string) string

ExtractHost extracts the registry host from an image name Examples:

  • "r8.im/user/model" -> "r8.im"
  • "ghcr.io/owner/repo:tag" -> "ghcr.io"
  • "gcr.io/project/image" -> "gcr.io"
  • "docker.io/library/nginx" -> "docker.io"
  • "nginx" -> "docker.io" (Docker Hub default)
  • "myregistry.com:5000/image" -> "myregistry.com:5000"
  • "localhost:5000/image" -> "localhost:5000"

func RegisterProvider

func RegisterProvider(p Provider)

RegisterProvider adds a provider to the default registry This should be called from init() functions in provider packages

Types

type LoginOptions

type LoginOptions struct {
	TokenStdin bool
	Host       string
}

type Provider

type Provider interface {
	// Name returns the provider identifier (e.g., "replicate", "generic")
	Name() string

	// MatchesRegistry returns true if this provider handles the given registry host
	MatchesRegistry(host string) bool

	// Login performs provider-specific authentication
	Login(ctx context.Context, opts LoginOptions) error

	// PostPush is called after push attempt (success or failure)
	// - Shows success message (e.g., Replicate model URL)
	// - May transform errors into provider-specific messages
	// - pushErr is nil on success, contains the push error on failure
	PostPush(ctx context.Context, opts PushOptions, pushErr error) error
}

Provider encapsulates registry-specific behavior

type PushOptions

type PushOptions struct {
	Image      string
	Config     *config.Config
	ProjectDir string
}

PushOptions contains all options for a push operation

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages provider lookup and registration

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry returns the global provider registry, initializing it on first call The registry is pre-populated with Replicate and Generic providers

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new Registry with no providers registered

func (*Registry) ForHost

func (r *Registry) ForHost(host string) Provider

ForHost returns the provider for a given registry host Returns the first provider that matches, or nil if none match

func (*Registry) ForImage

func (r *Registry) ForImage(image string) Provider

ForImage returns the provider for a given image name It extracts the registry host from the image and delegates to ForHost

func (*Registry) Register

func (r *Registry) Register(p Provider)

Register adds a provider to the registry Providers are checked in registration order, so register more specific providers before generic fallback providers

Directories

Path Synopsis
Package setup initializes the default provider registry
Package setup initializes the default provider registry

Jump to

Keyboard shortcuts

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