Skip to content

Commit 4dd3606

Browse files
alec-raboldpires
authored andcommitted
remove error from NodeOpt
1 parent f949e6c commit 4dd3606

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

node/nodeutil/controller.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,17 @@ func (n *Node) Err() error {
210210
}
211211

212212
// NodeOpt is used as functional options when configuring a new node in NewNodeFromClient
213-
type NodeOpt func(c *NodeOptions) error
213+
type NodeOpt func(c *NodeOptions)
214214

215215
type NodeOptions struct {
216-
NodeConfigOpts []func(c *NodeConfig) error
217-
PodControllerConfigOpts []func(c *node.PodControllerConfig) error
216+
NodeConfigOpts []NodeConfigOpt
217+
PodControllerConfigOpts []PodControllerConfigOpt
218218
}
219219

220+
type NodeConfigOpt func(c *NodeConfig) error
221+
222+
type PodControllerConfigOpt func(c *node.PodControllerConfig) error
223+
220224
// NodeConfig is used to hold configuration items for a Node.
221225
// It gets used in conjection with NodeOpt in NewNodeFromClient
222226
type NodeConfig struct {
@@ -269,33 +273,30 @@ type NodeConfig struct {
269273

270274
// WithNodeConfig returns a NodeOpt which replaces the NodeConfig with the passed in value.
271275
func WithNodeConfig(c NodeConfig) NodeOpt {
272-
return func(opts *NodeOptions) error {
276+
return func(opts *NodeOptions) {
273277
opts.NodeConfigOpts = append(opts.NodeConfigOpts, func(orig *NodeConfig) error {
274278
*orig = c
275279
return nil
276280
})
277-
return nil
278281
}
279282
}
280283

281284
// WithClient return a NodeOpt that sets the client that will be used to create/manage the node.
282285
func WithClient(c kubernetes.Interface) NodeOpt {
283-
return func(opts *NodeOptions) error {
286+
return func(opts *NodeOptions) {
284287
opts.NodeConfigOpts = append(opts.NodeConfigOpts, func(orig *NodeConfig) error {
285288
orig.Client = c
286289
return nil
287290
})
288-
return nil
289291
}
290292
}
291293

292294
func WithPodControllerConfigOverrides(mutateFn func(*node.PodControllerConfig)) NodeOpt {
293-
return func(opts *NodeOptions) error {
295+
return func(opts *NodeOptions) {
294296
opts.PodControllerConfigOpts = append(opts.PodControllerConfigOpts, func(orig *node.PodControllerConfig) error {
295297
mutateFn(orig)
296298
return nil
297299
})
298-
return nil
299300
}
300301
}
301302

@@ -339,9 +340,7 @@ func NewNode(name string, newProvider NewProviderFunc, opts ...NodeOpt) (*Node,
339340

340341
var options NodeOptions
341342
for _, o := range opts {
342-
if err := o(&options); err != nil {
343-
return nil, err
344-
}
343+
o(&options)
345344
}
346345

347346
for _, o := range options.NodeConfigOpts {

0 commit comments

Comments
 (0)