@@ -9,8 +9,10 @@ import (
9
9
"fmt"
10
10
11
11
"github.com/cockroachdb/cockroach/pkg/roachprod/config"
12
+ "github.com/cockroachdb/cockroach/pkg/roachprod/roachprodutil/codec"
12
13
"github.com/cockroachdb/cockroach/pkg/roachprod/vm/gce"
13
14
"github.com/cockroachdb/errors"
15
+ "gopkg.in/yaml.v3"
14
16
)
15
17
16
18
// ClusterSettings contains various knobs that affect operations on a cluster.
@@ -40,10 +42,12 @@ type secureFlagsOpt struct {
40
42
41
43
// ClusterSettingOption is the interface satisfied by options to MakeClusterSettings.
42
44
type ClusterSettingOption interface {
45
+ codec.DynamicType
43
46
apply (settings * ClusterSettings )
44
47
}
45
48
46
49
// ClusterSettingsOption adds cluster settings via SET CLUSTER SETTING.
50
+ // typegen:reg
47
51
type ClusterSettingsOption map [string ]string
48
52
49
53
func (o ClusterSettingsOption ) apply (settings * ClusterSettings ) {
@@ -53,20 +57,23 @@ func (o ClusterSettingsOption) apply(settings *ClusterSettings) {
53
57
}
54
58
55
59
// TagOption is used to pass a process tag.
60
+ // typegen:reg
56
61
type TagOption string
57
62
58
63
func (o TagOption ) apply (settings * ClusterSettings ) {
59
64
settings .Tag = string (o )
60
65
}
61
66
62
67
// BinaryOption is used to pass a process tag.
68
+ // typegen:reg
63
69
type BinaryOption string
64
70
65
71
func (o BinaryOption ) apply (settings * ClusterSettings ) {
66
72
settings .Binary = string (o )
67
73
}
68
74
69
75
// PGUrlCertsDirOption is used to pass certs dir for secure connections.
76
+ // typegen:reg
70
77
type PGUrlCertsDirOption string
71
78
72
79
func (o PGUrlCertsDirOption ) apply (settings * ClusterSettings ) {
@@ -75,6 +82,7 @@ func (o PGUrlCertsDirOption) apply(settings *ClusterSettings) {
75
82
76
83
// ComplexSecureOption is a complex type for secure options that keeps track of
77
84
// the user's intent regarding security.
85
+ // typegen:reg
78
86
type ComplexSecureOption secureFlagsOpt
79
87
80
88
func (o ComplexSecureOption ) apply (settings * ClusterSettings ) {
@@ -126,6 +134,7 @@ func (o ComplexSecureOption) overrideBasedOnClusterSettings(c *SyncedCluster) er
126
134
127
135
// SimpleSecureOption is a simple type that simplifies setting the secure flags
128
136
// in the cluster settings without keeping track of --secure or --insecure options.
137
+ // typegen:reg
129
138
type SimpleSecureOption bool
130
139
131
140
func (o SimpleSecureOption ) apply (settings * ClusterSettings ) {
@@ -150,13 +159,15 @@ type SecureOption interface {
150
159
}
151
160
152
161
// UseTreeDistOption is passed to use treedist copy algorithm.
162
+ // typegen:reg
153
163
type UseTreeDistOption bool
154
164
155
165
func (o UseTreeDistOption ) apply (settings * ClusterSettings ) {
156
166
settings .UseTreeDist = bool (o )
157
167
}
158
168
159
169
// EnvOption is used to pass environment variables to the cockroach process.
170
+ // typegen:reg
160
171
type EnvOption []string
161
172
162
173
var _ EnvOption
@@ -166,6 +177,7 @@ func (o EnvOption) apply(settings *ClusterSettings) {
166
177
}
167
178
168
179
// NumRacksOption is used to pass the number of racks to partition the nodes into.
180
+ // typegen:reg
169
181
type NumRacksOption int
170
182
171
183
var _ NumRacksOption
@@ -175,6 +187,7 @@ func (o NumRacksOption) apply(settings *ClusterSettings) {
175
187
}
176
188
177
189
// DebugDirOption is used to stash debug information.
190
+ // typegen:reg
178
191
type DebugDirOption string
179
192
180
193
var _ DebugDirOption
@@ -201,3 +214,20 @@ func MakeClusterSettings(opts ...ClusterSettingOption) ClusterSettings {
201
214
}
202
215
return clusterSettings
203
216
}
217
+
218
+ // ClusterSettingOptionList is a list of ClusterSettingOption that can be
219
+ // serialized to YAML. It uses codec.ListWrapper to handle the dynamic types.
220
+ type ClusterSettingOptionList []ClusterSettingOption
221
+
222
+ func (o ClusterSettingOptionList ) MarshalYAML () (any , error ) {
223
+ return codec .WrapList (o ), nil
224
+ }
225
+
226
+ func (o * ClusterSettingOptionList ) UnmarshalYAML (value * yaml.Node ) error {
227
+ var lw codec.ListWrapper [ClusterSettingOption ]
228
+ if err := value .Decode (& lw ); err != nil {
229
+ return err
230
+ }
231
+ * o = lw .Get ()
232
+ return nil
233
+ }
0 commit comments