-
Notifications
You must be signed in to change notification settings - Fork 64
/
register_unix.go
61 lines (51 loc) · 1.48 KB
/
register_unix.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
//go:build !windows
// +build !windows
// 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 platform
import (
"context"
"path/filepath"
zip "api.zip"
machinev1alpha1 "kraftkit.sh/api/machine/v1alpha1"
"kraftkit.sh/config"
"kraftkit.sh/machine/qemu"
"kraftkit.sh/store"
)
var qemuV1alpha1Driver = func(ctx context.Context, opts ...any) (machinev1alpha1.MachineService, error) {
service, err := qemu.NewMachineV1alpha1Service(ctx, opts...)
if err != nil {
return nil, err
}
embeddedStore, err := store.NewEmbeddedStore[machinev1alpha1.MachineSpec, machinev1alpha1.MachineStatus](
filepath.Join(
config.G[config.KraftKit](ctx).RuntimeDir,
"machinev1alpha1",
),
)
if err != nil {
return nil, err
}
return machinev1alpha1.NewMachineServiceHandler(
ctx,
service,
zip.WithStore[machinev1alpha1.MachineSpec, machinev1alpha1.MachineStatus](embeddedStore, zip.StoreRehydrationSpecNil),
zip.WithBefore(storePlatformFilter(PlatformQEMU)),
)
}
// hostSupportedStrategies returns the map of known supported drivers for the
// given host.
func hostSupportedStrategies() map[Platform]*Strategy {
s := map[Platform]*Strategy{
PlatformQEMU: {
NewMachineV1alpha1: qemuV1alpha1Driver,
},
}
// Merge OS-specific strategies
for k, v := range unixVariantStrategies() {
s[k] = v
}
return s
}