-
Notifications
You must be signed in to change notification settings - Fork 63
/
packager.go
41 lines (34 loc) · 1.29 KB
/
packager.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
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2023, 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 pkg
import (
"context"
"fmt"
"kraftkit.sh/pack"
)
// packager is an interface for defining different mechanisms to perform a
// packaging of a unikernel. Standardizing first the check, Packagable,
// to determine whether the provided input is capable of executing, and
// Pack, actually performing the packaging.
type packager interface {
// String implements fmt.Stringer and returns the name of the implementing
// builder.
fmt.Stringer
// Packagable determines whether the provided input is packagable by the
// current implementation.
Packagable(context.Context, *PkgOptions, ...string) (bool, error)
// Pack performs the packaging based on the determined implementation.
Pack(context.Context, *PkgOptions, ...string) ([]pack.Package, error)
}
// packagers is the list of built-in packagers which are checked
// sequentially for capability. The first to test positive via Packagable
// is used with the controller.
func packagers() []packager {
return []packager{
&packagerKraftfileUnikraft{},
&packagerKraftfileRuntime{},
&packagerCliKernel{},
}
}