38 lines
1,017 B
Go
38 lines
1,017 B
Go
package internal
|
|
|
|
import (
|
|
"net/url"
|
|
)
|
|
|
|
var EtcdDefaultArgs = []string{
|
|
"--listen-peer-urls=http://localhost:0",
|
|
"--advertise-client-urls={{ if .URL }}{{ .URL.String }}{{ end }}",
|
|
"--listen-client-urls={{ if .URL }}{{ .URL.String }}{{ end }}",
|
|
"--data-dir={{ .DataDir }}",
|
|
}
|
|
|
|
func DoEtcdArgDefaulting(args []string) []string {
|
|
if len(args) != 0 {
|
|
return args
|
|
}
|
|
|
|
return EtcdDefaultArgs
|
|
}
|
|
|
|
func isSecureScheme(scheme string) bool {
|
|
// https://github.com/coreos/etcd/blob/d9deeff49a080a88c982d328ad9d33f26d1ad7b6/pkg/transport/listener.go#L53
|
|
if scheme == "https" || scheme == "unixs" {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func GetEtcdStartMessage(listenUrl url.URL) string {
|
|
if isSecureScheme(listenUrl.Scheme) {
|
|
// https://github.com/coreos/etcd/blob/a7f1fbe00ec216fcb3a1919397a103b41dca8413/embed/serve.go#L167
|
|
return "serving client requests on "
|
|
}
|
|
|
|
// https://github.com/coreos/etcd/blob/a7f1fbe00ec216fcb3a1919397a103b41dca8413/embed/serve.go#L124
|
|
return "serving insecure client requests on "
|
|
}
|