-
Notifications
You must be signed in to change notification settings - Fork 453
/
install.go
78 lines (62 loc) · 1.81 KB
/
install.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// 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 installer
import (
"context"
"errors"
"fmt"
"log"
"github.com/spf13/cobra"
"github.com/siderolabs/talos/cmd/installer/pkg/install"
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform"
"github.com/siderolabs/talos/pkg/machinery/config/configloader"
"github.com/siderolabs/talos/pkg/machinery/version"
)
// installCmd represents the installation command.
var installCmd = &cobra.Command{
Use: "install",
Short: "",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) (err error) {
return runInstallCmd(cmd.Context())
},
}
func init() {
rootCmd.AddCommand(installCmd)
}
func runInstallCmd(ctx context.Context) (err error) {
log.Printf("running Talos installer %s", version.NewVersion().Tag)
mode := install.ModeInstall
if options.Upgrade {
mode = install.ModeUpgrade
}
p, err := platform.NewPlatform(options.Platform)
if err != nil {
return err
}
config, err := configloader.NewFromStdin()
if err != nil {
if errors.Is(err, configloader.ErrNoConfig) {
log.Printf("machine configuration missing, skipping validation")
} else {
return fmt.Errorf("error loading machine configuration: %w", err)
}
} else {
var warnings []string
warnings, err = config.Validate(p.Mode())
if err != nil {
return fmt.Errorf("machine configuration is invalid: %w", err)
}
if len(warnings) > 0 {
log.Printf("WARNING: config validation:")
for _, warning := range warnings {
log.Printf(" %s", warning)
}
}
if config.Machine().Install().LegacyBIOSSupport() {
options.LegacyBIOSSupport = true
}
}
return install.Install(ctx, p, mode, options)
}