// UpdateSplunk updates a specific splunk.
898
func (c *Client) UpdateSplunk(i *UpdateSplunkInput) (*Splunk, error) {
	if i.Service == "" {
		return nil, ErrMissingService
	}

	if i.Version == 0 {
		return nil, ErrMissingVersion
	}

	if i.Name == "" {
		return nil, ErrMissingName
	}

	path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.Service, i.Version, i.Name)
	resp, err := c.PutForm(path, i, nil)
	if err != nil {
		return nil, err
	}

	var s *Splunk
	if err := decodeJSON(&s, resp.Body); err != nil {
		return nil, err
	}
	return s, nil
}
174287
func (b *Backend) updateState(signature *tasks.Signature, update bson.M) error {
	update = bson.M{"$set": update}
	_, err := b.tasksCollection.UpdateOne(context.Background(), bson.M{"_id": signature.UUID}, update, options.Update().SetUpsert(true))
	return err
}
576790
func (s *Service) UpdateBucket(ctx context.Context, id platform.ID, upd platform.BucketUpdate) (*platform.Bucket, error) {
	b, err := s.FindBucketByID(ctx, id)
	if err != nil {
		return nil, &platform.Error{
			Op:  OpPrefix + platform.OpUpdateBucket,
			Err: err,
		}
	}

	if upd.Name != nil {
		b.Name = *upd.Name
	}

	if upd.RetentionPeriod != nil {
		b.RetentionPeriod = *upd.RetentionPeriod
	}

	s.bucketKV.Store(b.ID.String(), b)

	return b, nil
}
255495
func (c *FakeCronJobs) UpdateStatus(cronJob *v2alpha1.CronJob) (*v2alpha1.CronJob, error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateSubresourceAction(cronjobsResource, "status", c.ns, cronJob), &v2alpha1.CronJob{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v2alpha1.CronJob), err
}
12953
func (s *storeImpl) UpdateCurrentState(ctx datastore.Context, serviceID string, currentState string) error {
	plog.WithFields(log.Fields{
		"serviceID":    serviceID,
		"currentState": currentState,
	}).Debug("Storing currentState")
	s.updateCurrentState(serviceID, currentState, time.Now())
	return nil
}
527832
func updatePodContainers(params map[string]string, args []string, envs []v1.EnvVar, imagePullPolicy v1.PullPolicy, podSpec *v1.PodSpec) error {
	if len(args) > 0 {
		command, err := generate.GetBool(params, "command", false)
		if err != nil {
			return err
		}
		if command {
			podSpec.Containers[0].Command = args
		} else {
			podSpec.Containers[0].Args = args
		}
	}

	if len(envs) > 0 {
		podSpec.Containers[0].Env = envs
	}

	if len(imagePullPolicy) > 0 {
		// imagePullPolicy should be valid here since we have verified it before.
		podSpec.Containers[0].ImagePullPolicy = imagePullPolicy
	}
	return nil
}
691024
func (_m *APIClient) ContainerUpdate(ctx context.Context, _a1 string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) {
	ret := _m.Called(ctx, _a1, updateConfig)

	var r0 container.ContainerUpdateOKBody
	if rf, ok := ret.Get(0).(func(context.Context, string, container.UpdateConfig) container.ContainerUpdateOKBody); ok {
		r0 = rf(ctx, _a1, updateConfig)
	} else {
		r0 = ret.Get(0).(container.ContainerUpdateOKBody)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, string, container.UpdateConfig) error); ok {
		r1 = rf(ctx, _a1, updateConfig)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
269513
func UpdateState(conn client.Connection, req StateRequest, mutate func(*State) bool) error {
	logger := plog.WithFields(log.Fields{
		"hostid":     req.HostID,
		"serviceid":  req.ServiceID,
		"instanceid": req.InstanceID,
	})

	basepth := "/"
	if req.PoolID != "" {
		basepth = path.Join("/pools", req.PoolID)
	}

	// Get the current host state
	hspth := path.Join(basepth, "/hosts", req.HostID, "instances", req.StateID())
	hsdat := &HostState{}
	if err := conn.Get(hspth, hsdat); err != nil {

		logger.WithError(err).Debug("Could not look up host state")
		return &StateError{
			Request:   req,
			Operation: "update",
			Message:   "could not look up host state",
		}
	}

	// Get the current service state
	sspth := path.Join(basepth, "/services", req.ServiceID, req.StateID())
	ssdat := &ServiceState{}
	if err := conn.Get(sspth, ssdat); err != nil {

		logger.WithError(err).Debug("Could not look up service state")
		return &StateError{
			Request:   req,
			Operation: "update",
			Message:   "could not look up service state",
		}
	}

	// Get the current state (status)
	cspth := path.Join(sspth, "current")
	cstate := &CurrentStateContainer{}
	if err := conn.Get(cspth, cstate); err != nil {
		logger.WithError(err).Debug("Could not look up current state (status)")
		return &StateError{
			Request:   req,
			Operation: "update",
			Message:   "could not look up current state (status)",
		}
	}

	// mutate the states
	hsver, ssver, cstatever := hsdat.Version(), ssdat.Version(), cstate.Version()
	state := &State{
		HostState:             *hsdat,
		ServiceState:          *ssdat,
		CurrentStateContainer: *cstate,
		HostID:                req.HostID,
		ServiceID:             req.ServiceID,
		InstanceID:            req.InstanceID,
	}

	// only commit the transaction if mutate returns true
	if !mutate(state) {
		logger.Debug("Transaction aborted")
		return nil
	}

	// set the version object on the respective states
	*hsdat = state.HostState
	hsdat.SetVersion(hsver)
	*ssdat = state.ServiceState
	ssdat.SetVersion(ssver)
	*cstate = state.CurrentStateContainer
	cstate.SetVersion(cstatever)

	if err := conn.NewTransaction().Set(hspth, hsdat).Set(sspth, ssdat).Set(cspth, cstate).Commit(); err != nil {
		logger.WithError(err).Debug("Could not commit transaction")
		return &StateError{
			Request:   req,
			Operation: "update",
			Message:   "could not commit transaction",
		}
	}

	logger.Debug("Updated state")
	return nil
}
1168367
func (t *UpdateTaskRequest) UpdateFlux(oldFlux string) error {
	if t.Options.IsZero() {
		return nil
	}
	tu := platform.TaskUpdate{
		Options: t.Options,
		Flux:    &t.Script,
	}
	if err := tu.UpdateFlux(oldFlux); err != nil {
		return err
	}
	t.Script = *tu.Flux
	t.Options.Clear()
	return nil
}
1221871
func (c *Client) GetSplunk(i *GetSplunkInput) (*Splunk, error) {
	if i.Service == "" {
		return nil, ErrMissingService
	}

	if i.Version == 0 {
		return nil, ErrMissingVersion
	}

	if i.Name == "" {
		return nil, ErrMissingName
	}

	path := fmt.Sprintf("/service/%s/version/%d/logging/splunk/%s", i.Service, i.Version, i.Name)
	resp, err := c.Get(path, nil)
	if err != nil {
		return nil, err
	}

	var s *Splunk
	if err := decodeJSON(&s, resp.Body); err != nil {
		return nil, err
	}
	return s, nil
}
190493
func (t *TaskUpdate) UpdateFlux(oldFlux string) error {
	if t.Flux != nil && *t.Flux != "" {
		oldFlux = *t.Flux
	}
	toDelete := map[string]struct{}{}
	parsedPKG := parser.ParseSource(oldFlux)
	if ast.Check(parsedPKG) > 0 {
		return ast.GetError(parsedPKG)
	}
	parsed := parsedPKG.Files[0]
	if !t.Options.Every.IsZero() && t.Options.Cron != "" {
		return errors.New("cannot specify both cron and every")
	}
	op := make(map[string]ast.Expression, 4)

	if t.Options.Name != "" {
		op["name"] = &ast.StringLiteral{Value: t.Options.Name}
	}
	if !t.Options.Every.IsZero() {
		op["every"] = &t.Options.Every.Node
	}
	if t.Options.Cron != "" {
		op["cron"] = &ast.StringLiteral{Value: t.Options.Cron}
	}
	if t.Options.Offset != nil {
		if !t.Options.Offset.IsZero() {
			op["offset"] = &t.Options.Offset.Node
		} else {
			toDelete["offset"] = struct{}{}
		}
	}
	if len(op) > 0 || len(toDelete) > 0 {
		editFunc := func(opt *ast.OptionStatement) (ast.Expression, error) {
			a, ok := opt.Assignment.(*ast.VariableAssignment)
			if !ok {
				return nil, errors.New("option assignment must be variable assignment")
			}
			obj, ok := a.Init.(*ast.ObjectExpression)
			if !ok {
				return nil, fmt.Errorf("value is is %s, not an object expression", a.Init.Type())
			}
			// modify in the keys and values that already are in the ast
			for i, p := range obj.Properties {
				k := p.Key.Key()
				if _, ok := toDelete[k]; ok {
					obj.Properties = append(obj.Properties[:i], obj.Properties[i+1:]...)
				}
				switch k {
				case "name":
					if name, ok := op["name"]; ok && t.Options.Name != "" {
						delete(op, "name")
						p.Value = name
					}
				case "offset":
					if offset, ok := op["offset"]; ok && t.Options.Offset != nil {
						delete(op, "offset")
						p.Value = offset.Copy().(*ast.DurationLiteral)
					}
				case "every":
					if every, ok := op["every"]; ok && !t.Options.Every.IsZero() {
						p.Value = every.Copy().(*ast.DurationLiteral)
						delete(op, "every")
					} else if cron, ok := op["cron"]; ok && t.Options.Cron != "" {
						delete(op, "cron")
						p.Value = cron
						p.Key = &ast.Identifier{Name: "cron"}
					}
				case "cron":
					if cron, ok := op["cron"]; ok && t.Options.Cron != "" {
						delete(op, "cron")
						p.Value = cron
					} else if every, ok := op["every"]; ok && !t.Options.Every.IsZero() {
						delete(op, "every")
						p.Key = &ast.Identifier{Name: "every"}
						p.Value = every.Copy().(*ast.DurationLiteral)
					}
				}
			}
			// add in new keys and values to the ast
			for k := range op {
				obj.Properties = append(obj.Properties, &ast.Property{
					Key:   &ast.Identifier{Name: k},
					Value: op[k],
				})
			}
			return nil, nil
		}

		ok, err := edit.Option(parsed, "task", editFunc)

		if err != nil {
			return err
		}
		if !ok {
			return errors.New("unable to edit option")
		}

		t.Options.Clear()
		s := ast.Format(parsed)
		t.Flux = &s
	}
	return nil
}
1126334
func (vrsConnection VRSConnection) Update(context interface{}, tableUpdates libovsdb.TableUpdates) {
	vrsConnection.updatesChan <- &tableUpdates
}
502561
func (s *BucketService) UpdateBucket(ctx context.Context, id platform.ID, upd platform.BucketUpdate) (*platform.Bucket, error) {
	u, err := newURL(s.Addr, bucketIDPath(id))
	if err != nil {
		return nil, err
	}

	bu := newBucketUpdate(&upd)
	octets, err := json.Marshal(bu)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("PATCH", u.String(), bytes.NewReader(octets))
	if err != nil {
		return nil, err
	}

	req.Header.Set("Content-Type", "application/json")
	SetToken(s.Token, req)

	hc := newClient(u.Scheme, s.InsecureSkipVerify)

	resp, err := hc.Do(req)
	if err != nil {
		return nil, err
	}

	if err := CheckError(resp, true); err != nil {
		return nil, err
	}

	var br bucketResponse
	if err := json.NewDecoder(resp.Body).Decode(&br); err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	return br.toPlatform()
}
632078
func NewClientUpdater(client client.Client) UpdateFunc {
	return func(w *drone.Payload) {
		for {
			err := client.Push(w)
			if err == nil {
				return
			}
			logrus.Errorf("Error updating %s/%s#%d.%d. Retry in 30s. %s",
				w.Repo.Owner, w.Repo.Name, w.Build.Number, w.Job.Number, err)
			logrus.Infof("Retry update in 30s")
			time.Sleep(time.Second * 30)
		}
	}
}
1225206
func (c *FakePodPresets) Update(podPreset *v1alpha1.PodPreset) (result *v1alpha1.PodPreset, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateAction(podpresetsResource, c.ns, podPreset), &v1alpha1.PodPreset{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.PodPreset), err
}
899058
func (c *FakePersistentVolumes) Update(persistentVolume *corev1.PersistentVolume) (result *corev1.PersistentVolume, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootUpdateAction(persistentvolumesResource, persistentVolume), &corev1.PersistentVolume{})
	if obj == nil {
		return nil, err
	}
	return obj.(*corev1.PersistentVolume), err
}
913688
func (r *UpstreamService) Update(id string, upstream *Upstream) *UpstreamUpdateCall {
	c := &UpstreamUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.id = id
	c.upstream = upstream
	return c
}