-
Notifications
You must be signed in to change notification settings - Fork 90
/
redeploy.go
56 lines (48 loc) · 1.39 KB
/
redeploy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package handlers
import (
"net/http"
"strconv"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/replicatedhq/kots/pkg/logger"
"github.com/replicatedhq/kots/pkg/store"
"github.com/replicatedhq/kots/pkg/version"
)
func (h *Handler) RedeployAppVersion(w http.ResponseWriter, r *http.Request) {
appSlug := mux.Vars(r)["appSlug"]
sequence, err := strconv.Atoi(mux.Vars(r)["sequence"])
if err != nil {
logger.Error(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
a, err := store.GetStore().GetAppFromSlug(appSlug)
if err != nil {
logger.Error(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
downstreams, err := store.GetStore().ListDownstreamsForApp(a.ID)
if err != nil {
err = errors.Wrap(err, "failed to list downstreams for app")
logger.Error(err)
w.WriteHeader(http.StatusInternalServerError)
return
} else if len(downstreams) == 0 {
err = errors.New("no downstreams for app")
logger.Error(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
if err := store.GetStore().DeleteDownstreamDeployStatus(a.ID, downstreams[0].ClusterID, int64(sequence)); err != nil {
logger.Error(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
if err := version.DeployVersion(a.ID, int64(sequence)); err != nil {
logger.Error(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
JSON(w, http.StatusNoContent, "")
}