1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

lowercase the cmdline arg

This commit is contained in:
shivkumar dudhani 2020-01-08 16:40:19 -08:00
parent 38dcb2e94f
commit 1e5f871665
3 changed files with 9 additions and 9 deletions

View file

@ -32,7 +32,7 @@ var (
// will be removed in future and the configuration will be set only via configmaps // will be removed in future and the configuration will be set only via configmaps
filterK8Resources string filterK8Resources string
// User FQDN as CSR CN // User FQDN as CSR CN
FQDNCN bool fqdncn bool
) )
func main() { func main() {
@ -168,7 +168,7 @@ func main() {
policyMetaStore) policyMetaStore)
// CONFIGURE CERTIFICATES // CONFIGURE CERTIFICATES
tlsPair, err := client.InitTLSPemPair(clientConfig, FQDNCN) tlsPair, err := client.InitTLSPemPair(clientConfig, fqdncn)
if err != nil { if err != nil {
glog.Fatalf("Failed to initialize TLS key/certificate pair: %v\n", err) glog.Fatalf("Failed to initialize TLS key/certificate pair: %v\n", err)
} }
@ -247,7 +247,7 @@ func init() {
flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.") flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&serverIP, "serverIP", "", "IP address where Kyverno controller runs. Only required if out-of-cluster.") flag.StringVar(&serverIP, "serverIP", "", "IP address where Kyverno controller runs. Only required if out-of-cluster.")
// Generate CSR with CN as FQDN due to https://github.com/nirmata/kyverno/issues/542 // Generate CSR with CN as FQDN due to https://github.com/nirmata/kyverno/issues/542
flag.BoolVar(&FQDNCN, "FQDNAsCN", false, "use FQDN as Common Name in CSR") flag.BoolVar(&fqdncn, "fqdn-as-cn", false, "use FQDN as Common Name in CSR")
config.LogDefaultFlags() config.LogDefaultFlags()
flag.Parse() flag.Parse()
} }

View file

@ -18,7 +18,7 @@ import (
// InitTLSPemPair Loads or creates PEM private key and TLS certificate for webhook server. // InitTLSPemPair Loads or creates PEM private key and TLS certificate for webhook server.
// Created pair is stored in cluster's secret. // Created pair is stored in cluster's secret.
// Returns struct with key/certificate pair. // Returns struct with key/certificate pair.
func (c *Client) InitTLSPemPair(configuration *rest.Config, FQDNCN bool) (*tls.TlsPemPair, error) { func (c *Client) InitTLSPemPair(configuration *rest.Config, fqdncn bool) (*tls.TlsPemPair, error) {
certProps, err := c.GetTLSCertProps(configuration) certProps, err := c.GetTLSCertProps(configuration)
if err != nil { if err != nil {
return nil, err return nil, err
@ -26,7 +26,7 @@ func (c *Client) InitTLSPemPair(configuration *rest.Config, FQDNCN bool) (*tls.T
tlsPair := c.ReadTlsPair(certProps) tlsPair := c.ReadTlsPair(certProps)
if tls.IsTLSPairShouldBeUpdated(tlsPair) { if tls.IsTLSPairShouldBeUpdated(tlsPair) {
glog.Info("Generating new key/certificate pair for TLS") glog.Info("Generating new key/certificate pair for TLS")
tlsPair, err = c.generateTLSPemPair(certProps, FQDNCN) tlsPair, err = c.generateTLSPemPair(certProps, fqdncn)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -42,13 +42,13 @@ func (c *Client) InitTLSPemPair(configuration *rest.Config, FQDNCN bool) (*tls.T
//generateTlsPemPair Issues TLS certificate for webhook server using given PEM private key //generateTlsPemPair Issues TLS certificate for webhook server using given PEM private key
// Returns signed and approved TLS certificate in PEM format // Returns signed and approved TLS certificate in PEM format
func (c *Client) generateTLSPemPair(props tls.TlsCertificateProps, FQDNCN bool) (*tls.TlsPemPair, error) { func (c *Client) generateTLSPemPair(props tls.TlsCertificateProps, fqdncn bool) (*tls.TlsPemPair, error) {
privateKey, err := tls.TLSGeneratePrivateKey() privateKey, err := tls.TLSGeneratePrivateKey()
if err != nil { if err != nil {
return nil, err return nil, err
} }
certRequest, err := tls.CertificateGenerateRequest(privateKey, props, FQDNCN) certRequest, err := tls.CertificateGenerateRequest(privateKey, props, fqdncn)
if err != nil { if err != nil {
return nil, fmt.Errorf("Unable to create certificate request: %v", err) return nil, fmt.Errorf("Unable to create certificate request: %v", err)
} }

View file

@ -53,7 +53,7 @@ func certificateRequestToPem(csrRaw []byte) []byte {
} }
//CertificateGenerateRequest Generates raw certificate signing request //CertificateGenerateRequest Generates raw certificate signing request
func CertificateGenerateRequest(privateKey *rsa.PrivateKey, props TlsCertificateProps, FQDNCN bool) (*certificates.CertificateSigningRequest, error) { func CertificateGenerateRequest(privateKey *rsa.PrivateKey, props TlsCertificateProps, fqdncn bool) (*certificates.CertificateSigningRequest, error) {
dnsNames := make([]string, 3) dnsNames := make([]string, 3)
dnsNames[0] = props.Service dnsNames[0] = props.Service
dnsNames[1] = props.Service + "." + props.Namespace dnsNames[1] = props.Service + "." + props.Namespace
@ -61,7 +61,7 @@ func CertificateGenerateRequest(privateKey *rsa.PrivateKey, props TlsCertificate
commonName := GenerateInClusterServiceName(props) commonName := GenerateInClusterServiceName(props)
dnsNames[2] = commonName dnsNames[2] = commonName
csCommonName := props.Service csCommonName := props.Service
if FQDNCN { if fqdncn {
// use FQDN as CommonName as a workaournd for https://github.com/nirmata/kyverno/issues/542 // use FQDN as CommonName as a workaournd for https://github.com/nirmata/kyverno/issues/542
csCommonName = commonName csCommonName = commonName
} }