// Copy duplicates the current storage.
322858
func (s Storage) Copy() Storage {
	cpy := make(Storage)
	for key, value := range s {
		cpy[key] = value
	}

	return cpy
}
1309151
func (s *ConfigSnapshot) Clone() (*ConfigSnapshot, error) {
	snapCopy, err := copystructure.Copy(s)
	if err != nil {
		return nil, err
	}
	return snapCopy.(*ConfigSnapshot), nil
}
883009
func (h *HashMap) Copy() *HashMap {
	cpy := NewHashMap(h.eq, h.hash)
	h.Iter(func(k, v T) bool {
		cpy.Put(k, v)
		return false
	})
	return cpy
}
1150269
func Copy(elements map[string]interface{}) (result map[string]interface{}) {
	result = make(map[string]interface{}, len(elements))
	for k, v := range elements {
		result[k] = v
	}

	return result
}
653617
func (d *digest) Copy() (ResumableHash, error) {
	newHash := hash.Hash(sha1.New())
	state, err := d.Hash.(encoding.BinaryMarshaler).MarshalBinary()
	if err != nil {
		return nil, err
	}
	if err := newHash.(encoding.BinaryUnmarshaler).UnmarshalBinary(state); err != nil {
		return nil, err
	}
	return &digest{
		newHash,
	}, nil
}
1288220
func (md *MDServerMemory) copy(config mdServerLocalConfig) mdServerLocal {
	// NOTE: observers and sessionHeads are copied shallowly on
	// purpose, so that the MD server that gets a Put will notify all
	// observers correctly no matter where they got on the list.
	log := config.MakeLogger("")
	return &MDServerMemory{config, log, md.mdServerMemShared}
}
543970
func (r *RawConfig) Copy() *RawConfig {
	if r == nil {
		return nil
	}

	r.lock.Lock()
	defer r.lock.Unlock()

	if r.Body != nil {
		return NewRawConfigHCL2(r.Body)
	}

	newRaw := make(map[string]interface{})
	for k, v := range r.Raw {
		newRaw[k] = v
	}

	result, err := NewRawConfig(newRaw)
	if err != nil {
		panic("copy failed: " + err.Error())
	}

	result.Key = r.Key
	return result
}
840915
func (b *Backend) Copy(c *Backend) {
	b.Enabled = c.Enabled
	b.InService = c.InService
	b.Weight = c.Weight
	b.Host.Copy(&c.Host)
}
153045
func (v DynamicValue) Copy() DynamicValue {
	if v == nil {
		return nil
	}

	ret := make(DynamicValue, len(v))
	copy(ret, v)
	return ret
}
40181
func (imp *Import) Copy() *Import {
	cpy := *imp
	cpy.Path = imp.Path.Copy()
	return &cpy
}
212994
func Copy(ctx context.Context, s Store, src, des Object) error {
	// for Providers that offer fast path, and use the backend copier
	if src.StorageSource() == des.StorageSource() {
		if cp, ok := s.(StoreCopy); ok {
			return cp.Copy(ctx, src, des)
		}
	}

	// Slow path, open an io.Reader from the source and copy it to an
	// io.Writer to the destination.  This is considered a "slow path" because we
	// have to act as a broker to relay bytes between the two objects.  Some
	// stores support moving data using an API call.
	fout, err := s.NewWriterWithContext(ctx, des.Name(), src.MetaData())
	if err != nil {
		gou.Warnf("Move could not open destination %v", src.Name())
		return err
	}
	fin, err := s.NewReaderWithContext(ctx, src.Name())
	if err != nil {
		gou.Warnf("Move could not open source %v err=%v", src.Name(), err)
		return err
	}
	if _, err = io.Copy(fout, fin); err != nil {
		return err
	}
	if err := fin.Close(); err != nil {
		return err
	}
	if err := fout.Close(); err != nil { //this will flush and sync the file.
		return err
	}
	return nil
}
1143308
func (f *FakeCommandRunner) Copy(file assets.CopyableFile) error {
	var b bytes.Buffer
	_, err := io.Copy(&b, file)
	if err != nil {
		return errors.Wrapf(err, "error reading file: %+v", file)
	}
	f.fileMap.Store(file.GetAssetName(), b.String())
	return nil
}
1026956
func (d *AllocDir) Copy() *AllocDir {
	d.mu.RLock()
	defer d.mu.RUnlock()

	if d == nil {
		return nil
	}
	dcopy := &AllocDir{
		AllocDir:  d.AllocDir,
		SharedDir: d.SharedDir,
		TaskDirs:  make(map[string]*TaskDir, len(d.TaskDirs)),
		logger:    d.logger,
	}
	for k, v := range d.TaskDirs {
		dcopy.TaskDirs[k] = v.Copy()
	}
	return dcopy
}
665497
func (s *State) Copy(db dbm.DB) (*State, error) {
	stateCopy := NewState(db)
	err := s.writeState.forest.IterateRWTree(nil, nil, true,
		func(prefix []byte, tree *storage.RWTree) error {
			treeCopy, err := stateCopy.writeState.forest.Writer(prefix)
			if err != nil {
				return err
			}
			return tree.IterateWriteTree(nil, nil, true, func(key []byte, value []byte) error {
				treeCopy.Set(key, value)
				return nil
			})
		})
	if err != nil {
		return nil, err
	}
	_, _, err = stateCopy.commit()
	if err != nil {
		return nil, err
	}
	return stateCopy, nil
}
268246
func (e *ClientExecutor) Copy(excludes []string, copies ...imagebuilder.Copy) error {
	// copying content into a volume invalidates the archived state of any given directory
	for _, copy := range copies {
		e.Volumes.Invalidate(copy.Dest)
	}

	return e.CopyContainer(e.Container, excludes, copies...)
}
326521
func (d *EphemeralDisk) Copy() *EphemeralDisk {
	ld := new(EphemeralDisk)
	*ld = *d
	return ld
}
529980
func copy(src llb.State, srcPath string, dest llb.State, destPath string) llb.State {
	cpImage := llb.Image("docker.io/library/alpine@sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe")
	cp := cpImage.Run(llb.Shlexf("cp -a /src%s /dest%s", srcPath, destPath))
	cp.AddMount("/src", src, llb.Readonly)
	return cp.AddMount("/dest", dest)
}