|
|
@@ -29,8 +29,15 @@ func NewCreatePreflightCheckAWSUsageHandler(
|
|
|
}
|
|
|
|
|
|
func (p *CreatePreflightCheckAWSUsageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
- project, _ := r.Context().Value(types.ProjectScope).(*models.Project)
|
|
|
ctx := r.Context()
|
|
|
+ project, _ := ctx.Value(types.ProjectScope).(*models.Project)
|
|
|
+
|
|
|
+ if !p.Config().EnableCAPIProvisioner {
|
|
|
+ message := "Trying to run preflight checks but CAPI Provisioner is disabled. If you want to provision through CAPI, make sure that the environment variable ENABLE_CAPI_PROVISIONER is set to true"
|
|
|
+ e := fmt.Errorf(message)
|
|
|
+ p.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(e, http.StatusServiceUnavailable, message))
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
request := &types.QuotaPreflightCheckRequest{}
|
|
|
if ok := p.DecodeAndValidate(w, r, request); !ok {
|