From 64fac3db4c1e235a36dcf543229bfd17a1207bb3 Mon Sep 17 00:00:00 2001 From: "Timothy St. Clair" Date: Wed, 2 Nov 2016 18:10:30 -0500 Subject: [PATCH] Add a no-ttl flag to etcdctl migrate to discard keys on transform. --- etcdctl/ctlv3/command/migrate_command.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/etcdctl/ctlv3/command/migrate_command.go b/etcdctl/ctlv3/command/migrate_command.go index 5b616c577f2c..6bbd167f7477 100644 --- a/etcdctl/ctlv3/command/migrate_command.go +++ b/etcdctl/ctlv3/command/migrate_command.go @@ -42,9 +42,10 @@ import ( ) var ( - migrateDatadir string - migrateWALdir string - migrateTransformer string + migrateExcludeTTLKey bool + migrateDatadir string + migrateWALdir string + migrateTransformer string ) // NewMigrateCommand returns the cobra command for "migrate". @@ -55,6 +56,7 @@ func NewMigrateCommand() *cobra.Command { Run: migrateCommandFunc, } + mc.Flags().BoolVar(&migrateExcludeTTLKey, "no-ttl", false, "Do not convert TTL keys") mc.Flags().StringVar(&migrateDatadir, "data-dir", "", "Path to the data directory") mc.Flags().StringVar(&migrateWALdir, "wal-dir", "", "Path to the WAL directory") mc.Flags().StringVar(&migrateTransformer, "transformer", "", "Path to the user-provided transformer program") @@ -311,6 +313,10 @@ func defaultTransformer() (io.WriteCloser, io.ReadCloser, chan error) { return } + if migrateExcludeTTLKey && node.TTL != 0 { + continue + } + kv := transform(node) if kv == nil { continue