-
Notifications
You must be signed in to change notification settings - Fork 64
/
init.go
50 lines (40 loc) · 1.27 KB
/
init.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
// 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 bootstrap lets us keep kraftkit initialization logic in one place.
package bootstrap
import (
"context"
"kraftkit.sh/api"
"kraftkit.sh/machine/qemu"
"kraftkit.sh/manifest"
"kraftkit.sh/oci"
"kraftkit.sh/packmanager"
"kraftkit.sh/unikraft/elfloader"
)
// InitKraftkit performs a set of kraftkit setup steps.
// It allows us to move away from in-package init() magic.
// It also allows us to propagate initialization errors easily.
func InitKraftkit(ctx context.Context) error {
registerAdditionalFlags()
if err := registerSchemes(); err != nil {
return err
}
return registerPackageManagers(ctx)
}
func registerAdditionalFlags() {
elfloader.RegisterFlags()
manifest.RegisterFlags()
qemu.RegisterFlags()
}
func registerSchemes() error {
return api.RegisterSchemes()
}
func registerPackageManagers(ctx context.Context) error {
managerConstructors := []func(u *packmanager.UmbrellaManager) error{
oci.RegisterPackageManager(),
manifest.RegisterPackageManager(),
}
return packmanager.InitUmbrellaManager(ctx, managerConstructors)
}