code: func (v VersionsFile) AddVersion(pkg, ver, iid string) error {
  	if err := common.ValidatePackageName(pkg); err != nil {
  		return err
  	}
  	if err := common.ValidateInstanceVersion(ver); err != nil {
  		return err
  	}
  	if err := common.ValidateInstanceID(iid, common.AnyHash); err != nil {
  		return err
  	}
  
  	if common.ValidateInstanceID(ver, common.AnyHash) == nil {
  		if ver != iid {
  			return errors.Reason(
  				"version given as instance ID (%q) should resolve into that ID, not into %q",
  				ver, iid).Err()
  		}
  		return nil
  	}
  
  	v[unresolvedVer{pkg, ver}] = iid
  	return nil
  }
docs: // AddVersion adds (or overrides) an instance ID mapped to the given version.
  //
  // Returns an error if any of the arguments is invalid.
  //
  // If 'ver' is already an instance ID, just checks if it is equal to 'iid' and
  // silently doesn't modify the map.