micro/util/kubernetes/client/options.go

53 lines
1.0 KiB
Go
Raw Normal View History

2019-12-24 20:33:05 +03:00
package client
type DeploymentOptions struct {
BaseImage string
}
2019-12-24 20:33:05 +03:00
type LogOptions struct {
Params map[string]string
}
type WatchOptions struct {
Params map[string]string
}
2019-12-24 20:33:05 +03:00
type LogOption func(*LogOptions)
type WatchOption func(*WatchOptions)
type DeploymentOption func(*DeploymentOptions)
2019-12-24 20:33:05 +03:00
// LogParams provides additional params for logs
func LogParams(p map[string]string) LogOption {
return func(l *LogOptions) {
l.Params = p
}
}
// WatchParams used for watch params
func WatchParams(p map[string]string) WatchOption {
return func(w *WatchOptions) {
w.Params = p
}
}
// WithBaseImage sets the base image for the deployment
func WithBaseImage(img string) DeploymentOption {
return func(d *DeploymentOptions) {
d.BaseImage = img
}
}
// NewDeploymentOptions returns an initialized DeploymentOptions
func NewDeploymentOptions(opts []DeploymentOption) DeploymentOptions {
var options DeploymentOptions
for _, o := range opts {
o(&options)
}
if options.BaseImage == "" {
options.BaseImage = DefaultImage
}
return options
}