Documentation
¶
Index ¶
- Constants
- Variables
- func AlignToBlockSize(value int64, blockSize int64) (aligned int64)
- func CopyBlob(ctx context.Context, r io.ReadCloser, ref string, desc ocispec.Descriptor, ...) error
- func FetchBlobs(ctx context.Context, cfg *Config, blobs BlobsInfo, options ...FetchOption) error
- func FormatBytesInt64(size int64) string
- func FormatBytesUint64(size uint64) string
- func GetBlobsRootFor(storeRoot string) string
- func GetDockerClient(dockerHost string) (*dockerclient.Client, error)
- func GetServiceHealth(ctx context.Context, dockerClient *dockerClient.Client, containerID string) (health string)
- func Install(ctx context.Context, cfg *Config, appURI string, options ...InstallOption) error
- func InstallCompose(ctx context.Context, app App, provider BlobProvider, composeRoot string) error
- func LoadImages(ctx context.Context, client *client.Client, app App, blobsRoot string, ...) error
- func NewHttpClient(connectTimeout time.Duration, readTimeout time.Duration) *http.Client
- func NewReadMonitor(ctx context.Context, r io.ReadSeekCloser, b *BlobFetchProgress) *readMonitor
- func NewRegistryAuthorizer(cfg *configfile.ConfigFile, client *http.Client) docker.Authorizer
- func NewResolver(authorizer docker.Authorizer, client *http.Client) remotes.Resolver
- func NewSecureReadCloser(srcReadCloser io.ReadCloser, opts ...SecureReadOptions) (io.ReadCloser, error)
- func NewTarStreamer() *tarStreamer
- func ParseImageRootAsManifest(root *ImageRoot) (*ocispec.Descriptor, []*ocispec.Descriptor, error)
- func ReadBlob(ctx context.Context, provider BlobProvider, ref string, digest digest.Digest, ...) ([]byte, error)
- func ReadBlobWithReadLimit(ctx context.Context, provider BlobProvider, ref string, limit int64) ([]byte, error)
- func ReadBlobWithResolving(ctx context.Context, provider BlobProvider, ref string, size int64) ([]byte, error)
- func ReadImageManifest(ctx context.Context, provider BlobProvider, ref string, size int64) (*ocispec.Manifest, error)
- func ReadImageRoot(ctx context.Context, provider BlobProvider, ref string) (*ImageRef, *ImageRoot, *ocispec.Descriptor, error)
- func RemoveApps(ctx context.Context, cfg *Config, appRefs []string, options ...RemoveOpt) error
- func StartApps(ctx context.Context, cfg *Config, appURIs []string, options ...StartOption) error
- func StopApps(ctx context.Context, cfg *Config, appRefs []string) error
- func UninstallApps(ctx context.Context, cfg *Config, appRefs []string, options ...UninstallOpt) error
- func WithAppRef(ctx context.Context, ref *AppRef) context.Context
- func WithBlobType(ctx context.Context, blobType BlobType) context.Context
- func WithDescriptor(desc ocispec.Descriptor) func(opts *SecureReadParams)
- func WithExpectedDigest(digest digest.Digest) func(opts *SecureReadParams)
- func WithExpectedSize(size int64) func(opts *SecureReadParams)
- func WithReadLimit(limit int64) func(opts *SecureReadParams)
- func WithRef(ref string) func(opts *SecureReadParams)
- func WithSecureReadOff() func(opts *SecureReadParams)
- type App
- type AppBundleErrs
- type AppInstallCheckResult
- type AppInstallState
- type AppLoader
- type AppRef
- type AppStartProgress
- type AppStartStatus
- type AppStore
- type AppTree
- type AppsStatus
- type BlobFetchProgress
- type BlobInfo
- type BlobProvider
- type BlobProviderType
- type BlobState
- type BlobType
- type BlobsFetchProgress
- type BlobsInfo
- type CheckAppsStatusOption
- type CheckAppsStatusOptions
- type Config
- type ErrBlobDigestMismatch
- type ErrBlobSizeLimitExceed
- type ErrBlobSizeMismatch
- type ErrComposeInstall
- type ErrImageInstall
- type FetchOption
- type FetchOptions
- type FetchProgress
- type FetchProgressFunc
- type FetchReport
- type FetchStatus
- type ImageLoadState
- type ImageRef
- type ImageRoot
- type ImageTree
- type InstallCheckResult
- type InstallOption
- type InstallOptions
- type InstallProgress
- type InstallProgressFunc
- type InstallReport
- type InstallStatus
- type InstalledImagesInfo
- type LoadImageOption
- type LoadImageOptions
- type LoadImageProgress
- type NodeProcessor
- type ProgressCallbackFn
- type ProxyConfig
- type ProxyProvider
- type RemoveOpt
- type RemoveOpts
- type RunningReport
- type RunningStatus
- type SecureReadOptions
- type SecureReadParams
- type Service
- type Services
- type StartOption
- type StartOptions
- type StatFS
- type TreeNode
- type UninstallOpt
- type UninstallOpts
- type UsageInfo
Constants ¶
View Source
const ( BlobStateUndefined BlobState = iota BlobOk BlobFetching BlobMissing BlobSizeInvalid BlobDigestInvalid BlobTypeUnknown BlobType = "unknown blob type" BlobTypeAppManifest BlobType = "app manifest" BlobTypeAppBundle BlobType = "app bundle" BlobTypeAppIndex BlobType = "app index" BlobTypeAppLayersMeta BlobType = "app meta" BlobTypeImageIndex BlobType = "index" BlobTypeSkopeoImageIndex BlobType = "skopeo index" BlobTypeImageManifest BlobType = "manifest" BlobTypeImageConfig BlobType = "config" BlobTypeImageLayer BlobType = "layer" )
View Source
const ( AppServiceHashLabelKey = "io.compose-spec.config-hash" ServiceLabel = "com.docker.compose.service" )
View Source
const (
DefaultPollInterval = 300 // Default interval between polling/checking blob download status in milliseconds
)
View Source
const (
ImageRootMaxSize = 100 * 1024
)
View Source
const (
MaxMerkleTreeDepth = 10
)
Variables ¶
View Source
var ( ErrAppNotFound = errors.New("app not found") ErrAppHasNoIndex = errors.New("app has no bundle index") ErrAppIndexNotFound = errors.New("app blob index is not found") )
View Source
var (
ErrUninstallRunningApps = errors.New("failed to uninstall apps: some apps are still running, please stop them first")
)
Functions ¶
func AlignToBlockSize ¶
func FetchBlobs ¶
func FormatBytesInt64 ¶
func FormatBytesUint64 ¶
func GetBlobsRootFor ¶
func GetDockerClient ¶
func GetDockerClient(dockerHost string) (*dockerclient.Client, error)
func GetServiceHealth ¶
func InstallCompose ¶
func LoadImages ¶
func NewHttpClient ¶
func NewReadMonitor ¶
func NewReadMonitor(ctx context.Context, r io.ReadSeekCloser, b *BlobFetchProgress) *readMonitor
func NewRegistryAuthorizer ¶
func NewRegistryAuthorizer(cfg *configfile.ConfigFile, client *http.Client) docker.Authorizer
func NewResolver ¶
func NewSecureReadCloser ¶
func NewSecureReadCloser(srcReadCloser io.ReadCloser, opts ...SecureReadOptions) (io.ReadCloser, error)
func NewTarStreamer ¶
func NewTarStreamer() *tarStreamer
func ParseImageRootAsManifest ¶
func ParseImageRootAsManifest(root *ImageRoot) (*ocispec.Descriptor, []*ocispec.Descriptor, error)
func ReadBlobWithReadLimit ¶
func ReadBlobWithResolving ¶
func ReadImageManifest ¶
func ReadImageRoot ¶
func ReadImageRoot(ctx context.Context, provider BlobProvider, ref string) (*ImageRef, *ImageRoot, *ocispec.Descriptor, error)
func RemoveApps ¶
func UninstallApps ¶
func WithDescriptor ¶
func WithDescriptor(desc ocispec.Descriptor) func(opts *SecureReadParams)
func WithExpectedDigest ¶
func WithExpectedDigest(digest digest.Digest) func(opts *SecureReadParams)
func WithExpectedSize ¶
func WithExpectedSize(size int64) func(opts *SecureReadParams)
func WithReadLimit ¶
func WithReadLimit(limit int64) func(opts *SecureReadParams)
func WithRef ¶
func WithRef(ref string) func(opts *SecureReadParams)
func WithSecureReadOff ¶
func WithSecureReadOff() func(opts *SecureReadParams)
Types ¶
type App ¶
type App interface {
Name() string
Tree() *AppTree
NodeCount() int
Ref() *AppRef
HasLayersMeta(arch string) bool
GetBlobRuntimeSize(desc *ocispec.Descriptor, arch string, blockSize int64) int64
GetComposeRoot() *TreeNode
GetCompose(ctx context.Context, provider BlobProvider) (*composetypes.Project, error)
CheckComposeInstallation(ctx context.Context, provider BlobProvider, installationRootDir string) (AppBundleErrs, error)
}
type AppBundleErrs ¶
type AppInstallCheckResult ¶
type AppInstallCheckResult struct {
AppName string `json:"app_name"`
MissingImages []string `json:"missing_images"`
BundleErrors AppBundleErrs `json:"bundle_errors"`
}
type AppInstallState ¶
type AppInstallState string
const ( AppInstallStateComposeInstalling AppInstallState = "app:install:compose:install" AppInstallStateComposeChecking AppInstallState = "app:install:compose:check" AppInstallStateImagesLoading AppInstallState = "app:install:images:loading" )
type AppLoader ¶
type AppLoader interface {
LoadAppTree(context.Context, BlobProvider, platforms.MatchComparer, string) (App, error)
}
type AppRef ¶
func ParseAppRef ¶
type AppStartProgress ¶
type AppStartProgress func(app App, status AppStartStatus, any interface{})
type AppStartStatus ¶
type AppStartStatus string
const ( AppStartStatusStarting AppStartStatus = "starting" AppStartStatusStarted AppStartStatus = "started" AppStartStatusFailed AppStartStatus = "failed" )
type AppTree ¶
type AppTree TreeNode
func (*AppTree) Walk ¶
func (t *AppTree) Walk(fn NodeProcessor) error
type AppsStatus ¶
type AppsStatus struct {
Apps []App
*FetchStatus
*InstallStatus
*RunningStatus
}
func CheckAppsStatus ¶
func CheckAppsStatus( ctx context.Context, cfg *Config, appRefs []string, options ...CheckAppsStatusOption) (*AppsStatus, error)
func (*AppsStatus) AreFetched ¶
func (s *AppsStatus) AreFetched() bool
func (*AppsStatus) AreInstalled ¶
func (s *AppsStatus) AreInstalled() bool
func (*AppsStatus) AreRunning ¶
func (s *AppsStatus) AreRunning() bool
type BlobFetchProgress ¶
type BlobFetchProgress struct {
BlobInfo `json:"blob_info"`
BytesFetched int64 `json:"bytes_fetched"` // overall bytes read for this blob and written to the local storage;
FetchStartTime time.Time `json:"fetch_start_time"`
BytesRead int64 `json:"bytes_read"` // total blob bytes read from network during the last fetch attempt
ReadTime time.Duration `json:"read_time"` // aggregate time spent reading this blob data from the network
ReadSpeedAvg int64 `json:"read_speed_avg"` // average read speed in bytes per second
ReadSpeedCur int64 `json:"read_speed_curr"` // current read speed in bytes per second
}
type BlobInfo ¶
type BlobProvider ¶
type BlobProvider interface {
content.InfoProvider
Type() BlobProviderType
GetReadCloser(ctx context.Context, opts ...SecureReadOptions) (io.ReadCloser, error)
}
func NewLocalBlobProvider ¶
func NewLocalBlobProvider(fileProvider content.Store) BlobProvider
func NewMemoryBlobProvider ¶
func NewMemoryBlobProvider(blobs map[digest.Digest][]byte) BlobProvider
func NewRemoteBlobProviderFromConfig ¶
func NewRemoteBlobProviderFromConfig(config *Config) BlobProvider
func NewStoreBlobProvider ¶
func NewStoreBlobProvider(blobRoot string) BlobProvider
type BlobProviderType ¶
type BlobProviderType string
const ( BlobProviderTypeRemote BlobProviderType = "blob-provider:remote" BlobProviderTypeLocal BlobProviderType = "blob-provider:local" BlobProviderTypeStore BlobProviderType = "blob-provider:store" BlobProviderTypeMemory BlobProviderType = "blob-provider:memory" )
type BlobState ¶
type BlobState int
func CheckBlob ¶
func CheckBlob(ctx context.Context, provider BlobProvider, dgst digest.Digest, opts ...SecureReadOptions) (BlobState, error)
func ErrToBlobState ¶
type BlobsFetchProgress ¶
type BlobsFetchProgress map[digest.Digest]*BlobFetchProgress
type CheckAppsStatusOption ¶
type CheckAppsStatusOption func(*CheckAppsStatusOptions)
func WithAppTreeBlobProvider ¶
func WithAppTreeBlobProvider(bp BlobProvider) CheckAppsStatusOption
func WithCheckInstallation ¶
func WithCheckInstallation(check bool) CheckAppsStatusOption
func WithCheckRunning ¶
func WithCheckRunning(check bool) CheckAppsStatusOption
func WithQuickCheckFetch ¶
func WithQuickCheckFetch(quickCheck bool) CheckAppsStatusOption
type CheckAppsStatusOptions ¶
type CheckAppsStatusOptions struct {
CheckInstallation bool
CheckRunning bool
QuickCheckFetch bool
AppTreeBlobProvider BlobProvider
}
type Config ¶
type Config struct {
StoreRoot string
ComposeRoot string
DockerCfg *configfile.ConfigFile
DockerHost string
Platform specs.Platform
ConnectTimeout time.Duration
ReadTimeout time.Duration
AppLoader AppLoader
AppStoreFactoryFunc func(c *Config) (AppStore, error)
BlockSize int64
DBFilePath string
Proxy ProxyProvider
}
func (*Config) AppStoreFactory ¶
func (*Config) GetAppComposeDir ¶
func (*Config) GetBlobsRoot ¶
type ErrBlobDigestMismatch ¶
func (*ErrBlobDigestMismatch) Error ¶
func (e *ErrBlobDigestMismatch) Error() string
type ErrBlobSizeLimitExceed ¶
type ErrBlobSizeLimitExceed struct {
Limit int64
}
func (*ErrBlobSizeLimitExceed) Error ¶
func (e *ErrBlobSizeLimitExceed) Error() string
type ErrBlobSizeMismatch ¶
func (*ErrBlobSizeMismatch) Error ¶
func (e *ErrBlobSizeMismatch) Error() string
type ErrComposeInstall ¶
type ErrComposeInstall struct {
Errs AppBundleErrs
}
func (*ErrComposeInstall) Error ¶
func (e *ErrComposeInstall) Error() string
type ErrImageInstall ¶
type ErrImageInstall struct {
MissingImages []string
}
func (*ErrImageInstall) Error ¶
func (e *ErrImageInstall) Error() string
type FetchOption ¶
type FetchOption func(*FetchOptions)
func WithFetchProgress ¶
func WithFetchProgress(pf FetchProgressFunc) FetchOption
func WithProgressPollInterval ¶
func WithProgressPollInterval(pollInterval int) FetchOption
func WithSourcePath ¶
func WithSourcePath(sourcePath string) FetchOption
type FetchOptions ¶
type FetchOptions struct {
ProgressHandler FetchProgressFunc
ProgressPollInterval int // interval between polling/checking blob download status in milliseconds
SourcePath string // path to the source directory containing blobs to fetch, if specified, the blobs will be fetched from this directory instead of remote registry
}
type FetchProgress ¶
type FetchProgress struct {
Blobs BlobsFetchProgress // per-blob metadata and progress
FetchedCount int // number of fully fetched blobs
CurrentBytes int64 // total bytes downloaded so far
TotalBytes int64 // total bytes expected to download
}
type FetchProgressFunc ¶
type FetchProgressFunc func(*FetchProgress)
type FetchReport ¶
type FetchReport struct {
BlobsStatus BlobsInfo
}
type FetchStatus ¶
type FetchStatus struct {
BlobsStatus map[digest.Digest]FetchReport
MissingBlobs BlobsInfo
}
func CheckAppsFetchStatus ¶
func CheckAppsFetchStatus( ctx context.Context, cfg *Config, blobProvider BlobProvider, apps []App, quick bool) (*FetchStatus, error)
type ImageLoadState ¶
type ImageLoadState string
const ( ImageLoadStateImageWaiting ImageLoadState = "image-load:image:waiting" ImageLoadStateLayerLoading ImageLoadState = "image-load:layer:loading" ImageLoadStateLayerSyncing ImageLoadState = "image-load:layer:syncing" ImageLoadStateLayerLoaded ImageLoadState = "image-load:layer:loaded" ImageLoadStateImageLoaded ImageLoadState = "image-load:image:loaded" ImageLoadStateImageExist ImageLoadState = "image-load:image:exist" )
type ImageRef ¶
func ParseImageRef ¶
type ImageRoot ¶
type ImageRoot struct {
specs.Versioned
MediaType string `json:"mediaType,omitempty"`
Config json.RawMessage `json:"config,omitempty"`
Layers json.RawMessage `json:"layers,omitempty"`
Manifests json.RawMessage `json:"manifests,omitempty"`
FSLayers json.RawMessage `json:"fsLayers,omitempty"` // schema 1
Type BlobType
Children []TreeNode
}
type InstallCheckResult ¶
type InstallCheckResult map[string]*AppInstallCheckResult
type InstallOption ¶
type InstallOption func(*InstallOptions)
func WithInstallProgress ¶
func WithInstallProgress(pf InstallProgressFunc) InstallOption
func WithLoadedImages ¶
func WithLoadedImages(li map[string]struct{}) InstallOption
type InstallOptions ¶
type InstallOptions struct {
ProgressReporter progress.Reporter[InstallProgress]
LoadedImages map[string]struct{}
}
type InstallProgress ¶
type InstallProgress struct {
AppInstallState AppInstallState
AppID string
ImageLoadState ImageLoadState
ImageID string
ID string
Current int64
Total int64
}
type InstallProgressFunc ¶
type InstallProgressFunc func(*InstallProgress)
type InstallReport ¶
type InstallReport struct {
Images map[digest.Digest]bool
BundleErrors AppBundleErrs
}
type InstallStatus ¶
type InstallStatus struct {
AppsInstallStatus map[digest.Digest]*InstallReport
NotInstalledImages map[string]interface{}
NotInstalledCompose map[digest.Digest]interface{}
}
func CheckAppsInstallStatus ¶
func CheckAppsInstallStatus( ctx context.Context, cfg *Config, blobProvider BlobProvider, apps []App) (*InstallStatus, error)
type InstalledImagesInfo ¶
type InstalledImagesInfo struct {
// Image ID to image summary map (Image ID is the docker's internal ID for the image,
// not the digest URI of the image).
InstalledImages map[string]image.Summary
// Image refs (both digest and tag) to image ID map.
// The same image can have multiple references.
InstalledImageRefs map[string]string
}
func GetInstalledImages ¶
func GetInstalledImages(ctx context.Context, cfg *Config) (*InstalledImagesInfo, error)
type LoadImageOption ¶
type LoadImageOption func(*LoadImageOptions)
func WithBlobReadingFromStore ¶
func WithBlobReadingFromStore() LoadImageOption
func WithProgressReporting ¶
func WithProgressReporting(pc ProgressCallbackFn) LoadImageOption
func WithRefWithDigest ¶
func WithRefWithDigest() LoadImageOption
type LoadImageOptions ¶
type LoadImageOptions struct {
ReadBlobsFromStore bool
RefWithDigest bool
ProgressReporter progress.Reporter[LoadImageProgress]
ProgressCallback ProgressCallbackFn
}
type LoadImageProgress ¶
type LoadImageProgress struct {
State ImageLoadState
ImageID string
ID string
Current int64
Total int64
}
type NodeProcessor ¶
type ProgressCallbackFn ¶
type ProgressCallbackFn func(*LoadImageProgress)
type ProxyProvider ¶
type ProxyProvider func() *ProxyConfig
type RemoveOpts ¶
type RunningReport ¶
type RunningStatus ¶
type RunningStatus struct {
AppsRunningStatus map[digest.Digest]RunningReport
NotRunningApps map[digest.Digest]interface{}
}
func CheckAppsRunningStatus ¶
type SecureReadOptions ¶
type SecureReadOptions func(opts *SecureReadParams)
type SecureReadParams ¶
type SecureReadParams struct {
Ref string
ExpectedDigest digest.Digest
ExpectedSize int64
ReadLimit int64
Descriptor ocispec.Descriptor
DisableSecureRead bool
}
func GetSecureReadParams ¶
func GetSecureReadParams(opts ...SecureReadOptions) (p SecureReadParams)
type StartOption ¶
type StartOption func(*StartOptions)
func WithStartProgressHandler ¶
func WithStartProgressHandler(handler AppStartProgress) StartOption
func WithVerboseStart ¶
func WithVerboseStart(verbose bool) StartOption
type StartOptions ¶
type StartOptions struct {
Verbose bool
ProgressHandler AppStartProgress
}
type TreeNode ¶
type TreeNode struct {
Descriptor *ocispec.Descriptor
Type BlobType
Children []*TreeNode
}
func LoadImageTree ¶
func LoadImageTree(ctx context.Context, provider BlobProvider, platform platforms.MatchComparer, ref string) (*TreeNode, error)
func (*TreeNode) GetImageConfigAndLayers ¶
func (t *TreeNode) GetImageConfigAndLayers() (*ocispec.Descriptor, []*ocispec.Descriptor, error)
func (*TreeNode) GetServiceHash ¶
func (*TreeNode) Walk ¶
func (t *TreeNode) Walk(fn NodeProcessor) error
type UninstallOpt ¶
type UninstallOpt func(*UninstallOpts)
func WithImagePruning ¶
func WithImagePruning() UninstallOpt
type UninstallOpts ¶
type UninstallOpts struct {
Prune bool
}
type UsageInfo ¶
type UsageInfo struct {
Path string `json:"path"`
SizeB uint64 `json:"size_b"`
Free uint64 `json:"free"`
FreeP float32 `json:"free_p"`
Reserved uint64 `json:"reserved"`
ReservedP float32 `json:"reserved_p"`
Available uint64 `json:"available"`
AvailableP float32 `json:"available_p"`
Required uint64 `json:"required"`
RequiredP float32 `json:"required_p"`
}
func GetUsageInfo ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.