-
Notifications
You must be signed in to change notification settings - Fork 90
/
app.go
54 lines (44 loc) · 1.46 KB
/
app.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
package app
import (
"time"
"github.com/pkg/errors"
"github.com/replicatedhq/kots/pkg/app/types"
"github.com/replicatedhq/kots/pkg/persistence"
)
// SetLastUpdateAtTime sets the time that the client last checked for an update to now
func SetLastUpdateAtTime(appID string, t time.Time) error {
db := persistence.MustGetDBSession()
query := `update app set last_update_check_at = $1 where id = $2`
_, err := db.Exec(query, t, appID)
if err != nil {
return errors.Wrap(err, "failed to update last_update_check_at")
}
return nil
}
func InitiateRestore(snapshotName string, appID string) error {
db := persistence.MustGetDBSession()
query := `update app set restore_in_progress_name = $1 where id = $2`
_, err := db.Exec(query, snapshotName, appID)
if err != nil {
return errors.Wrap(err, "failed to update restore_in_progress_name")
}
return nil
}
func ResetRestore(appID string) error {
db := persistence.MustGetDBSession()
query := `update app set restore_in_progress_name = NULL, restore_undeploy_status = '' where id = $1`
_, err := db.Exec(query, appID)
if err != nil {
return errors.Wrap(err, "failed to exec")
}
return nil
}
func SetRestoreUndeployStatus(appID string, undeployStatus types.UndeployStatus) error {
db := persistence.MustGetDBSession()
query := `update app set restore_undeploy_status = $1 where id = $2`
_, err := db.Exec(query, undeployStatus, appID)
if err != nil {
return errors.Wrap(err, "failed to exec")
}
return nil
}