2022-05-11 10:05:13 +02:00
|
|
|
package tls
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
|
|
|
|
"k8s.io/client-go/rest"
|
|
|
|
)
|
|
|
|
|
2022-05-11 16:58:14 +02:00
|
|
|
// certificateProps Properties of TLS certificate which should be issued for webhook server
|
|
|
|
type certificateProps struct {
|
|
|
|
apiServerHost string
|
2022-05-11 10:05:13 +02:00
|
|
|
}
|
|
|
|
|
2022-05-11 16:58:14 +02:00
|
|
|
// newCertificateProps creates CertificateProps from a *rest.Config
|
|
|
|
func newCertificateProps(configuration *rest.Config) (*certificateProps, error) {
|
2022-05-11 10:05:13 +02:00
|
|
|
apiServerURL, err := url.Parse(configuration.Host)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2022-05-11 16:58:14 +02:00
|
|
|
return &certificateProps{
|
|
|
|
apiServerHost: apiServerURL.Hostname(),
|
2022-05-11 10:05:13 +02:00
|
|
|
}, nil
|
|
|
|
}
|