2023-03-25 13:47:39 -04:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
|
|
|
|
package handlers
|
|
|
|
|
|
|
|
|
|
import (
|
2023-04-01 08:43:04 -04:00
|
|
|
"github.com/hashicorp/nodeenrollment"
|
2023-03-25 13:47:39 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// getOpts - iterate the inbound Options and return a struct
|
|
|
|
|
func getOpts(opt ...Option) options {
|
|
|
|
|
opts := getDefaultOptions()
|
|
|
|
|
for _, o := range opt {
|
|
|
|
|
o(&opts)
|
|
|
|
|
}
|
|
|
|
|
return opts
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Option - how Options are passed as arguments
|
|
|
|
|
type Option func(*options)
|
|
|
|
|
|
|
|
|
|
// options = how options are represented
|
|
|
|
|
type options struct {
|
2023-04-01 08:43:04 -04:00
|
|
|
withKeyProducer nodeenrollment.X25519KeyProducer
|
2023-03-25 13:47:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getDefaultOptions() options {
|
|
|
|
|
return options{}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 08:43:04 -04:00
|
|
|
// WithKeyProducer provides an option types.NodeInformation
|
|
|
|
|
func WithKeyProducer(nodeInfo nodeenrollment.X25519KeyProducer) Option {
|
2023-03-25 13:47:39 -04:00
|
|
|
return func(o *options) {
|
2023-04-01 08:43:04 -04:00
|
|
|
o.withKeyProducer = nodeInfo
|
2023-03-25 13:47:39 -04:00
|
|
|
}
|
|
|
|
|
}
|