for _, ch := range charms {
if ch.IsPlaceholder() {
logger.Debugf("skipping %s, placeholder charm", ch.URL())
continue
}
if !ch.IsUploaded() {
logger.Debugf("skipping %s, not uploaded to provider storage", ch.URL())
continue
}
if charmStoragePath(ch) != "" {
logger.Debugf("skipping %s, already in environment storage", ch.URL())
continue
}
url := charmBundleURL(ch)
if url == nil {
logger.Debugf("skipping %s, has no bundle URL", ch.URL())
continue
}
uuid, err := utils.NewUUID()
if err != nil {
return err
}
data, err := fetchCharmArchive(url)
if err != nil {
return err
}
curl := ch.URL()
storagePath := fmt.Sprintf("charms/%s-%s", curl, uuid)
logger.Debugf("uploading %s to %q in environment storage", curl, storagePath)
err = storage.Put(storagePath, bytes.NewReader(data), int64(len(data)))
if err != nil {
return errors.Annotatef(err, "failed to upload %s to storage", curl)
}
storagePaths[curl] = storagePath
}