1
0
mirror of https://github.com/rancher/os.git synced 2025-07-31 22:47:16 +00:00

Config ROS image prefix for install and all rancher/os services (#2272)

This commit is contained in:
niusmallnan 2018-03-06 18:07:21 +08:00 committed by GitHub
parent d263be4bae
commit f6a76a10ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 3 deletions

View File

@ -121,7 +121,11 @@ func installAction(c *cli.Context) error {
image := c.String("image")
cfg := config.LoadConfig()
if image == "" {
image = cfg.Rancher.Upgrade.Image + ":" + config.Version + config.Suffix
image = fmt.Sprintf("%s:%s%s",
cfg.Rancher.Upgrade.Image,
config.Version,
config.Suffix)
image = formatImage(image, cfg)
}
installType := c.String("install-type")
@ -202,7 +206,7 @@ func runInstall(image, installType, cloudConfig, device, partition, statedir, ka
}
// Versions before 0.8.0-rc3 use the old calling convention (from the lay-down-os shell script)
imageVersion := strings.TrimPrefix(image, "rancher/os:")
imageVersion := strings.Split(image, ":")[1]
if version.GreaterThan("v0.8.0-rc3", imageVersion) {
log.Infof("user specified to install pre v0.8.0: %s", image)
imageVersion = strings.Replace(imageVersion, "-", ".", -1)

View File

@ -117,7 +117,18 @@ func getImages() (*Images, error) {
}
}
return parseBody(body)
images, err := parseBody(body)
if err != nil {
return nil, err
}
cfg := config.LoadConfig()
images.Current = formatImage(images.Current, cfg)
for i := len(images.Available) - 1; i >= 0; i-- {
images.Available[i] = formatImage(images.Available[i], cfg)
}
return images, nil
}
func osMetaDataGet(c *cli.Context) error {
@ -133,6 +144,7 @@ func osMetaDataGet(c *cli.Context) error {
cfg := config.LoadConfig()
runningName := cfg.Rancher.Upgrade.Image + ":" + config.Version
runningName = formatImage(runningName, cfg)
foundRunning := false
for i := len(images.Available) - 1; i >= 0; i-- {

View File

@ -6,6 +6,7 @@ import (
"os"
"strings"
"github.com/rancher/os/config"
"github.com/rancher/os/log"
)
@ -19,3 +20,11 @@ func yes(question string) bool {
return strings.ToLower(line[0:1]) == "y"
}
func formatImage(image string, cfg *config.CloudConfig) string {
domainRegistry := cfg.Rancher.Environment["REGISTRY_DOMAIN"]
if domainRegistry != "docker.io" && domainRegistry != "" {
return fmt.Sprintf("%s/%s", domainRegistry, image)
}
return image
}

View File

@ -3,6 +3,7 @@ rancher:
environment:
VERSION: {{.VERSION}}
SUFFIX: {{.SUFFIX}}
REGISTRY_DOMAIN: "docker.io"
defaults:
hostname: {{.HOSTNAME_DEFAULT}}
{{if eq "amd64" .ARCH -}}