37 Star 404 Fork 74

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
upgrader.go 857 Bytes
一键复制 编辑 原始数据 按行查看 历史
Aiwantaozi 提交于 2018-08-27 19:40 . support upgrade system service
package systemimage
import (
"context"
"crypto/sha1"
"encoding/json"
"fmt"
"github.com/rancher/types/config"
"github.com/sirupsen/logrus"
)
var systemServices = make(map[string]SystemService)
type SystemService interface {
Init(ctx context.Context, cluster *config.UserContext)
Upgrade(currentVersion string) (newVersion string, err error)
Version() (string, error)
}
func RegisterSystemService(name string, systemService SystemService) {
if _, exists := systemServices[name]; exists {
logrus.Errorf("system service '%s' tried to register twice", name)
}
systemServices[name] = systemService
}
func DefaultGetVersion(obj interface{}) (string, error) {
b, err := json.Marshal(obj)
if err != nil {
return "", fmt.Errorf("marshal obj failed when get system image version: %v", err)
}
return fmt.Sprintf("%x", sha1.Sum(b))[:7], nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.3-rc2

搜索帮助