@@ -15,14 +15,17 @@ limitations under the License.
1515package main
1616
1717import (
18- flag "github.com/spf13/pflag"
19- "log"
18+ "flag"
19+ "github.com/golang/glog"
20+ "github.com/spf13/pflag"
2021 "net/http"
2122
22- "git.openstack.org/openstack/openstack-cloud-controller-manager/pkg/authenticator/token /keystone"
23+ "git.openstack.org/openstack/openstack-cloud-controller-manager/pkg/identity /keystone"
2324 "git.openstack.org/openstack/openstack-cloud-controller-manager/pkg/identity/webhook"
2425 "k8s.io/apiserver/pkg/authentication/authenticator"
2526 "k8s.io/apiserver/pkg/authorization/authorizer"
27+ kflag "k8s.io/apiserver/pkg/util/flag"
28+ "k8s.io/apiserver/pkg/util/logs"
2629)
2730
2831func webhookServer (authenticator authenticator.Token , authorizer authorizer.Authorizer ) http.Handler {
@@ -42,35 +45,39 @@ var (
4245)
4346
4447func main () {
45- flag .StringVar (& listenAddr , "listen" , "localhost:8443" , "<address>:<port> to listen on" )
46- flag .StringVar (& tlsCertFile , "tls-cert-file" , "" , "File containing the default x509 Certificate for HTTPS." )
47- flag .StringVar (& tlsPrivateKey , "tls-private-key-file" , "" , "File containing the default x509 private key matching --tls-cert-file." )
48- flag .StringVar (& keystoneURL , "keystone-url" , "http://localhost/identity/v3/" , "URL for the OpenStack Keystone API" )
49- flag .StringVar (& keystoneCaFile , "keystone-ca-file" , "" , "File containing the certificate authority for Keystone Service." )
50- flag .StringVar (& policyFile , "keystone-policy-file" , "" , "File containing the policy." )
51- flag .Parse ()
48+ flag .CommandLine .Parse ([]string {})
49+ pflag .StringVar (& listenAddr , "listen" , "0.0.0.0:8443" , "<address>:<port> to listen on" )
50+ pflag .StringVar (& tlsCertFile , "tls-cert-file" , "" , "File containing the default x509 Certificate for HTTPS." )
51+ pflag .StringVar (& tlsPrivateKey , "tls-private-key-file" , "" , "File containing the default x509 private key matching --tls-cert-file." )
52+ pflag .StringVar (& keystoneURL , "keystone-url" , "http://localhost/identity/v3/" , "URL for the OpenStack Keystone API" )
53+ pflag .StringVar (& keystoneCaFile , "keystone-ca-file" , "" , "File containing the certificate authority for Keystone Service." )
54+ pflag .StringVar (& policyFile , "keystone-policy-file" , "" , "File containing the policy." )
55+
56+ kflag .InitFlags ()
57+ logs .InitLogs ()
58+ defer logs .FlushLogs ()
5259
5360 if tlsCertFile == "" || tlsPrivateKey == "" {
54- log .Fatal ("Please specify --tls-cert-file and --tls-private-key-file arguments." )
61+ glog .Fatal ("Please specify --tls-cert-file and --tls-private-key-file arguments." )
5562 }
5663 if policyFile == "" {
57- log . Printf ("Argument --keystone-policy-file missing. Only keystone authentication will work. Use RBAC for authorization." )
64+ glog . Infof ("Argument --keystone-policy-file missing. Only keystone authentication will work. Use RBAC for authorization." )
5865 }
5966
6067 authentication_handler , err := keystone .NewKeystoneAuthenticator (keystoneURL , keystoneCaFile )
6168 if err != nil {
62- log .Fatal (err .Error ())
69+ glog .Fatal (err .Error ())
6370 }
6471
6572 authorization_handler , err := keystone .NewKeystoneAuthorizer (keystoneURL , keystoneCaFile , policyFile )
6673 if err != nil {
67- log .Fatal (err .Error ())
74+ glog .Fatal (err .Error ())
6875 }
6976
7077 http .Handle ("/webhook" , webhookServer (authentication_handler , authorization_handler ))
71- log . Println ("Starting webhook.." )
72- log .Fatal (
73- http .ListenAndServeTLS (":8443" ,
78+ glog . Infof ("Starting webhook.." )
79+ glog .Fatal (
80+ http .ListenAndServeTLS (listenAddr ,
7481 tlsCertFile ,
7582 tlsPrivateKey ,
7683 nil ))
0 commit comments