diff --git a/cmd/control/install.go b/cmd/control/install.go index 874bd87d..d9c8b7d7 100755 --- a/cmd/control/install.go +++ b/cmd/control/install.go @@ -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) diff --git a/cmd/control/os.go b/cmd/control/os.go index c7c14772..ff196576 100644 --- a/cmd/control/os.go +++ b/cmd/control/os.go @@ -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-- { diff --git a/cmd/control/util.go b/cmd/control/util.go index 5e83803e..7df8b9aa 100644 --- a/cmd/control/util.go +++ b/cmd/control/util.go @@ -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 +} diff --git a/os-config.tpl.yml b/os-config.tpl.yml index 73d4b50f..c89d9860 100644 --- a/os-config.tpl.yml +++ b/os-config.tpl.yml @@ -3,6 +3,7 @@ rancher: environment: VERSION: {{.VERSION}} SUFFIX: {{.SUFFIX}} + REGISTRY_DOMAIN: "docker.io" defaults: hostname: {{.HOSTNAME_DEFAULT}} {{if eq "amd64" .ARCH -}}