|
|
@@ -1,7 +1,6 @@
|
|
|
package environment
|
|
|
|
|
|
import (
|
|
|
- "bytes"
|
|
|
"fmt"
|
|
|
"net/http"
|
|
|
"strconv"
|
|
|
@@ -77,12 +76,24 @@ func (c *EnablePullRequestHandler) ServeHTTP(w http.ResponseWriter, r *http.Requ
|
|
|
},
|
|
|
)
|
|
|
|
|
|
- buf := new(bytes.Buffer)
|
|
|
- buf.ReadFrom(ghResp.Body)
|
|
|
-
|
|
|
- if ghResp != nil && ghResp.StatusCode == 404 {
|
|
|
- c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(fmt.Errorf("workflow file not found"), 404))
|
|
|
- return
|
|
|
+ if ghResp != nil {
|
|
|
+ if ghResp.StatusCode == 404 {
|
|
|
+ c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(
|
|
|
+ fmt.Errorf(
|
|
|
+ "Please make sure the preview environment workflow files are present in PR branch %s and are up to"+
|
|
|
+ " date with the default branch", request.BranchFrom,
|
|
|
+ ), 404),
|
|
|
+ )
|
|
|
+ return
|
|
|
+ } else if ghResp.StatusCode == 422 {
|
|
|
+ c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(
|
|
|
+ fmt.Errorf(
|
|
|
+ "Please make sure the workflow files in PR branch %s are up to date with the default branch",
|
|
|
+ request.BranchFrom,
|
|
|
+ ), 422),
|
|
|
+ )
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if err != nil {
|