code: func (m *EC2Manifest) Add(version string, image *EC2Image) {
  	versions := make(sortVersions, 0, len(m.Versions)+1)
  	for _, v := range m.Versions {
  		if v.version() == version {
  			images := make([]*EC2Image, len(v.Images))
  			added := false
  			for n, i := range v.Images {
  				if i.Region == image.Region {
  					// replace existing image
  					images[n] = image
  					added = true
  					continue
  				}
  				images[n] = i
  			}
  			if !added {
  				images = append(images, image)
  			}
  			v.Images = images
  			return
  		}
  		versions = append(versions, v)
  	}
  	versions = append(versions, &EC2Version{
  		Version: version,
  		Images:  []*EC2Image{image},
  	})
  	sort.Sort(sort.Reverse(versions))
  	m.Versions = make([]*EC2Version, 0, maxVersions)
  	for i := 0; i < len(versions) && i < maxVersions; i++ {
  		m.Versions = append(m.Versions, versions[i].(*EC2Version))
  	}
  }
docs: // Add adds an image to the manifest.
  //
  // If the version is already in the manifest, the given image either
  // replaces any existing image with the same region, or is appended to
  // the existing list of images for that version.
  //
  // If the version is not already in the manifest a new version is added
  // containing the image.
  //
  // The number of versions in the manifest is capped at the value of maxVersions.