etcdctl: add etcdctl snapshot pipe command

To improve the security of etcdctl. Added the ability to write snapshots to stdout without writing data to disk.

Signed-off-by: Ais8Ooz8 <47941654+Ais8Ooz8@users.noreply.github.com>
This commit is contained in:
Ais8Ooz8 2024-03-30 12:23:06 +03:00 committed by GitHub
parent 23f758fb59
commit d2ffdeda9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -97,7 +97,11 @@ func SaveWithVersion(ctx context.Context, lg *zap.Logger, cfg clientv3.Config, d
defer os.RemoveAll(partPath)
defer f.Close()
version, _ := WriteSnapshotWithVersion(ctx, lg, cfg, f)
var version string
version, err = WriteSnapshotWithVersion(ctx, lg, cfg, f)
if err != nil {
return version, err
}
if err = os.Rename(partPath, dbPath); err != nil {
return version, fmt.Errorf("could not rename %s to %s (%v)", partPath, dbPath, err)
}