Skip to content

Commit

Permalink
Use authentication/v1 api
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha committed Feb 18, 2018
1 parent eab6c03 commit 59f928b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion cmds/webhok_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/appscode/kutil/tools/certstore"
"github.com/spf13/afero"
"github.com/spf13/cobra"
auth "k8s.io/api/authentication/v1"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
"k8s.io/client-go/util/cert"
Expand Down Expand Up @@ -85,7 +86,7 @@ func NewCmdGetWebhookConfig() *cobra.Command {
APIVersion: "v1",
Clusters: map[string]*clientcmdapi.Cluster{
"guard-server": {
Server: fmt.Sprintf("https://%s/apis/authentication.k8s.io/v1/tokenreviews", addr),
Server: fmt.Sprintf("https://%s/apis/%s/tokenreviews", addr, auth.SchemeGroupVersion),
CertificateAuthorityData: caCert,
},
},
Expand Down
4 changes: 2 additions & 2 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/tls"
"crypto/x509"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
_ "net/http/pprof"
Expand All @@ -18,6 +19,7 @@ import (
"github.com/appscode/pat"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/spf13/pflag"
auth "k8s.io/api/authentication/v1"
)

type Server struct {
Expand Down Expand Up @@ -106,7 +108,7 @@ func (s Server) ListenAndServe() {
tlsConfig.BuildNameToCertificate()

m := pat.New()
m.Post("/apis/authentication.k8s.io/v1/tokenreviews", s)
m.Post(fmt.Sprintf("/apis/%s/tokenreviews", auth.SchemeGroupVersion), s)
m.Get("/metrics", promhttp.Handler())
m.Get("/healthz", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(200)
Expand Down
6 changes: 2 additions & 4 deletions lib/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const apiVersion = "authentication.k8s.io/v1"

// Write replies to the request with the specified TokenReview object and HTTP code.
// It does not otherwise end the request; the caller should ensure no further
// writes are done to w.
Expand All @@ -19,7 +17,7 @@ func Write(w http.ResponseWriter, data auth.TokenReview, code int) {
w.Header().Set("x-content-type-options", "nosniff")
w.WriteHeader(code)
data.TypeMeta = metav1.TypeMeta{
APIVersion: apiVersion,
APIVersion: auth.SchemeGroupVersion.String(),
Kind: "TokenReview",
}
json.NewEncoder(w).Encode(data)
Expand All @@ -30,7 +28,7 @@ func Error(err string) auth.TokenReview {
log.Errorln(err)
return auth.TokenReview{
TypeMeta: metav1.TypeMeta{
APIVersion: apiVersion,
APIVersion: auth.SchemeGroupVersion.String(),
Kind: "TokenReview",
},
Status: auth.TokenReviewStatus{
Expand Down

0 comments on commit 59f928b

Please sign in to comment.