Skip to content

Commit

Permalink
Merge pull request #10955 from azhao155/yzhao/feature/replaceGlogWith…
Browse files Browse the repository at this point in the history
…Klog

Replace glog with klog
  • Loading branch information
medyagh authored Mar 29, 2021
2 parents 83c56e0 + fc7195c commit 4d38650
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
19 changes: 9 additions & 10 deletions cmd/auto-pause/auto-pause-hook/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

"github.com/golang/glog"
"k8s.io/klog/v2"
)

var (
Expand All @@ -41,11 +40,11 @@ var (
func client() *kubernetes.Clientset {
config, err := rest.InClusterConfig()
if err != nil {
glog.Fatal(err)
klog.Fatal(err)
}
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
glog.Fatal(err)
klog.Fatal(err)
}
return clientset
}
Expand All @@ -55,14 +54,14 @@ func client() *kubernetes.Clientset {
func apiServerCert(clientset *kubernetes.Clientset) []byte {
c, err := clientset.CoreV1().ConfigMaps("kube-system").Get(context.TODO(), "extension-apiserver-authentication", metav1.GetOptions{})
if err != nil {
glog.Fatal(err)
klog.Fatal(err)
}

pem, ok := c.Data["requestheader-client-ca-file"]
if !ok {
glog.Fatalf(fmt.Sprintf("cannot find the ca.crt in the configmap, configMap.Data is %#v", c.Data))
klog.Fatalf(fmt.Sprintf("cannot find the ca.crt in the configmap, configMap.Data is %#v", c.Data))
}
glog.Info("client-ca-file=", pem)
klog.Info("client-ca-file=", pem)
return []byte(pem)
}

Expand All @@ -73,7 +72,7 @@ func configTLS(clientset *kubernetes.Clientset, serverCert []byte, serverKey []b

sCert, err := tls.X509KeyPair(serverCert, serverKey)
if err != nil {
glog.Fatal(err)
klog.Fatal(err)
}
return &tls.Config{
Certificates: []tls.Certificate{sCert},
Expand All @@ -89,7 +88,7 @@ func selfRegistration(clientset *kubernetes.Clientset, caCert []byte) {
_, err := client.Get(context.TODO(), webhookName, metav1.GetOptions{})
if err == nil {
if err2 := client.Delete(context.TODO(), webhookName, metav1.DeleteOptions{}); err2 != nil {
glog.Fatal(err2)
klog.Fatal(err2)
}
}
var failurePolicy v1.FailurePolicyType = v1.Fail
Expand Down Expand Up @@ -142,7 +141,7 @@ func selfRegistration(clientset *kubernetes.Clientset, caCert []byte) {
},
}
if _, err := client.Create(context.TODO(), webhookConfig, metav1.CreateOptions{}); err != nil {
glog.Fatalf("Client creation failed with %s", err)
klog.Fatalf("Client creation failed with %s", err)
}
log.Println("CLIENT CREATED")
}
4 changes: 2 additions & 2 deletions cmd/auto-pause/auto-pause-hook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import (
"net/http"
"strconv"

"github.com/golang/glog"
"github.com/mattbaird/jsonpatch"

v1 "k8s.io/api/admission/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/constants"
)

Expand Down Expand Up @@ -171,6 +171,6 @@ func main() {
go selfRegistration(clientset, cacert)
err := server.ListenAndServeTLS("", "")
if err != nil {
glog.Fatalf("Start https server failed with %s", err)
klog.Fatalf("Start https server failed with %s", err)
}
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ require (
github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f
github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/google/go-cmp v0.5.5
github.com/google/go-containerregistry v0.4.1
github.com/google/go-github v17.0.0+incompatible
Expand Down

0 comments on commit 4d38650

Please sign in to comment.