code: func PutDescToIndex(index *v1.Index, desc v1.Descriptor, tag string) error {
  	if index == nil {
  		index = &v1.Index{}
  	}
  	if index.SchemaVersion == 0 {
  		index.SchemaVersion = 2
  	}
  	if tag != "" {
  		if desc.Annotations == nil {
  			desc.Annotations = make(map[string]string)
  		}
  		desc.Annotations[v1.AnnotationRefName] = tag
  		// remove existing manifests with the same tag
  		var manifests []v1.Descriptor
  		for _, m := range index.Manifests {
  			if m.Annotations[v1.AnnotationRefName] != tag {
  				manifests = append(manifests, m)
  			}
  		}
  		index.Manifests = manifests
  	}
  	index.Manifests = append(index.Manifests, desc)
  	return nil
  }
docs: // PutDescToIndex puts desc to index with tag.
  // Existing manifests with the same tag will be removed from the index.