forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listen_arg.go
32 lines (25 loc) · 1004 Bytes
/
listen_arg.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
package start
import (
"github.com/spf13/pflag"
"github.com/openshift/origin/pkg/cmd/flagtypes"
)
// ListenArg is a struct that the command stores flag values into.
type ListenArg struct {
// ListenAddr is the address to listen for connections on (scheme://host:port).
ListenAddr flagtypes.Addr
}
// BindListenArg binds values to the given arguments by using flags
func BindListenArg(args *ListenArg, flags *pflag.FlagSet, prefix string) {
flags.Var(&args.ListenAddr, prefix+"listen", "The address to listen for connections on (scheme://host:port).")
}
// NewDefaultListenArg returns a new address to listen for connections
func NewDefaultListenArg() *ListenArg {
config := &ListenArg{
ListenAddr: flagtypes.Addr{Value: "0.0.0.0:8443", DefaultScheme: "https", DefaultPort: 8443, AllowPrefix: true}.Default(),
}
return config
}
// UseTLS checks whether the address we listen for connections uses TLS or not
func (l *ListenArg) UseTLS() bool {
return l.ListenAddr.URL.Scheme == "https"
}