-
Notifications
You must be signed in to change notification settings - Fork 0
/
recommended.go
48 lines (39 loc) · 1017 Bytes
/
recommended.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package options
import (
"flag"
"github.com/appscode/grpc-go-addons/server"
"github.com/spf13/pflag"
)
type RecommendedOptions struct {
Cors *CorsOptions
SecureServing *SecureServingOptions
}
func NewRecommendedOptions() *RecommendedOptions {
return &RecommendedOptions{
Cors: NewCORSOptions(),
SecureServing: NewSecureServingOptions(),
}
}
func (o *RecommendedOptions) AddGoFlags(fs *flag.FlagSet) {
o.Cors.AddGoFlags(fs)
o.SecureServing.AddGoFlags(fs)
}
func (o *RecommendedOptions) AddFlags(fs *pflag.FlagSet) {
o.Cors.AddFlags(fs)
o.SecureServing.AddFlags(fs)
}
func (o *RecommendedOptions) ApplyTo(config *server.Config) error {
if err := o.Cors.ApplyTo(config); err != nil {
return err
}
if err := o.SecureServing.ApplyTo(config); err != nil {
return err
}
return nil
}
func (o *RecommendedOptions) Validate() []error {
var errors []error
errors = append(errors, o.Cors.Validate()...)
errors = append(errors, o.SecureServing.Validate()...)
return errors
}