code: func (m *Manager) UpsertRegistryEntry(username string, globalid string, registryEntry RegistryEntry) (err error) {
  	selector, err := createSelector(username, globalid, registryEntry.Key)
  	if err != nil {
  		return
  	}
  	result, err := m.getRegistryCollection().UpdateAll(selector, bson.M{"$set": bson.M{"entries.$.value": registryEntry.Value}})
  	if err == nil && result.Updated == 0 {
  		//Negate the selector on push so it is never pushed twice
  		if username != "" {
  			selector = bson.M{"username": username, "entries.key": bson.M{"$ne": registryEntry.Key}}
  		} else {
  			selector = bson.M{"globalid": globalid, "entries.key": bson.M{"$ne": registryEntry.Key}}
  		}
  		_, err = m.getRegistryCollection().Upsert(selector, bson.M{"$push": bson.M{"entries": &registryEntry}})
  	}
  	return
  }
docs: //UpsertRegistryEntry updates or inserts a registry entry
  // Either a username or a globalid needs to be given