Skip to content

Commit

Permalink
Merge pull request #443 from mengqiy/conversionstatus
Browse files Browse the repository at this point in the history
🐛 set status in conversion response
  • Loading branch information
k8s-ci-robot committed May 24, 2019
2 parents e72b0e7 + 0af7a98 commit 13ee2bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/webhook/conversion/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ func (wh *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if err != nil {
log.Error(err, "failed to convert", "request", convertReview.Request.UID)
convertReview.Response = errored(err)
convertReview.Response.UID = convertReview.Request.UID
} else {
convertReview.Response = resp
}
convertReview.Response.UID = convertReview.Request.UID
convertReview.Request = nil

err = json.NewEncoder(w).Encode(convertReview)
if err != nil {
Expand Down Expand Up @@ -112,6 +113,9 @@ func (wh *Webhook) handleConvertRequest(req *apix.ConversionRequest) (*apix.Conv
return &apix.ConversionResponse{
UID: req.UID,
ConvertedObjects: objects,
Result: metav1.Status{
Status: metav1.StatusSuccess,
},
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/webhook/conversion/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ var _ = Describe("Conversion Webhook", func() {
convReview := doRequest(convReq)

Expect(convReview.Response.ConvertedObjects).To(HaveLen(1))
Expect(convReview.Response.Result.Status).To(Equal(metav1.StatusSuccess))
got, _, err := decoder.Decode(convReview.Response.ConvertedObjects[0].Raw)
Expect(err).NotTo(HaveOccurred())
Expect(got).To(Equal(expected))
Expand Down

0 comments on commit 13ee2bc

Please sign in to comment.