mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
refactor: replace upgrader with version package for runtime and release information
This commit is contained in:
parent
8e212ae79b
commit
d0cf93d5e3
11 changed files with 182 additions and 121 deletions
|
@ -3,13 +3,6 @@ package upgrader
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
_github "github.com/0xJacky/Nginx-UI/.github"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/jpillora/overseer"
|
||||
"github.com/minio/selfupdate"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -18,19 +11,40 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
_github "github.com/0xJacky/Nginx-UI/.github"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/version"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/jpillora/overseer"
|
||||
"github.com/minio/selfupdate"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
UpgradeStatusInfo = "info"
|
||||
UpgradeStatusError = "error"
|
||||
UpgradeStatusProgress = "progress"
|
||||
)
|
||||
|
||||
type CoreUpgradeResp struct {
|
||||
Status string `json:"status"`
|
||||
Progress float64 `json:"progress"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type Upgrader struct {
|
||||
Release TRelease
|
||||
RuntimeInfo
|
||||
Release version.TRelease
|
||||
version.RuntimeInfo
|
||||
}
|
||||
|
||||
func NewUpgrader(channel string) (u *Upgrader, err error) {
|
||||
data, err := GetRelease(channel)
|
||||
data, err := version.GetRelease(channel)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
runtimeInfo, err := GetRuntimeInfo()
|
||||
runtimeInfo, err := version.GetRuntimeInfo()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue