2021-08-18 15:30:55 +02:00
|
|
|
package proxy
|
|
|
|
|
|
2021-09-17 11:26:04 -07:00
|
|
|
import (
|
2021-12-17 11:26:42 -08:00
|
|
|
serverpb "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
2021-09-17 11:26:04 -07:00
|
|
|
)
|
|
|
|
|
|
2021-08-18 15:30:55 +02:00
|
|
|
// Option - how Options are passed as arguments.
|
2021-09-17 11:26:04 -07:00
|
|
|
type Option func(*Options)
|
|
|
|
|
|
|
|
|
|
// GetOpts - iterate the inbound Options and return a struct.
|
|
|
|
|
func GetOpts(opt ...Option) Options {
|
|
|
|
|
opts := getDefaultOptions()
|
|
|
|
|
for _, o := range opt {
|
|
|
|
|
o(&opts)
|
|
|
|
|
}
|
|
|
|
|
return opts
|
|
|
|
|
}
|
2021-08-18 15:30:55 +02:00
|
|
|
|
2021-09-17 11:26:04 -07:00
|
|
|
// Options = how options are represented
|
|
|
|
|
type Options struct {
|
2021-12-17 11:26:42 -08:00
|
|
|
WithEgressCredentials []*serverpb.Credential
|
2021-09-17 11:26:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getDefaultOptions() Options {
|
|
|
|
|
return Options{
|
|
|
|
|
WithEgressCredentials: nil,
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-18 15:30:55 +02:00
|
|
|
|
2021-09-17 11:26:04 -07:00
|
|
|
// WithEgressCredentials provides an optional egress credentials to use when establishing a proxy
|
2021-12-17 11:26:42 -08:00
|
|
|
func WithEgressCredentials(creds []*serverpb.Credential) Option {
|
2021-09-17 11:26:04 -07:00
|
|
|
return func(o *Options) {
|
|
|
|
|
o.WithEgressCredentials = creds
|
|
|
|
|
}
|
2021-08-18 15:30:55 +02:00
|
|
|
}
|