61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
package servicemesh
|
|
|
|
import "github.com/spf13/pflag"
|
|
|
|
type ServiceMeshOptions struct {
|
|
|
|
// istio pilot discovery service url
|
|
IstioPilotHost string `json:"istioPilotHost,omitempty" yaml:"istioPilotHost,omitempty"`
|
|
|
|
// jaeger query service url
|
|
JaegerQueryHost string `json:"jaegerQueryHost,omitempty" yaml:"jaegerQueryHost,omitempty"`
|
|
|
|
// prometheus service url for servicemesh metrics
|
|
ServicemeshPrometheusHost string `json:"servicemeshPrometheusHost,omitempty" yaml:"servicemeshPrometheusHost,omitempty"`
|
|
}
|
|
|
|
// NewServiceMeshOptions returns a `zero` instance
|
|
func NewServiceMeshOptions() *ServiceMeshOptions {
|
|
return &ServiceMeshOptions{
|
|
IstioPilotHost: "",
|
|
JaegerQueryHost: "",
|
|
ServicemeshPrometheusHost: "",
|
|
}
|
|
}
|
|
|
|
func (s *ServiceMeshOptions) Validate() []error {
|
|
errors := []error{}
|
|
|
|
return errors
|
|
}
|
|
|
|
func (s *ServiceMeshOptions) ApplyTo(options *ServiceMeshOptions) {
|
|
if options == nil {
|
|
options = s
|
|
return
|
|
}
|
|
|
|
if s.ServicemeshPrometheusHost != "" {
|
|
options.ServicemeshPrometheusHost = s.ServicemeshPrometheusHost
|
|
}
|
|
|
|
if s.JaegerQueryHost != "" {
|
|
options.JaegerQueryHost = s.JaegerQueryHost
|
|
}
|
|
|
|
if s.IstioPilotHost != "" {
|
|
options.IstioPilotHost = s.IstioPilotHost
|
|
}
|
|
}
|
|
|
|
func (s *ServiceMeshOptions) AddFlags(fs *pflag.FlagSet) {
|
|
fs.StringVar(&s.IstioPilotHost, "istio-pilot-host", s.IstioPilotHost, ""+
|
|
"istio pilot discovery service url")
|
|
|
|
fs.StringVar(&s.JaegerQueryHost, "jaeger-query-host", s.JaegerQueryHost, ""+
|
|
"jaeger query service url")
|
|
|
|
fs.StringVar(&s.ServicemeshPrometheusHost, "servicemesh-prometheus-host", s.ServicemeshPrometheusHost, ""+
|
|
"prometheus service for servicemesh")
|
|
}
|