@@ -17,16 +17,16 @@ limitations under the License.
1717package options
1818
1919import (
20- "flag"
2120 "fmt"
2221
23- "github.com/golang/glog "
22+ "github.com/spf13/pflag "
2423
2524 "k8s.io/api/admissionregistration/v1beta1"
2625 apierrors "k8s.io/apimachinery/pkg/api/errors"
2726 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2827 "k8s.io/client-go/kubernetes"
2928 admissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1"
29+ "k8s.io/klog"
3030)
3131
3232const (
@@ -58,27 +58,27 @@ func NewConfig() *Config {
5858}
5959
6060// AddFlags add flags
61- func (c * Config ) AddFlags () {
62- flag .StringVar (& c .Master , "master" , c .Master , "The address of the Kubernetes API server (overrides any value in kubeconfig)" )
63- flag .StringVar (& c .Kubeconfig , "kubeconfig" , c .Kubeconfig , "Path to kubeconfig file with authorization and master location information." )
64- flag .StringVar (& c .CertFile , "tls-cert-file" , c .CertFile , "" +
61+ func (c * Config ) AddFlags (fs * pflag. FlagSet ) {
62+ fs .StringVar (& c .Master , "master" , c .Master , "The address of the Kubernetes API server (overrides any value in kubeconfig)" )
63+ fs .StringVar (& c .Kubeconfig , "kubeconfig" , c .Kubeconfig , "Path to kubeconfig file with authorization and master location information." )
64+ fs .StringVar (& c .CertFile , "tls-cert-file" , c .CertFile , "" +
6565 "File containing the default x509 Certificate for HTTPS. (CA cert, if any, concatenated " +
6666 "after server cert)." )
67- flag .StringVar (& c .KeyFile , "tls-private-key-file" , c .KeyFile , "File containing the default x509 private key matching --tls-cert-file." )
68- flag .StringVar (& c .CaCertFile , "ca-cert-file" , c .CaCertFile , "File containing the x509 Certificate for HTTPS." )
69- flag .IntVar (& c .Port , "port" , 443 , "the port used by admission-controller-server." )
70- flag .StringVar (& c .MutateWebhookConfigName , "mutate-webhook-config-name" , "" ,
67+ fs .StringVar (& c .KeyFile , "tls-private-key-file" , c .KeyFile , "File containing the default x509 private key matching --tls-cert-file." )
68+ fs .StringVar (& c .CaCertFile , "ca-cert-file" , c .CaCertFile , "File containing the x509 Certificate for HTTPS." )
69+ fs .IntVar (& c .Port , "port" , 443 , "the port used by admission-controller-server." )
70+ fs .StringVar (& c .MutateWebhookConfigName , "mutate-webhook-config-name" , "" ,
7171 "Name of the mutatingwebhookconfiguration resource in Kubernetes [Deprecated]: it will be generated when not specified." )
72- flag .StringVar (& c .MutateWebhookName , "mutate-webhook-name" , "" ,
72+ fs .StringVar (& c .MutateWebhookName , "mutate-webhook-name" , "" ,
7373 "Name of the webhook entry in the webhook config. [Deprecated]: it will be generated when not specified" )
74- flag .StringVar (& c .ValidateWebhookConfigName , "validate-webhook-config-name" , "" ,
74+ fs .StringVar (& c .ValidateWebhookConfigName , "validate-webhook-config-name" , "" ,
7575 "Name of the mutatingwebhookconfiguration resource in Kubernetes. [Deprecated]: it will be generated when not specified" )
76- flag .StringVar (& c .ValidateWebhookName , "validate-webhook-name" , "" ,
76+ fs .StringVar (& c .ValidateWebhookName , "validate-webhook-name" , "" ,
7777 "Name of the webhook entry in the webhook config. [Deprecated]: it will be generated when not specified" )
78- flag .BoolVar (& c .PrintVersion , "version" , false , "Show version and quit" )
79- flag .StringVar (& c .AdmissionServiceNamespace , "webhook-namespace" , "default" , "The namespace of this webhook" )
80- flag .StringVar (& c .AdmissionServiceName , "webhook-service-name" , "admission-service" , "The name of this admission service" )
81- flag .StringVar (& c .SchedulerName , "scheduler-name" , defaultSchedulerName , "Volcano will handle pods whose .spec.SchedulerName is same as scheduler-name" )
78+ fs .BoolVar (& c .PrintVersion , "version" , false , "Show version and quit" )
79+ fs .StringVar (& c .AdmissionServiceNamespace , "webhook-namespace" , "default" , "The namespace of this webhook" )
80+ fs .StringVar (& c .AdmissionServiceName , "webhook-service-name" , "admission-service" , "The name of this admission service" )
81+ fs .StringVar (& c .SchedulerName , "scheduler-name" , defaultSchedulerName , "Volcano will handle pods whose .spec.SchedulerName is same as scheduler-name" )
8282}
8383
8484const (
@@ -235,13 +235,13 @@ func registerMutateWebhook(client admissionregistrationv1beta1.MutatingWebhookCo
235235 return err
236236 }
237237 if err == nil && existing != nil {
238- glog .Infof ("Updating MutatingWebhookConfiguration %v" , hook )
238+ klog .Infof ("Updating MutatingWebhookConfiguration %v" , hook )
239239 existing .Webhooks = hook .Webhooks
240240 if _ , err := client .Update (existing ); err != nil {
241241 return err
242242 }
243243 } else {
244- glog .Infof ("Creating MutatingWebhookConfiguration %v" , hook )
244+ klog .Infof ("Creating MutatingWebhookConfiguration %v" , hook )
245245 if _ , err := client .Create (& hook ); err != nil {
246246 return err
247247 }
@@ -259,12 +259,12 @@ func registerValidateWebhook(client admissionregistrationv1beta1.ValidatingWebho
259259 }
260260 if err == nil && existing != nil {
261261 existing .Webhooks = hook .Webhooks
262- glog .Infof ("Updating ValidatingWebhookConfiguration %v" , hook )
262+ klog .Infof ("Updating ValidatingWebhookConfiguration %v" , hook )
263263 if _ , err := client .Update (existing ); err != nil {
264264 return err
265265 }
266266 } else {
267- glog .Infof ("Creating ValidatingWebhookConfiguration %v" , hook )
267+ klog .Infof ("Creating ValidatingWebhookConfiguration %v" , hook )
268268 if _ , err := client .Create (& hook ); err != nil {
269269 return err
270270 }
0 commit comments