lib

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package lib provides manually-maintained functionality that extends the auto-generated SDK.

Package lib provides manually-maintained functionality that extends the auto-generated SDK.

Package lib provides manually-maintained functionality that extends the auto-generated SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CpFromInstance

func CpFromInstance(ctx context.Context, cfg CpConfig, opts CpFromInstanceOptions) error

CpFromInstance copies a file or directory from a running instance.

Example:

cfg, _ := lib.ExtractCpConfig(client.Options)
err := lib.CpFromInstance(ctx, cfg, lib.CpFromInstanceOptions{
    InstanceID: "inst_123",
    SrcPath:    "/app/output.txt",
    DstPath:    "./local-output.txt",
})

func CpFromInstanceFromURL

func CpFromInstanceFromURL(ctx context.Context, baseURL, apiKey string, opts CpFromInstanceOptions) error

CpFromInstanceFromURL is a convenience function that uses base URL and API key directly.

func CpToInstance

func CpToInstance(ctx context.Context, cfg CpConfig, opts CpToInstanceOptions) error

CpToInstance copies a file or directory to a running instance.

Example:

cfg, _ := lib.ExtractCpConfig(client.Options)
err := lib.CpToInstance(ctx, cfg, lib.CpToInstanceOptions{
    InstanceID: "inst_123",
    SrcPath:    "./local-file.txt",
    DstPath:    "/app/file.txt",
})

func CpToInstanceFromURL

func CpToInstanceFromURL(ctx context.Context, baseURL, apiKey string, opts CpToInstanceOptions) error

CpToInstanceFromURL is a convenience function that uses base URL and API key directly.

func Push

func Push(ctx context.Context, cfg PushConfig, sourceImage, targetName string) error

Push loads an image from the local Docker daemon and pushes it to hypeman's registry.

This is a convenience function for local development workflows where images are built using Docker. For CI/CD pipelines that use Kaniko, ko, or buildpacks, use PushImage directly with the v1.Image they produce.

Parameters:

  • sourceImage: Local Docker image reference (e.g., "myapp:latest")
  • targetName: Name in hypeman (defaults to sourceImage if empty)

func PushFromURL

func PushFromURL(ctx context.Context, baseURL, apiKey string, img v1.Image, targetName string) error

PushFromURL is a convenience function that parses a base URL and API key directly, without needing a hypeman.Client. Useful for standalone scripts.

func PushImage

func PushImage(ctx context.Context, cfg PushConfig, img v1.Image, targetName string) error

PushImage pushes a v1.Image to hypeman's OCI registry.

This function works with images from any source supported by go-containerregistry:

  • Images built with Kaniko, ko, or buildpacks (no Docker needed)
  • Images pulled from remote registries via remote.Image()
  • Images loaded from tarballs via tarball.ImageFromPath()
  • Images from OCI layouts via layout.Image()

The targetName parameter specifies how the image will be named in hypeman (e.g., "myapp:latest" or "myorg/myapp:v1.0").

Types

type CpCallbacks

type CpCallbacks struct {
	OnFileStart func(path string, size int64) // Called when a file starts copying
	OnProgress  func(bytesCopied int64)       // Called as bytes are copied
	OnFileEnd   func(path string)             // Called when a file finishes copying
}

CpCallbacks provides optional progress callbacks for copy operations.

type CpConfig

type CpConfig struct {
	// BaseURL is the base URL for the hypeman API
	BaseURL string
	// APIKey is the JWT token for authentication
	APIKey string
}

CpConfig holds the configuration needed for copy operations. Extract this from a hypeman.Client using ExtractCpConfig.

func ExtractCpConfig

func ExtractCpConfig(opts []requestconfig.RequestOption) (CpConfig, error)

ExtractCpConfig extracts the base URL and API key from client options.

type CpFromInstanceOptions

type CpFromInstanceOptions struct {
	InstanceID  string       // Instance ID to copy from
	SrcPath     string       // Source path in guest
	DstPath     string       // Local destination path
	FollowLinks bool         // Follow symbolic links
	Archive     bool         // Preserve UID/GID ownership
	Callbacks   *CpCallbacks // Optional: progress callbacks
	Dialer      WsDialer     // Optional: custom WebSocket dialer (for testing)
}

CpFromInstanceOptions configures a copy-from-instance operation

type CpToInstanceOptions

type CpToInstanceOptions struct {
	InstanceID  string       // Instance ID to copy to
	SrcPath     string       // Local source path
	DstPath     string       // Destination path in guest
	Mode        fs.FileMode  // Optional: override file mode (0 = auto-detect)
	Archive     bool         // Preserve UID/GID ownership
	FollowLinks bool         // Follow symbolic links when copying
	Callbacks   *CpCallbacks // Optional: progress callbacks
	Dialer      WsDialer     // Optional: custom WebSocket dialer (for testing)
}

CpToInstanceOptions configures a copy-to-instance operation

type DefaultDialer

type DefaultDialer struct{}

DefaultDialer uses gorilla/websocket for real WebSocket connections.

func (*DefaultDialer) DialContext

func (d *DefaultDialer) DialContext(ctx context.Context, url string, headers http.Header) (WsConn, *http.Response, error)

DialContext connects to a WebSocket server.

type PushConfig

type PushConfig struct {
	// RegistryHost is the host:port of the hypeman registry (derived from base URL)
	RegistryHost string
	// APIKey is the JWT token for authentication
	APIKey string
}

PushConfig holds the configuration needed to push images to hypeman's registry. Extract this from a hypeman.Client using ExtractPushConfig.

func ExtractPushConfig

func ExtractPushConfig(opts []requestconfig.RequestOption) (PushConfig, error)

ExtractPushConfig extracts the registry host and API key from client options. This is needed because the Client struct doesn't expose these values directly.

type WsConn

type WsConn interface {
	WriteMessage(messageType int, data []byte) error
	ReadMessage() (messageType int, p []byte, err error)
	Close() error
}

WsConn abstracts a WebSocket connection for testing.

type WsDialer

type WsDialer interface {
	DialContext(ctx context.Context, url string, headers http.Header) (WsConn, *http.Response, error)
}

WsDialer abstracts WebSocket connection creation for testing.

Jump to

Keyboard shortcuts

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