api/pkg/cert/defaults.go
Peter Kurfer 7c2a41ad25 Move TLS/cert handling to main app
- apply changes in proxy plugin and TLS interceptor
- add HTTPS proxy support
- move ca-generation command to main app
- minor refactoring to improve API stability
- move mocks to extra packages to avoid cycling imports
- fix bug in multi-port configuration
- change HTTP proxy to redirect to HTTP mock instead of maintaining custom rules
2020-04-26 00:32:46 +02:00

43 lines
813 B
Go

package cert
import (
"github.com/baez90/inetmock/pkg/defaulting"
"reflect"
)
var (
certOptionsDefaulter defaulting.Defaulter = func(instance interface{}) {
switch o := instance.(type) {
case *GenerationOptions:
if len(o.Country) < 1 {
o.Country = []string{"US"}
}
if len(o.Locality) < 1 {
o.Locality = []string{"San Francisco"}
}
if len(o.Organization) < 1 {
o.Organization = []string{"INetMock"}
}
if len(o.StreetAddress) < 1 {
o.StreetAddress = []string{"Golden Gate Bridge"}
}
if len(o.PostalCode) < 1 {
o.PostalCode = []string{"94016"}
}
if len(o.Province) < 1 {
o.Province = []string{""}
}
}
}
)
func init() {
certOptionsType := reflect.TypeOf(GenerationOptions{})
defaulters.Register(certOptionsType, certOptionsDefaulter)
}