Pass ImageStream to ubuntu-cloudimage-query command. #4480

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+10 −7
Split
View
@@ -142,7 +142,7 @@ func (h *imagesDownloadHandler) fetchAndCacheLxcImage(storage imagestorage.Stora
if err != nil {
return errors.Trace(err)
}
- imageURL, err := container.ImageDownloadURL(instance.LXC, series, arch, cfg.CloudImageBaseURL())
+ imageURL, err := container.ImageDownloadURL(instance.LXC, series, arch, cfg.CloudImageBaseURL(), cfg.ImageStream())
if err != nil {
return errors.Annotatef(err, "cannot determine LXC image URL: %v", err)
}
@@ -1005,7 +1005,8 @@ func (a *MachineAgent) updateSupportedContainers(
// adds additional fields, this fails.
container.ImageURLGetterConfig{
st.Addr(), envUUID.Id(), []byte(agentConfig.CACert()),
- cfg.CloudImageBaseURL(), container.ImageDownloadURL,
+ cfg.CloudImageBaseURL(), cfg.ImageStream(),
@mattyw

mattyw Feb 24, 2016

Member

This is sufficiently lengthy now to justify putting the field names explicitly:

EnvUUID: envUUID.Id(),
CloudimgBaseUrl: cfg.CloudImageBaseURL()
...
+ container.ImageDownloadURL,
})
}
params := provisioner.ContainerSetupParams{
View
@@ -32,7 +32,8 @@ type ImageURLGetterConfig struct {
EnvUUID string
CACert []byte
CloudimgBaseUrl string
- ImageDownloadFunc func(kind instance.ContainerType, series, arch, cloudimgBaseUrl string) (string, error)
+ CloudimgStream string
+ ImageDownloadFunc func(kind instance.ContainerType, series, arch, cloudimgBaseUrl, cloudimgStream string) (string, error)
}
type imageURLGetter struct {
@@ -47,7 +48,7 @@ func NewImageURLGetter(config ImageURLGetterConfig) ImageURLGetter {
// ImageURL is specified on the NewImageURLGetter interface.
func (ug *imageURLGetter) ImageURL(kind instance.ContainerType, series, arch string) (string, error) {
- imageURL, err := ug.config.ImageDownloadFunc(kind, series, arch, ug.config.CloudimgBaseUrl)
+ imageURL, err := ug.config.ImageDownloadFunc(kind, series, arch, ug.config.CloudimgBaseUrl, ug.config.CloudimgStream)
if err != nil {
return "", errors.Annotatef(err, "cannot determine LXC image URL: %v", err)
}
@@ -66,15 +67,15 @@ func (ug *imageURLGetter) CACert() []byte {
// ImageDownloadURL determines the public URL which can be used to obtain an
// image blob with the specified parameters.
-func ImageDownloadURL(kind instance.ContainerType, series, arch, cloudimgBaseUrl string) (string, error) {
+func ImageDownloadURL(kind instance.ContainerType, series, arch, cloudimgBaseUrl, cloudimgStream string) (string, error) {
@wallyworld

wallyworld Feb 25, 2016

Owner

please put the stream param after arch

func ImageDownloadURL(kind instance.ContainerType, series, arch, cloudimgStream, cloudimgBaseUrl string) (string, error) {

// TODO - we currently only need to support LXC images - kind is ignored.
if kind != instance.LXC {
return "", errors.Errorf("unsupported container type: %v", kind)
}
// Use the ubuntu-cloudimg-query command to get the url from which to fetch the image.
// This will be somewhere on http://cloud-images.ubuntu.com.
- cmd := exec.Command("ubuntu-cloudimg-query", series, "released", arch, "--format", "%{url}")
+ cmd := exec.Command("ubuntu-cloudimg-query", series, cloudimgStream, arch, "--format", "%{url}")
if cloudimgBaseUrl != "" {
// If the base url isn't specified, we don't need to copy the current
// environment, because this is the default behaviour of the exec package.
@@ -270,13 +270,14 @@ func (env *localEnviron) SetConfig(cfg *config.Config) error {
caCert = []byte(cert)
}
baseUrl := ecfg.CloudImageBaseURL()
+ stream := ecfg.ImageStream()
imageURLGetter = container.NewImageURLGetter(
// Explicitly call the non-named constructor so if anyone
// adds additional fields, this fails.
container.ImageURLGetterConfig{
ecfg.stateServerAddr(), uuid, caCert, baseUrl,
- container.ImageDownloadURL,
+ stream, container.ImageDownloadURL,
})
}