"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "etcdctl/ctlv3/command/del_command.go" between
etcd-3.5.5.tar.gz and etcd-3.5.6.tar.gz

About: etcd is a distributed reliable key-value store for the most critical data of a distributed system (written in "Go").

del_command.go  (etcd-3.5.5):del_command.go  (etcd-3.5.6)
skipping to change at line 19 skipping to change at line 19
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package command package command
import ( import (
"fmt" "fmt"
"os"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"go.etcd.io/etcd/client/v3" clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/pkg/v3/cobrautl" "go.etcd.io/etcd/pkg/v3/cobrautl"
) )
var ( var (
delPrefix bool delPrefix bool
delPrevKV bool delPrevKV bool
delFromKey bool delFromKey bool
delRange bool
) )
// NewDelCommand returns the cobra command for "del". // NewDelCommand returns the cobra command for "del".
func NewDelCommand() *cobra.Command { func NewDelCommand() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "del [options] <key> [range_end]", Use: "del [options] <key> [range_end]",
Short: "Removes the specified key or range of keys [key, range_en d)", Short: "Removes the specified key or range of keys [key, range_en d)",
Run: delCommandFunc, Run: delCommandFunc,
} }
cmd.Flags().BoolVar(&delPrefix, "prefix", false, "delete keys with matchi ng prefix") cmd.Flags().BoolVar(&delPrefix, "prefix", false, "delete keys with matchi ng prefix")
cmd.Flags().BoolVar(&delPrevKV, "prev-kv", false, "return deleted key-val ue pairs") cmd.Flags().BoolVar(&delPrevKV, "prev-kv", false, "return deleted key-val ue pairs")
cmd.Flags().BoolVar(&delFromKey, "from-key", false, "delete keys that are greater than or equal to the given key using byte compare") cmd.Flags().BoolVar(&delFromKey, "from-key", false, "delete keys that are greater than or equal to the given key using byte compare")
cmd.Flags().BoolVar(&delRange, "range", false, "delete range of keys")
return cmd return cmd
} }
// delCommandFunc executes the "del" command. // delCommandFunc executes the "del" command.
func delCommandFunc(cmd *cobra.Command, args []string) { func delCommandFunc(cmd *cobra.Command, args []string) {
key, opts := getDelOp(args) key, opts := getDelOp(args)
ctx, cancel := commandCtx(cmd) ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).Delete(ctx, key, opts...) resp, err := mustClientFromCmd(cmd).Delete(ctx, key, opts...)
cancel() cancel()
if err != nil { if err != nil {
skipping to change at line 73 skipping to change at line 76
cobrautl.ExitWithError(cobrautl.ExitBadArgs, fmt.Errorf("`--prefi x` and `--from-key` cannot be set at the same time, choose one")) cobrautl.ExitWithError(cobrautl.ExitBadArgs, fmt.Errorf("`--prefi x` and `--from-key` cannot be set at the same time, choose one"))
} }
opts := []clientv3.OpOption{} opts := []clientv3.OpOption{}
key := args[0] key := args[0]
if len(args) > 1 { if len(args) > 1 {
if delPrefix || delFromKey { if delPrefix || delFromKey {
cobrautl.ExitWithError(cobrautl.ExitBadArgs, fmt.Errorf(" too many arguments, only accept one argument when `--prefix` or `--from-key` is set")) cobrautl.ExitWithError(cobrautl.ExitBadArgs, fmt.Errorf(" too many arguments, only accept one argument when `--prefix` or `--from-key` is set"))
} }
opts = append(opts, clientv3.WithRange(args[1])) opts = append(opts, clientv3.WithRange(args[1]))
if !delRange {
fmt.Fprintln(os.Stderr, "In etcd v3.6, the operation will
be suspended for a few seconds to provide the user time to verify range.")
}
} }
if delPrefix { if delPrefix {
if len(key) == 0 { if len(key) == 0 {
key = "\x00" key = "\x00"
opts = append(opts, clientv3.WithFromKey()) opts = append(opts, clientv3.WithFromKey())
} else { } else {
opts = append(opts, clientv3.WithPrefix()) opts = append(opts, clientv3.WithPrefix())
} }
} }
 End of changes. 5 change blocks. 
1 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)