mirror of
https://github.com/rancher/os.git
synced 2025-08-08 10:08:04 +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")
|
image := c.String("image")
|
||||||
cfg := config.LoadConfig()
|
cfg := config.LoadConfig()
|
||||||
if image == "" {
|
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")
|
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)
|
// 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) {
|
if version.GreaterThan("v0.8.0-rc3", imageVersion) {
|
||||||
log.Infof("user specified to install pre v0.8.0: %s", image)
|
log.Infof("user specified to install pre v0.8.0: %s", image)
|
||||||
imageVersion = strings.Replace(imageVersion, "-", ".", -1)
|
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 {
|
func osMetaDataGet(c *cli.Context) error {
|
||||||
@ -133,6 +144,7 @@ func osMetaDataGet(c *cli.Context) error {
|
|||||||
|
|
||||||
cfg := config.LoadConfig()
|
cfg := config.LoadConfig()
|
||||||
runningName := cfg.Rancher.Upgrade.Image + ":" + config.Version
|
runningName := cfg.Rancher.Upgrade.Image + ":" + config.Version
|
||||||
|
runningName = formatImage(runningName, cfg)
|
||||||
|
|
||||||
foundRunning := false
|
foundRunning := false
|
||||||
for i := len(images.Available) - 1; i >= 0; i-- {
|
for i := len(images.Available) - 1; i >= 0; i-- {
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rancher/os/config"
|
||||||
"github.com/rancher/os/log"
|
"github.com/rancher/os/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,3 +20,11 @@ func yes(question string) bool {
|
|||||||
|
|
||||||
return strings.ToLower(line[0:1]) == "y"
|
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:
|
environment:
|
||||||
VERSION: {{.VERSION}}
|
VERSION: {{.VERSION}}
|
||||||
SUFFIX: {{.SUFFIX}}
|
SUFFIX: {{.SUFFIX}}
|
||||||
|
REGISTRY_DOMAIN: "docker.io"
|
||||||
defaults:
|
defaults:
|
||||||
hostname: {{.HOSTNAME_DEFAULT}}
|
hostname: {{.HOSTNAME_DEFAULT}}
|
||||||
{{if eq "amd64" .ARCH -}}
|
{{if eq "amd64" .ARCH -}}
|
||||||
|
Loading…
Reference in New Issue
Block a user