-
Notifications
You must be signed in to change notification settings - Fork 467
/
options.go
127 lines (100 loc) · 2.88 KB
/
options.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// 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 provision
import (
"io"
"os"
"runtime"
"github.com/talos-systems/talos/pkg/machinery/client"
clientconfig "github.com/talos-systems/talos/pkg/machinery/client/config"
)
// Option controls Provisioner.
type Option func(o *Options) error
// WithLogWriter sets logging destination.
func WithLogWriter(w io.Writer) Option {
return func(o *Options) error {
o.LogWriter = w
return nil
}
}
// WithEndpoint specifies endpoint to use when acessing Talos cluster.
func WithEndpoint(endpoint string) Option {
return func(o *Options) error {
o.ForceEndpoint = endpoint
return nil
}
}
// WithTalosConfig specifies talosconfig to use when acessing Talos cluster.
func WithTalosConfig(talosConfig *clientconfig.Config) Option {
return func(o *Options) error {
o.TalosConfig = talosConfig
return nil
}
}
// WithTalosClient specifies client to use when acessing Talos cluster.
func WithTalosClient(client *client.Client) Option {
return func(o *Options) error {
o.TalosClient = client
return nil
}
}
// WithBootlader enables or disables bootloader (bootloader is enabled by default).
func WithBootlader(enabled bool) Option {
return func(o *Options) error {
o.BootloaderEnabled = enabled
return nil
}
}
// WithUEFI enables or disables UEFI boot on amd64 (default for amd64 is BIOS boot).
func WithUEFI(enabled bool) Option {
return func(o *Options) error {
o.UEFIEnabled = enabled
return nil
}
}
// WithTargetArch specifies target architecture for the cluster.
func WithTargetArch(arch string) Option {
return func(o *Options) error {
o.TargetArch = arch
return nil
}
}
// WithDockerPorts allows docker provisioner to expose ports on workers.
func WithDockerPorts(ports []string) Option {
return func(o *Options) error {
o.DockerPorts = ports
return nil
}
}
// WithDockerPortsHostIP sets host IP for docker provisioner to expose ports on workers.
func WithDockerPortsHostIP(hostIP string) Option {
return func(o *Options) error {
o.DockerPortsHostIP = hostIP
return nil
}
}
// Options describes Provisioner parameters.
type Options struct {
LogWriter io.Writer
TalosConfig *clientconfig.Config
TalosClient *client.Client
ForceEndpoint string
TargetArch string
// Enable bootloader by booting from disk image after install.
BootloaderEnabled bool
// Enable UEFI (for amd64), arm64 can only boot UEFI
UEFIEnabled bool
// Expose ports to worker machines in docker provisioner
DockerPorts []string
DockerPortsHostIP string
}
// DefaultOptions returns default options.
func DefaultOptions() Options {
return Options{
BootloaderEnabled: true,
TargetArch: runtime.GOARCH,
LogWriter: os.Stderr,
DockerPortsHostIP: "0.0.0.0",
}
}