|
|
@@ -602,7 +602,8 @@ func (app *App) HandleGetReleaseAllPods(w http.ResponseWriter, r *http.Request)
|
|
|
}
|
|
|
|
|
|
type GetJobStatusResult struct {
|
|
|
- Status string `json:"status"`
|
|
|
+ Status string `json:"status,omitempty"`
|
|
|
+ StartTime *metav1.Time `json:"start_time,omitempty"`
|
|
|
}
|
|
|
|
|
|
// HandleGetJobStatus gets the status for a specific job
|
|
|
@@ -692,9 +693,7 @@ func (app *App) HandleGetJobStatus(w http.ResponseWriter, r *http.Request) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- res := &GetJobStatusResult{
|
|
|
- Status: "succeeded",
|
|
|
- }
|
|
|
+ res := &GetJobStatusResult{}
|
|
|
|
|
|
// get the most recent job
|
|
|
if len(jobs) > 0 {
|
|
|
@@ -708,6 +707,8 @@ func (app *App) HandleGetJobStatus(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ res.StartTime = mostRecentJob.Status.StartTime
|
|
|
+
|
|
|
// get the status of the most recent job
|
|
|
if mostRecentJob.Status.Succeeded >= 1 {
|
|
|
res.Status = "succeeded"
|
|
|
@@ -1017,8 +1018,27 @@ func (app *App) HandleUpgradeRelease(w http.ResponseWriter, r *http.Request) {
|
|
|
conf.Chart = chart
|
|
|
}
|
|
|
|
|
|
+ rel, upgradeErr := agent.UpgradeRelease(conf, form.Values, app.DOConf)
|
|
|
+
|
|
|
slackInts, _ := app.Repo.SlackIntegration.ListSlackIntegrationsByProjectID(uint(projID))
|
|
|
- notifier := slack.NewSlackNotifier(slackInts...)
|
|
|
+
|
|
|
+ clusterID, err := strconv.ParseUint(vals["cluster_id"][0], 10, 64)
|
|
|
+ release, _ := app.Repo.Release.ReadRelease(uint(clusterID), name, form.Namespace)
|
|
|
+
|
|
|
+ var notifConf *models.NotificationConfigExternal
|
|
|
+ notifConf = nil
|
|
|
+ if release != nil && release.NotificationConfig != 0 {
|
|
|
+ conf, err := app.Repo.NotificationConfig.ReadNotificationConfig(release.NotificationConfig)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ app.handleErrorInternal(err, w)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ notifConf = conf.Externalize()
|
|
|
+ }
|
|
|
+
|
|
|
+ notifier := slack.NewSlackNotifier(notifConf, slackInts...)
|
|
|
|
|
|
notifyOpts := &slack.NotifyOpts{
|
|
|
ProjectID: uint(projID),
|
|
|
@@ -1035,18 +1055,16 @@ func (app *App) HandleUpgradeRelease(w http.ResponseWriter, r *http.Request) {
|
|
|
) + fmt.Sprintf("?project_id=%d", uint(projID)),
|
|
|
}
|
|
|
|
|
|
- rel, err := agent.UpgradeRelease(conf, form.Values, app.DOConf)
|
|
|
-
|
|
|
- if err != nil {
|
|
|
+ if upgradeErr != nil {
|
|
|
notifyOpts.Status = slack.StatusFailed
|
|
|
- notifyOpts.Info = err.Error()
|
|
|
+ notifyOpts.Info = upgradeErr.Error()
|
|
|
|
|
|
slackErr := notifier.Notify(notifyOpts)
|
|
|
fmt.Println("SLACK ERROR IS", slackErr)
|
|
|
|
|
|
app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
Code: ErrReleaseDeploy,
|
|
|
- Errors: []string{err.Error()},
|
|
|
+ Errors: []string{upgradeErr.Error()},
|
|
|
}, w)
|
|
|
|
|
|
return
|
|
|
@@ -1059,8 +1077,6 @@ func (app *App) HandleUpgradeRelease(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
// update the github actions env if the release exists and is built from source
|
|
|
if cName := rel.Chart.Metadata.Name; cName == "job" || cName == "web" || cName == "worker" {
|
|
|
- clusterID, err := strconv.ParseUint(vals["cluster_id"][0], 10, 64)
|
|
|
-
|
|
|
if err != nil {
|
|
|
app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
Code: ErrReleaseReadData,
|
|
|
@@ -1070,8 +1086,6 @@ func (app *App) HandleUpgradeRelease(w http.ResponseWriter, r *http.Request) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- release, err := app.Repo.Release.ReadRelease(uint(clusterID), name, rel.Namespace)
|
|
|
-
|
|
|
if release != nil {
|
|
|
// update image repo uri if changed
|
|
|
repository := rel.Config["image"].(map[string]interface{})["repository"]
|
|
|
@@ -1250,7 +1264,21 @@ func (app *App) HandleReleaseDeployWebhook(w http.ResponseWriter, r *http.Reques
|
|
|
}
|
|
|
|
|
|
slackInts, _ := app.Repo.SlackIntegration.ListSlackIntegrationsByProjectID(uint(form.ReleaseForm.Cluster.ProjectID))
|
|
|
- notifier := slack.NewSlackNotifier(slackInts...)
|
|
|
+
|
|
|
+ var notifConf *models.NotificationConfigExternal
|
|
|
+ notifConf = nil
|
|
|
+ if release != nil && release.NotificationConfig != 0 {
|
|
|
+ conf, err := app.Repo.NotificationConfig.ReadNotificationConfig(release.NotificationConfig)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ app.handleErrorInternal(err, w)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ notifConf = conf.Externalize()
|
|
|
+ }
|
|
|
+
|
|
|
+ notifier := slack.NewSlackNotifier(notifConf, slackInts...)
|
|
|
|
|
|
notifyOpts := &slack.NotifyOpts{
|
|
|
ProjectID: uint(form.ReleaseForm.Cluster.ProjectID),
|