-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Craig O'Donnell
committed
Jun 17, 2024
1 parent
289b309
commit ae26b69
Showing
4 changed files
with
88 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package handlers | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gorilla/mux" | ||
"github.com/pkg/errors" | ||
"github.com/replicatedhq/kots/pkg/logger" | ||
preflighttypes "github.com/replicatedhq/kots/pkg/preflight/types" | ||
upgradepreflight "github.com/replicatedhq/kots/pkg/upgradeservice/preflight" | ||
) | ||
|
||
type GetPreflightResultResponse struct { | ||
PreflightProgress string `json:"preflightProgress,omitempty"` | ||
PreflightResult preflighttypes.PreflightResult `json:"preflightResult"` | ||
} | ||
|
||
func (h *Handler) GetPreflightResult(w http.ResponseWriter, r *http.Request) { | ||
params := GetContextParams(r) | ||
appSlug := mux.Vars(r)["appSlug"] | ||
|
||
if params.AppSlug != appSlug { | ||
logger.Error(errors.Errorf("app slug in path %s does not match app slug in context %s", appSlug, params.AppSlug)) | ||
w.WriteHeader(http.StatusForbidden) | ||
return | ||
} | ||
|
||
preflightData, err := upgradepreflight.GetPreflightData() | ||
if err != nil { | ||
logger.Error(errors.Wrap(err, "failed to get preflight data")) | ||
w.WriteHeader(http.StatusInternalServerError) | ||
return | ||
} | ||
|
||
response := GetPreflightResultResponse{ | ||
PreflightResult: *preflightData.Result, | ||
PreflightProgress: preflightData.Progress, | ||
} | ||
JSON(w, 200, response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters