Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongxuanzhang committed Feb 1, 2022
1 parent 853fd90 commit a38f423
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/pod/entrypoint_lookup_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,18 @@ func newfakeHTTP() fakeHTTP {
}

func (f *fakeHTTP) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Requests to container registry except "GET" will be handled by the registry handler.
if r.Header["User-Agent"][0] == "go-containerregistry" && !(strings.HasPrefix(r.URL.Path, "/v2/task") && r.Method == "GET") {
f.reg.ServeHTTP(w, r)
return
}

// For Ping requests, the server will need basic authenticaion and reutrn 401
if r.Header["Authorization"] == nil {
w.Header().Add("WWW-Authenticate", "basic")
w.WriteHeader(401)
} else {
// Handle the requests with matching authorization.
auth := strings.Split(r.Header["Authorization"][0], " ")[1]
if auth == base64.StdEncoding.EncodeToString([]byte(username+":"+password)) {
f.reg.ServeHTTP(w, r)
Expand Down

0 comments on commit a38f423

Please sign in to comment.