// Update replaces a dashboard from the file system directory
11531
func (d *Dashboards) Update(ctx context.Context, dashboard chronograf.Dashboard) error {
	board, _, err := d.idToFile(dashboard.ID)
	if err != nil {
		return err
	}

	if err := d.Delete(ctx, board); err != nil {
		return err
	}
	file := dashboardFile(d.Dir, dashboard)
	return d.Create(file, dashboard)
}
1141601
func (c *ksmdCollector) Update(ch chan<- prometheus.Metric) error {
	for _, n := range ksmdFiles {
		val, err := readUintFromFile(sysFilePath(filepath.Join("kernel/mm/ksm", n)))
		if err != nil {
			return err
		}

		t := prometheus.GaugeValue
		v := float64(val)
		switch n {
		case "full_scans":
			t = prometheus.CounterValue
		case "sleep_millisecs":
			v /= 1000
		}
		ch <- prometheus.MustNewConstMetric(c.metricDescs[n], t, v)
	}

	return nil
}
874982
func (s *SourcesStore) Update(ctx context.Context, src chronograf.Source) error {
	return s.UpdateF(ctx, src)
}
286835
func (i *VCSInstaller) Update() error {
	debug("updating %s", i.Repo.Remote())
	if i.Repo.IsDirty() {
		return errors.New("plugin repo was modified")
	}
	if err := i.Repo.Update(); err != nil {
		return err
	}
	if !isPlugin(i.Repo.LocalPath()) {
		return ErrMissingMetadata
	}
	return nil
}
1316128
func (s *service) update(svc *service) {
	if s.serviceKey != svc.serviceKey {
		log.Fatalf("%v: can't update service %v using %v: serviceKey mismatch: %v != %v",
			s.vserver, s, svc, s.serviceKey, svc.serviceKey)
	}
	log.Infof("%v: updating service %v", s.vserver, s)

	updateIPVS := s.active && !s.ipvsEqual(svc)
	svc.active = s.active
	svc.healthy = s.healthy
	svc.stats = s.stats
	svc.dests = s.dests
	*s = *svc

	if !updateIPVS {
		return
	}

	log.Infof("%v: %v updating IPVS service", s.vserver, s)
	ncc := s.vserver.ncc
	if err := ncc.Dial(); err != nil {
		log.Fatalf("%v: failed to connect to NCC: %v", s.vserver, err)
	}
	defer ncc.Close()

	if err := ncc.IPVSUpdateService(s.ipvsSvc); err != nil {
		log.Fatalf("%v: failed to update service %v: %v", s.vserver, s, err)
	}
}
1045404
func (s *BinLayoutsStore) Update(ctx context.Context, layout chronograf.Layout) error {
	return fmt.Errorf("update to BinLayoutsStore not supported")
}
1059028
func Update(root string, dh *DirectoryHierarchy, keywords []Keyword, fs FsEval) ([]InodeDelta, error) {
	creator := dhCreator{DH: dh}
	curDir, err := os.Getwd()
	if err == nil {
		defer os.Chdir(curDir)
	}

	if err := os.Chdir(root); err != nil {
		return nil, err
	}
	sort.Sort(byPos(creator.DH.Entries))

	// This is for deferring the update of mtimes of directories, to unwind them
	// in a most specific path first
	h := &pathUpdateHeap{}
	heap.Init(h)

	results := []InodeDelta{}
	for i, e := range creator.DH.Entries {
		switch e.Type {
		case SpecialType:
			if e.Name == "/set" {
				creator.curSet = &creator.DH.Entries[i]
			} else if e.Name == "/unset" {
				creator.curSet = nil
			}
			logrus.Debugf("%#v", e)
			continue
		case RelativeType, FullType:
			e.Set = creator.curSet
			pathname, err := e.Path()
			if err != nil {
				return nil, err
			}

			// filter the keywords to update on the file, from the keywords available for this entry:
			var kvToUpdate []KeyVal
			kvToUpdate = keyvalSelector(e.AllKeys(), keywords)
			logrus.Debugf("kvToUpdate(%q): %#v", pathname, kvToUpdate)

			for _, kv := range kvToUpdate {
				if !InKeywordSlice(kv.Keyword().Prefix(), keywordPrefixes(keywords)) {
					continue
				}
				logrus.Debugf("finding function for %q (%q)", kv.Keyword(), kv.Keyword().Prefix())
				ukFunc, ok := UpdateKeywordFuncs[kv.Keyword().Prefix()]
				if !ok {
					logrus.Debugf("no UpdateKeywordFunc for %s; skipping", kv.Keyword())
					continue
				}

				// TODO check for the type=dir of the entry as well
				if kv.Keyword().Prefix() == "time" && e.IsDir() {
					heap.Push(h, pathUpdate{
						Path: pathname,
						E:    e,
						KV:   kv,
						Func: ukFunc,
					})

					continue
				}

				if _, err := ukFunc(pathname, kv); err != nil {
					results = append(results, InodeDelta{
						diff: ErrorDifference,
						path: pathname,
						old:  e,
						keys: []KeyDelta{
							{
								diff: ErrorDifference,
								name: kv.Keyword(),
								err:  err,
							},
						}})
				}
				// XXX really would be great to have a Check() or Compare() right here,
				// to compare each entry as it is encountered, rather than just running
				// Check() on this path after the whole update is finished.
			}
		}
	}

	for h.Len() > 0 {
		pu := heap.Pop(h).(pathUpdate)
		if _, err := pu.Func(pu.Path, pu.KV); err != nil {
			results = append(results, InodeDelta{
				diff: ErrorDifference,
				path: pu.Path,
				old:  pu.E,
				keys: []KeyDelta{
					{
						diff: ErrorDifference,
						name: pu.KV.Keyword(),
						err:  err,
					},
				}})
		}
	}
	return results, nil
}
257280
func (z *ZipArchive) updateStat() {
	z.NumFiles = len(z.files)
	z.isHasChanged = true
}
1124983
func (h *Hook) Update() error {
	if len(strings.TrimSpace(h.Content)) == 0 {
		if isExist(h.path) {
			return os.Remove(h.path)
		}
		return nil
	}
	os.MkdirAll(path.Dir(h.path), os.ModePerm)
	return ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm)
}
454323
func (c *deployments) Update(deployment *v1.Deployment) (result *v1.Deployment, err error) {
	result = &v1.Deployment{}
	err = c.client.Put().
		Namespace(c.ns).
		Resource("deployments").
		Name(deployment.Name).
		Body(deployment).
		Do().
		Into(result)
	return
}
727570
func (s *Server) Update(ctx context.Context, filePath string, contents []byte, version topo.Version) (topo.Version, error) {
	nodePath := path.Join(s.root, filePath)

	if version != nil {
		// We have to do a transaction. This means: if the
		// current file revision is what we expect, save it.
		txnresp, err := s.cli.Txn(ctx).
			If(clientv3.Compare(clientv3.ModRevision(nodePath), "=", int64(version.(EtcdVersion)))).
			Then(clientv3.OpPut(nodePath, string(contents))).
			Commit()
		if err != nil {
			return nil, convertError(err, nodePath)
		}
		if !txnresp.Succeeded {
			return nil, topo.NewError(topo.BadVersion, nodePath)
		}
		return EtcdVersion(txnresp.Header.Revision), nil
	}

	// No version specified. We can use a simple unconditional Put.
	resp, err := s.cli.Put(ctx, nodePath, string(contents))
	if err != nil {
		return nil, convertError(err, nodePath)
	}
	return EtcdVersion(resp.Header.Revision), nil
}
485861
func (c *bootTimeCollector) Update(ch chan<- prometheus.Metric) error {
	v, err := c.boottime.Value()
	if err != nil {
		return err
	}

	ch <- prometheus.MustNewConstMetric(
		prometheus.NewDesc(
			prometheus.BuildFQName(namespace, "", c.boottime.name),
			c.boottime.description,
			nil, nil,
		), prometheus.GaugeValue, v)

	return nil
}
1016057
func (s *BuildStore) Update(ctx context.Context, build chronograf.BuildInfo) error {
	if err := s.client.db.Update(func(tx *bolt.Tx) error {
		return s.update(ctx, build, tx)
	}); err != nil {
		return err
	}

	return nil
}
939821
func (ar *allocRunner) update(update *structs.Allocation) error {
	if ar.logger.IsTrace() {
		start := time.Now()
		ar.logger.Trace("running update hooks", "start", start)
		defer func() {
			end := time.Now()
			ar.logger.Trace("finished update hooks", "end", end, "duration", end.Sub(start))
		}()
	}

	req := &interfaces.RunnerUpdateRequest{
		Alloc: update,
	}

	var merr multierror.Error
	for _, hook := range ar.runnerHooks {
		h, ok := hook.(interfaces.RunnerUpdateHook)
		if !ok {
			continue
		}

		name := h.Name()
		var start time.Time
		if ar.logger.IsTrace() {
			start = time.Now()
			ar.logger.Trace("running pre-run hook", "name", name, "start", start)
		}

		if err := h.Update(req); err != nil {
			merr.Errors = append(merr.Errors, fmt.Errorf("update hook %q failed: %v", name, err))
		}

		if ar.logger.IsTrace() {
			end := time.Now()
			ar.logger.Trace("finished update hooks", "name", name, "end", end, "duration", end.Sub(start))
		}
	}

	return merr.ErrorOrNil()
}
887358
func (p *Controller) Update(ctx context.Context, t *api.Task) error {
	p.logger.Debug("Update")
	return nil
}
1146690
func (h *Hashes) Update(path string) (err error) {
	var buffer [4096]byte
	file, err := os.Open(path)
	if err != nil {
		return err
	}
	defer file.Close()
	md5 := md5.New()
	sha1 := sha1.New()
	sha256 := sha256.New()
	sha512 := sha512.New()

	for read, err := file.Read(buffer[:]); err != io.EOF && read != 0; read, err = file.Read(buffer[:]) {
		if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
			return err
		}
		md5.Write(buffer[:read])
		sha1.Write(buffer[:read])
		sha256.Write(buffer[:read])
		sha512.Write(buffer[:read])
	}

	h.Path = path
	h.Md5 = hex.EncodeToString(md5.Sum(nil))
	h.Sha1 = hex.EncodeToString(sha1.Sum(nil))
	h.Sha256 = hex.EncodeToString(sha256.Sum(nil))
	h.Sha512 = hex.EncodeToString(sha512.Sum(nil))
	return nil
}
469198
func (c *statCollector) Update(ch chan<- prometheus.Metric) error {
	stats, err := c.fs.NewStat()
	if err != nil {
		return err
	}

	ch <- prometheus.MustNewConstMetric(c.intr, prometheus.CounterValue, float64(stats.IRQTotal))
	ch <- prometheus.MustNewConstMetric(c.ctxt, prometheus.CounterValue, float64(stats.ContextSwitches))
	ch <- prometheus.MustNewConstMetric(c.forks, prometheus.CounterValue, float64(stats.ProcessCreated))

	ch <- prometheus.MustNewConstMetric(c.btime, prometheus.GaugeValue, float64(stats.BootTime))

	ch <- prometheus.MustNewConstMetric(c.procsRunning, prometheus.GaugeValue, float64(stats.ProcessesRunning))
	ch <- prometheus.MustNewConstMetric(c.procsBlocked, prometheus.GaugeValue, float64(stats.ProcessesBlocked))

	return nil
}