-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.go
60 lines (47 loc) · 1.58 KB
/
main.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
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package main
import (
_ "embed"
"path/filepath"
"github.com/siderolabs/go-copy/copy"
"github.com/siderolabs/talos/pkg/machinery/overlay"
"github.com/siderolabs/talos/pkg/machinery/overlay/adapter"
)
func main() {
adapter.Execute(&BoardInstaller{})
}
type BoardInstaller struct{}
type boardExtraOptions struct {
Console []string `json:"console"`
ConfigFile string `json:"configFile"`
}
func (i *BoardInstaller) GetOptions(extra boardExtraOptions) (overlay.Options, error) {
kernelArgs := []string{
"console=tty0",
"sysctl.kernel.kexec_load_disabled=1",
"talos.dashboard.disabled=1",
}
kernelArgs = append(kernelArgs, extra.Console...)
return overlay.Options{
Name: "board",
KernelArgs: kernelArgs,
}, nil
}
func (i *BoardInstaller) Install(options overlay.InstallOptions[boardExtraOptions]) error {
// allows to copy a directory from the overlay to the target
// err := copy.Dir(filepath.Join(options.ArtifactsPath, "arm64/firmware/boot"), filepath.Join(options.MountPrefix, "/boot/EFI"))
// if err != nil {
// return err
// }
// allows to copy a file from the overlay to the target
err := copy.File(filepath.Join(options.ArtifactsPath, "arm64/u-boot/board/u-boot.bin"), filepath.Join(options.MountPrefix, "/boot/EFI/u-boot.bin"))
if err != nil {
return err
}
if options.ExtraOptions.ConfigFile != "" {
// do something with the config file
}
return nil
}