-
Notifications
You must be signed in to change notification settings - Fork 64
/
manager.go
61 lines (47 loc) · 2.43 KB
/
manager.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors.
// Licensed under the BSD-3-Clause License (the "License").
// You may not use this file except in compliance with the License.
package packmanager
import (
"context"
"kraftkit.sh/pack"
"kraftkit.sh/unikraft/component"
)
// NewManagerConstructor represents the prototype that all implementing package
// managers must use during their instantiation. This standardizes their input
// and output during "construction", particularly providing access to a
// referenceable context with which they can access (within the context of
// KraftKit) the logging, IOStreams and Config subsystems.
type NewManagerConstructor func(context.Context, ...any) (PackageManager, error)
type PackageManager interface {
// Update retrieves and stores locally a cache of the upstream registry.
Update(context.Context) error
// Pack turns the provided component into the distributable package. Since
// components can comprise of other components, it is possible to return more
// than one package. It is possible to disable this and "flatten" a component
// into a single package by setting a relevant `pack.PackOption`.
Pack(context.Context, component.Component, ...PackOption) ([]pack.Package, error)
// Unpack turns a given package into a usable component. Since a package can
// compromise of a multiple components, it is possible to return multiple
// components.
Unpack(context.Context, pack.Package, ...UnpackOption) ([]component.Component, error)
// Catalog returns all packages known to the manager via given query
Catalog(context.Context, ...QueryOption) ([]pack.Package, error)
// Set the list of sources for the package manager
SetSources(context.Context, ...string) error
// Add a source to the package manager
AddSource(context.Context, string) error
// Delete package(s) from the package manager
Delete(context.Context, ...QueryOption) error
// Remove a source from the package manager
RemoveSource(context.Context, string) error
// IsCompatible checks whether the provided source is compatible with the
// package manager
IsCompatible(context.Context, string, ...QueryOption) (PackageManager, bool, error)
// From is used to retrieve a sub-package manager. For now, this is a small
// hack used for the umbrella.
From(pack.PackageFormat) (PackageManager, error)
// Format returns the name of the implementation.
Format() pack.PackageFormat
}