// UpdateCurrent updates the meta data for a specific role
502470
func (st *MemStorage) UpdateCurrent(gun data.GUN, update MetaUpdate) error {
	id := entryKey(gun, update.Role)
	st.lock.Lock()
	defer st.lock.Unlock()
	if space, ok := st.tufMeta[id]; ok {
		for _, v := range space {
			if v.version >= update.Version {
				return ErrOldVersion{}
			}
		}
	}
	version := ver{version: update.Version, data: update.Data, createupdate: time.Now()}
	st.tufMeta[id] = append(st.tufMeta[id], version)
	checksumBytes := sha256.Sum256(update.Data)
	checksum := hex.EncodeToString(checksumBytes[:])

	_, ok := st.checksums[gun.String()]
	if !ok {
		st.checksums[gun.String()] = make(map[string]ver)
	}
	st.checksums[gun.String()][checksum] = version
	if update.Role == data.CanonicalTimestampRole {
		st.writeChange(gun, update.Version, checksum)
	}
	return nil
}
250874
func (s *ProductionVariantSummary) SetCurrentWeight(v float64) *ProductionVariantSummary {
	s.CurrentWeight = &v
	return s
}
496471
func (c *Client) UpdateRP(ctx context.Context, db string, rp string, upd *chronograf.RetentionPolicy) (*chronograf.RetentionPolicy, error) {
	var buffer bytes.Buffer
	buffer.WriteString(fmt.Sprintf(`ALTER RETENTION POLICY "%s" ON "%s"`, rp, db))
	if len(upd.Duration) > 0 {
		buffer.WriteString(" DURATION " + upd.Duration)
	}
	if upd.Replication > 0 {
		buffer.WriteString(" REPLICATION " + fmt.Sprint(upd.Replication))
	}
	if len(upd.ShardDuration) > 0 {
		buffer.WriteString(" SHARD DURATION " + upd.ShardDuration)
	}
	if upd.Default {
		buffer.WriteString(" DEFAULT")
	}
	queryRes, err := c.Query(ctx, chronograf.Query{
		Command: buffer.String(),
		DB:      db,
		RP:      rp,
	})
	if err != nil {
		return nil, err
	}

	// The ALTER RETENTION POLICIES statements puts the error within the results itself
	// So, we have to crack open the results to see what happens
	octets, err := queryRes.MarshalJSON()
	if err != nil {
		return nil, err
	}

	results := make([]struct{ Error string }, 0)
	if err := json.Unmarshal(octets, &results); err != nil {
		return nil, err
	}

	// At last, we can check if there are any error strings
	for _, r := range results {
		if r.Error != "" {
			return nil, fmt.Errorf(r.Error)
		}
	}

	res, err := c.getRP(ctx, db, upd.Name)
	if err != nil {
		return nil, err
	}

	return &res, nil
}
617504
func CreateOrUpdateRole(client clientset.Interface, role *rbac.Role) error {
	if _, err := client.RbacV1().Roles(role.ObjectMeta.Namespace).Create(role); err != nil {
		if !apierrors.IsAlreadyExists(err) {
			return errors.Wrap(err, "unable to create RBAC role")
		}

		if _, err := client.RbacV1().Roles(role.ObjectMeta.Namespace).Update(role); err != nil {
			return errors.Wrap(err, "unable to update RBAC role")
		}
	}
	return nil
}
1087
func (s *RedshiftInstanceDetails) SetCurrentGeneration(v bool) *RedshiftInstanceDetails {
	s.CurrentGeneration = &v
	return s
}
1325143
func UpdateIPRole(client *TwilioIPMessagingClient, serviceSid string, sid string, friendlyName string, kind string, permissions []string) (*IPRole, error) {
	var role *IPRole

	params := url.Values{}
	params.Set("FriendlyName", friendlyName)
	params.Set("Type", kind)
	if permissions != nil {
		for _, p := range permissions {
			params.Add("Permission", p)
		}
	}

	res, err := client.post(params, "/Services/"+serviceSid+"/Roles/"+sid+".json")

	if err != nil {
		return role, err
	}

	role = new(IPRole)
	err = json.Unmarshal(res, role)

	return role, err
}
1291904
func (s *GetOfferingStatusOutput) SetCurrent(v map[string]*OfferingStatus) *GetOfferingStatusOutput {
	s.Current = v
	return s
}
21443
func (opc *operationCallbacks) SetCurrentCharm(charmURL *corecharm.URL) error {
	return opc.u.unit.SetCharmURL(charmURL)
}
1141587
func (m *Mercury) UpdateContainer(ctx context.Context, container *types.Container) error {
	return m.doOpsContainer(ctx, container, false)
}
849209
func (s *RoleService) UpdateRole(p *UpdateRoleParams) (*UpdateRoleResponse, error) {
	resp, err := s.cs.newRequest("updateRole", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r UpdateRoleResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
1005026
func (st *MemStorage) GetCurrent(gun data.GUN, role data.RoleName) (*time.Time, []byte, error) {
	id := entryKey(gun, role)
	st.lock.Lock()
	defer st.lock.Unlock()
	space, ok := st.tufMeta[id]
	if !ok || len(space) == 0 {
		return nil, nil, ErrNotFound{}
	}
	return &(space[len(space)-1].createupdate), space[len(space)-1].data, nil
}
1306930
func GetCurrentUser(req *http.Request) *users.User {
	if currentUser, ok := auth.Auth.GetCurrentUser(req).(*users.User); ok {
		return currentUser
	}
	return nil
}
1259443
func (p *ProgressBar) UpdateRequired() bool {
	return p.Current == 0 || p.Current == p.Total
}
505938
func (s *GameSession) SetCurrentPlayerSessionCount(v int64) *GameSession {
	s.CurrentPlayerSessionCount = &v
	return s
}
258850
func (s *server) updateCurrentTerm(term uint64, leaderName string) {
	_assert(term > s.currentTerm,
		"upadteCurrentTerm: update is called when term is not larger than currentTerm")

	// Store previous values temporarily.
	prevTerm := s.currentTerm
	prevLeader := s.leader

	// set currentTerm = T, convert to follower (§5.1)
	// stop heartbeats before step-down
	if s.state == Leader {
		for _, peer := range s.peers {
			peer.stopHeartbeat(false)
		}
	}
	// update the term and clear vote for
	if s.state != Follower {
		s.setState(Follower)
	}

	s.mutex.Lock()
	s.currentTerm = term
	s.leader = leaderName
	s.votedFor = ""
	s.mutex.Unlock()

	// Dispatch change events.
	s.DispatchEvent(newEvent(TermChangeEventType, s.currentTerm, prevTerm))

	if prevLeader != s.leader {
		s.DispatchEvent(newEvent(LeaderChangeEventType, s.leader, prevLeader))
	}
}
568228
func (s *Configurations) SetCurrent(v *ConfigurationId) *Configurations {
	s.Current = v
	return s
}
1327064
func (d *DropDown) SetCurrentOption(index int) *DropDown {
	if index >= 0 && index < len(d.options) {
		d.currentOption = index
		d.list.SetCurrentItem(index)
		if d.selected != nil {
			d.selected(d.options[index].Text, index)
		}
		if d.options[index].Selected != nil {
			d.options[index].Selected()
		}
	} else {
		d.currentOption = -1
		d.list.SetCurrentItem(0) // Set to 0 because -1 means "last item".
		if d.selected != nil {
			d.selected("", -1)
		}
	}
	return d
}