提供检查边缘节点新版本接口

This commit is contained in:
刘祥超
2021-01-31 11:03:47 +08:00
parent 458690f22e
commit f482867211

View File

@@ -14,6 +14,7 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/types" "github.com/iwind/TeaGo/types"
stringutil "github.com/iwind/TeaGo/utils/string"
"net" "net"
) )
@@ -1254,3 +1255,17 @@ func (this *NodeService) FindEnabledNodesWithIds(ctx context.Context, req *pb.Fi
} }
return &pb.FindEnabledNodesWithIdsResponse{Nodes: pbNodes}, nil return &pb.FindEnabledNodesWithIdsResponse{Nodes: pbNodes}, nil
} }
// 检查新版本
func (this *NodeService) CheckNodeLatestVersion(ctx context.Context, req *pb.CheckNodeLatestVersionRequest) (*pb.CheckNodeLatestVersionResponse, error) {
deployFiles := installers.SharedDeployManager.LoadFiles()
for _, file := range deployFiles {
if file.OS == req.Os && file.Arch == req.Arch && stringutil.VersionCompare(file.Version, req.CurrentVersion) > 0 {
return &pb.CheckNodeLatestVersionResponse{
HasNewVersion: true,
NewVersion: file.Version,
}, nil
}
}
return &pb.CheckNodeLatestVersionResponse{HasNewVersion: false}, nil
}