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:
parent
d263be4bae
commit
f6a76a10ae
@ -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)
|
||||
|
@ -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-- {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ rancher:
|
||||
environment:
|
||||
VERSION: {{.VERSION}}
|
||||
SUFFIX: {{.SUFFIX}}
|
||||
REGISTRY_DOMAIN: "docker.io"
|
||||
defaults:
|
||||
hostname: {{.HOSTNAME_DEFAULT}}
|
||||
{{if eq "amd64" .ARCH -}}
|
||||
|
Loading…
Reference in New Issue
Block a user