|
|
@@ -36,6 +36,15 @@ func NewEnablePullRequestHandler(
|
|
|
func (c *EnablePullRequestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
project, _ := r.Context().Value(types.ProjectScope).(*models.Project)
|
|
|
cluster, _ := r.Context().Value(types.ClusterScope).(*models.Cluster)
|
|
|
+
|
|
|
+ if !project.PreviewEnvsEnabled {
|
|
|
+ c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(errPreviewProjectDisabled, http.StatusForbidden))
|
|
|
+ return
|
|
|
+ } else if !cluster.PreviewEnvsEnabled {
|
|
|
+ c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(errPreviewClusterDisabled, http.StatusForbidden))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
request := &types.PullRequest{}
|
|
|
|
|
|
if ok := c.DecodeAndValidate(w, r, request); !ok {
|