Merge remote-tracking branch 'goodrain/V5.2' into V5.2

This commit is contained in:
GLYASAI 2020-04-15 19:01:48 +08:00
commit 3caf812ccb
2 changed files with 12 additions and 4 deletions

View File

@ -384,8 +384,8 @@ func (i *ImportApp) importPlugins() error {
return err return err
} }
// 上传到仓库 // 上传到仓库
user := plugin.Get("plugin_image.hub_user").String() // get docker account user and pass
pass := plugin.Get("plugin_image.hub_password").String() user, pass := builder.GetImageUserInfo(plugin.Get("plugin_image.hub_user").String(), plugin.Get("plugin_image.hub_password").String())
// 上传之前先要根据新的仓库地址修改镜像名 // 上传之前先要根据新的仓库地址修改镜像名
image := i.oldPluginPath[plugin.Get("plugin_id").String()] image := i.oldPluginPath[plugin.Get("plugin_id").String()]
imageName := sources.ImageNameWithNamespaceHandle(image) imageName := sources.ImageNameWithNamespaceHandle(image)
@ -437,8 +437,8 @@ func (i *ImportApp) loadApps() error {
// 上传到仓库 // 上传到仓库
oldImage := i.oldAPPPath[app.Get("service_key").String()] oldImage := i.oldAPPPath[app.Get("service_key").String()]
oldImageName := sources.ImageNameWithNamespaceHandle(oldImage) oldImageName := sources.ImageNameWithNamespaceHandle(oldImage)
user := app.Get("service_image.hub_user").String() // get docker account user and pass
pass := app.Get("service_image.hub_password").String() user, pass := builder.GetImageUserInfo(app.Get("service_image.hub_user").String(), app.Get("service_image.hub_password").String())
// 上传之前先要根据新的仓库地址修改镜像名 // 上传之前先要根据新的仓库地址修改镜像名
image := app.Get("share_image").String() image := app.Get("share_image").String()
if err := sources.ImageTag(i.DockerClient, fmt.Sprintf("%s/%s:%s", builder.REGISTRYDOMAIN, oldImageName.Name, oldImageName.Tag), image, i.Logger, 15); err != nil { if err := sources.ImageTag(i.DockerClient, fmt.Sprintf("%s/%s:%s", builder.REGISTRYDOMAIN, oldImageName.Name, oldImageName.Tag), image, i.Logger, 15); err != nil {

View File

@ -48,6 +48,14 @@ func init() {
BUILDERIMAGENAME = path.Join(REGISTRYDOMAIN, BUILDERIMAGENAME) BUILDERIMAGENAME = path.Join(REGISTRYDOMAIN, BUILDERIMAGENAME)
} }
// GetImageUserInfo -
func GetImageUserInfo(user, pass string) (string, string) {
if user != "" && pass != "" {
return user, pass
}
return REGISTRYUSER, REGISTRYPASS
}
//REGISTRYDOMAIN REGISTRY_DOMAIN //REGISTRYDOMAIN REGISTRY_DOMAIN
var REGISTRYDOMAIN = constants.DefImageRepository var REGISTRYDOMAIN = constants.DefImageRepository