[VOL-5486] Fix deprecated versions

Change-Id: If0b888d6c2f33b2f415c8b03b08dc994bb3df3f4
Signed-off-by: Abhay Kumar <abhay.kumar@radisys.com>
diff --git a/vendor/github.com/cheggaaa/pb/v3/termutil/term.go b/vendor/github.com/cheggaaa/pb/v3/termutil/term.go
new file mode 100644
index 0000000..c838d4f
--- /dev/null
+++ b/vendor/github.com/cheggaaa/pb/v3/termutil/term.go
@@ -0,0 +1,68 @@
+package termutil
+
+import (
+	"errors"
+	"os"
+	"os/signal"
+	"sync"
+)
+
+var echoLocked bool
+var echoLockMutex sync.Mutex
+var errLocked = errors.New("terminal locked")
+var autoTerminate = true
+
+// AutoTerminate enables or disables automatic terminate signal catching.
+// It's needed to restore the terminal state after the pool was used.
+// By default, it's enabled.
+func AutoTerminate(enable bool) {
+	echoLockMutex.Lock()
+	defer echoLockMutex.Unlock()
+	autoTerminate = enable
+}
+
+// RawModeOn switches terminal to raw mode
+func RawModeOn() (quit chan struct{}, err error) {
+	echoLockMutex.Lock()
+	defer echoLockMutex.Unlock()
+	if echoLocked {
+		err = errLocked
+		return
+	}
+	if err = lockEcho(); err != nil {
+		return
+	}
+	echoLocked = true
+	quit = make(chan struct{}, 1)
+	go catchTerminate(quit)
+	return
+}
+
+// RawModeOff restore previous terminal state
+func RawModeOff() (err error) {
+	echoLockMutex.Lock()
+	defer echoLockMutex.Unlock()
+	if !echoLocked {
+		return
+	}
+	if err = unlockEcho(); err != nil {
+		return
+	}
+	echoLocked = false
+	return
+}
+
+// listen exit signals and restore terminal state
+func catchTerminate(quit chan struct{}) {
+	sig := make(chan os.Signal, 1)
+	if autoTerminate {
+		signal.Notify(sig, unlockSignals...)
+		defer signal.Stop(sig)
+	}
+	select {
+	case <-quit:
+		RawModeOff()
+	case <-sig:
+		RawModeOff()
+	}
+}
diff --git a/vendor/github.com/cheggaaa/pb/v3/termutil/term_aix.go b/vendor/github.com/cheggaaa/pb/v3/termutil/term_aix.go
new file mode 100644
index 0000000..5bbc5ef
--- /dev/null
+++ b/vendor/github.com/cheggaaa/pb/v3/termutil/term_aix.go
@@ -0,0 +1,69 @@
+//go:build aix
+
+package termutil
+
+import (
+	"os"
+	"syscall"
+
+	"golang.org/x/sys/unix"
+)
+
+var (
+	tty *os.File
+
+	unlockSignals = []os.Signal{
+		os.Interrupt, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGKILL,
+	}
+)
+
+func init() {
+	var err error
+	tty, err = os.Open("/dev/tty")
+	if err != nil {
+		tty = os.Stdin
+	}
+}
+
+// TerminalWidth returns width of the terminal.
+func TerminalWidth() (int, error) {
+	_, width, err := TerminalSize()
+	return width, err
+}
+
+// TerminalSize returns size of the terminal.
+func TerminalSize() (int, int, error) {
+	w, err := unix.IoctlGetWinsize(int(tty.Fd()), syscall.TIOCGWINSZ)
+	if err != nil {
+		return 0, 0, err
+	}
+	return int(w.Row), int(w.Col), nil
+}
+
+var oldState unix.Termios
+
+func lockEcho() error {
+	fd := int(tty.Fd())
+	currentState, err := unix.IoctlGetTermios(fd, unix.TCGETS)
+	if err != nil {
+		return err
+	}
+
+	oldState = *currentState
+	newState := oldState
+	newState.Lflag &^= syscall.ECHO
+	newState.Lflag |= syscall.ICANON | syscall.ISIG
+	newState.Iflag |= syscall.ICRNL
+	if err := unix.IoctlSetTermios(fd, unix.TCSETS, &newState); err != nil {
+		return err
+	}
+	return nil
+}
+
+func unlockEcho() (err error) {
+	fd := int(tty.Fd())
+	if err := unix.IoctlSetTermios(fd, unix.TCSETS, &oldState); err != nil {
+		return err
+	}
+	return
+}
diff --git a/vendor/github.com/cheggaaa/pb/v3/termutil/term_appengine.go b/vendor/github.com/cheggaaa/pb/v3/termutil/term_appengine.go
new file mode 100644
index 0000000..6bc5c51
--- /dev/null
+++ b/vendor/github.com/cheggaaa/pb/v3/termutil/term_appengine.go
@@ -0,0 +1,12 @@
+//go:build appengine
+// +build appengine
+
+package termutil
+
+import "errors"
+
+// terminalWidth returns width of the terminal, which is not supported
+// and should always failed on appengine classic which is a sandboxed PaaS.
+func TerminalWidth() (int, error) {
+	return 0, errors.New("Not supported")
+}
diff --git a/vendor/github.com/cheggaaa/pb/v3/termutil/term_bsd.go b/vendor/github.com/cheggaaa/pb/v3/termutil/term_bsd.go
new file mode 100644
index 0000000..e16380f
--- /dev/null
+++ b/vendor/github.com/cheggaaa/pb/v3/termutil/term_bsd.go
@@ -0,0 +1,10 @@
+//go:build (darwin || freebsd || netbsd || openbsd || dragonfly) && !appengine
+// +build darwin freebsd netbsd openbsd dragonfly
+// +build !appengine
+
+package termutil
+
+import "syscall"
+
+const ioctlReadTermios = syscall.TIOCGETA
+const ioctlWriteTermios = syscall.TIOCSETA
diff --git a/vendor/github.com/cheggaaa/pb/v3/termutil/term_linux.go b/vendor/github.com/cheggaaa/pb/v3/termutil/term_linux.go
new file mode 100644
index 0000000..f4c5325
--- /dev/null
+++ b/vendor/github.com/cheggaaa/pb/v3/termutil/term_linux.go
@@ -0,0 +1,7 @@
+//go:build linux && !appengine
+// +build linux,!appengine
+
+package termutil
+
+const ioctlReadTermios = 0x5401  // syscall.TCGETS
+const ioctlWriteTermios = 0x5402 // syscall.TCSETS
diff --git a/vendor/github.com/cheggaaa/pb/v3/termutil/term_nix.go b/vendor/github.com/cheggaaa/pb/v3/termutil/term_nix.go
new file mode 100644
index 0000000..471d5a9
--- /dev/null
+++ b/vendor/github.com/cheggaaa/pb/v3/termutil/term_nix.go
@@ -0,0 +1,9 @@
+//go:build (linux || darwin || freebsd || netbsd || openbsd || dragonfly) && !appengine
+// +build linux darwin freebsd netbsd openbsd dragonfly
+// +build !appengine
+
+package termutil
+
+import "syscall"
+
+const sysIoctl = syscall.SYS_IOCTL
diff --git a/vendor/github.com/cheggaaa/pb/v3/termutil/term_plan9.go b/vendor/github.com/cheggaaa/pb/v3/termutil/term_plan9.go
new file mode 100644
index 0000000..f3934c6
--- /dev/null
+++ b/vendor/github.com/cheggaaa/pb/v3/termutil/term_plan9.go
@@ -0,0 +1,50 @@
+package termutil
+
+import (
+	"errors"
+	"os"
+	"syscall"
+)
+
+var (
+	consctl *os.File
+
+	// Plan 9 doesn't have syscall.SIGQUIT
+	unlockSignals = []os.Signal{
+		os.Interrupt, syscall.SIGTERM, syscall.SIGKILL,
+	}
+)
+
+// TerminalWidth returns width of the terminal.
+func TerminalWidth() (int, error) {
+	return 0, errors.New("Not supported")
+}
+
+func lockEcho() error {
+	if consctl != nil {
+		return errors.New("consctl already open")
+	}
+	var err error
+	consctl, err = os.OpenFile("/dev/consctl", os.O_WRONLY, 0)
+	if err != nil {
+		return err
+	}
+	_, err = consctl.WriteString("rawon")
+	if err != nil {
+		consctl.Close()
+		consctl = nil
+		return err
+	}
+	return nil
+}
+
+func unlockEcho() error {
+	if consctl == nil {
+		return nil
+	}
+	if err := consctl.Close(); err != nil {
+		return err
+	}
+	consctl = nil
+	return nil
+}
diff --git a/vendor/github.com/cheggaaa/pb/v3/termutil/term_solaris.go b/vendor/github.com/cheggaaa/pb/v3/termutil/term_solaris.go
new file mode 100644
index 0000000..45f3055
--- /dev/null
+++ b/vendor/github.com/cheggaaa/pb/v3/termutil/term_solaris.go
@@ -0,0 +1,8 @@
+//go:build solaris && !appengine
+// +build solaris,!appengine
+
+package termutil
+
+const ioctlReadTermios = 0x5401  // syscall.TCGETS
+const ioctlWriteTermios = 0x5402 // syscall.TCSETS
+const sysIoctl = 54
diff --git a/vendor/github.com/cheggaaa/pb/v3/termutil/term_win.go b/vendor/github.com/cheggaaa/pb/v3/termutil/term_win.go
new file mode 100644
index 0000000..99397a0
--- /dev/null
+++ b/vendor/github.com/cheggaaa/pb/v3/termutil/term_win.go
@@ -0,0 +1,155 @@
+//go:build windows
+// +build windows
+
+package termutil
+
+import (
+	"fmt"
+	"os"
+	"os/exec"
+	"strconv"
+	"syscall"
+	"unsafe"
+)
+
+var (
+	tty = os.Stdin
+
+	unlockSignals = []os.Signal{
+		os.Interrupt, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGKILL,
+	}
+)
+
+var (
+	kernel32 = syscall.NewLazyDLL("kernel32.dll")
+
+	// GetConsoleScreenBufferInfo retrieves information about the
+	// specified console screen buffer.
+	// http://msdn.microsoft.com/en-us/library/windows/desktop/ms683171(v=vs.85).aspx
+	procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
+
+	// GetConsoleMode retrieves the current input mode of a console's
+	// input buffer or the current output mode of a console screen buffer.
+	// https://msdn.microsoft.com/en-us/library/windows/desktop/ms683167(v=vs.85).aspx
+	getConsoleMode = kernel32.NewProc("GetConsoleMode")
+
+	// SetConsoleMode sets the input mode of a console's input buffer
+	// or the output mode of a console screen buffer.
+	// https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx
+	setConsoleMode = kernel32.NewProc("SetConsoleMode")
+
+	// SetConsoleCursorPosition sets the cursor position in the
+	// specified console screen buffer.
+	// https://msdn.microsoft.com/en-us/library/windows/desktop/ms686025(v=vs.85).aspx
+	setConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition")
+
+	mingw = isMingw()
+)
+
+type (
+	// Defines the coordinates of the upper left and lower right corners
+	// of a rectangle.
+	// See
+	// http://msdn.microsoft.com/en-us/library/windows/desktop/ms686311(v=vs.85).aspx
+	smallRect struct {
+		Left, Top, Right, Bottom int16
+	}
+
+	// Defines the coordinates of a character cell in a console screen
+	// buffer. The origin of the coordinate system (0,0) is at the top, left cell
+	// of the buffer.
+	// See
+	// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682119(v=vs.85).aspx
+	coordinates struct {
+		X, Y int16
+	}
+
+	word int16
+
+	// Contains information about a console screen buffer.
+	// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
+	consoleScreenBufferInfo struct {
+		dwSize              coordinates
+		dwCursorPosition    coordinates
+		wAttributes         word
+		srWindow            smallRect
+		dwMaximumWindowSize coordinates
+	}
+)
+
+// TerminalWidth returns width of the terminal.
+func TerminalWidth() (width int, err error) {
+	if mingw {
+		return termWidthTPut()
+	}
+	return termWidthCmd()
+}
+
+func termWidthCmd() (width int, err error) {
+	var info consoleScreenBufferInfo
+	_, _, e := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(syscall.Stdout), uintptr(unsafe.Pointer(&info)), 0)
+	if e != 0 {
+		return 0, error(e)
+	}
+	return int(info.dwSize.X) - 1, nil
+}
+
+func isMingw() bool {
+	return os.Getenv("MINGW_PREFIX") != "" || os.Getenv("MSYSTEM") == "MINGW64"
+}
+
+func termWidthTPut() (width int, err error) {
+	// TODO: maybe anybody knows a better way to get it on mintty...
+	var res []byte
+	cmd := exec.Command("tput", "cols")
+	cmd.Stdin = os.Stdin
+	if res, err = cmd.CombinedOutput(); err != nil {
+		return 0, fmt.Errorf("%s: %v", string(res), err)
+	}
+	if len(res) > 1 {
+		res = res[:len(res)-1]
+	}
+	return strconv.Atoi(string(res))
+}
+
+func GetCursorPos() (pos coordinates, err error) {
+	var info consoleScreenBufferInfo
+	_, _, e := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(syscall.Stdout), uintptr(unsafe.Pointer(&info)), 0)
+	if e != 0 {
+		return info.dwCursorPosition, error(e)
+	}
+	return info.dwCursorPosition, nil
+}
+
+func SetCursorPos(pos coordinates) error {
+	_, _, e := syscall.Syscall(setConsoleCursorPosition.Addr(), 2, uintptr(syscall.Stdout), uintptr(uint32(uint16(pos.Y))<<16|uint32(uint16(pos.X))), 0)
+	if e != 0 {
+		return error(e)
+	}
+	return nil
+}
+
+var oldState word
+
+func lockEcho() (err error) {
+	if _, _, e := syscall.Syscall(getConsoleMode.Addr(), 2, uintptr(syscall.Stdout), uintptr(unsafe.Pointer(&oldState)), 0); e != 0 {
+		err = fmt.Errorf("Can't get terminal settings: %v", e)
+		return
+	}
+
+	newState := oldState
+	const ENABLE_LINE_INPUT = 0x0002
+	newState = newState & (^ENABLE_LINE_INPUT)
+	if _, _, e := syscall.Syscall(setConsoleMode.Addr(), 2, uintptr(syscall.Stdout), uintptr(newState), 0); e != 0 {
+		err = fmt.Errorf("Can't set terminal settings: %v", e)
+		return
+	}
+	return
+}
+
+func unlockEcho() (err error) {
+	if _, _, e := syscall.Syscall(setConsoleMode.Addr(), 2, uintptr(syscall.Stdout), uintptr(oldState), 0); e != 0 {
+		err = fmt.Errorf("Can't set terminal settings")
+	}
+	return
+}
diff --git a/vendor/github.com/cheggaaa/pb/v3/termutil/term_x.go b/vendor/github.com/cheggaaa/pb/v3/termutil/term_x.go
new file mode 100644
index 0000000..4746e9b
--- /dev/null
+++ b/vendor/github.com/cheggaaa/pb/v3/termutil/term_x.go
@@ -0,0 +1,81 @@
+//go:build (linux || darwin || freebsd || netbsd || openbsd || solaris || dragonfly) && !appengine
+// +build linux darwin freebsd netbsd openbsd solaris dragonfly
+// +build !appengine
+
+package termutil
+
+import (
+	"fmt"
+	"os"
+	"syscall"
+	"unsafe"
+)
+
+var (
+	tty *os.File
+
+	unlockSignals = []os.Signal{
+		os.Interrupt, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGKILL,
+	}
+	oldState syscall.Termios
+)
+
+type window struct {
+	Row    uint16
+	Col    uint16
+	Xpixel uint16
+	Ypixel uint16
+}
+
+func init() {
+	var err error
+	tty, err = os.Open("/dev/tty")
+	if err != nil {
+		tty = os.Stdin
+	}
+}
+
+// TerminalWidth returns width of the terminal.
+func TerminalWidth() (int, error) {
+	_, c, err := TerminalSize()
+	return c, err
+}
+
+// TerminalSize returns size of the terminal.
+func TerminalSize() (rows, cols int, err error) {
+	w := new(window)
+	res, _, err := syscall.Syscall(sysIoctl,
+		tty.Fd(),
+		uintptr(syscall.TIOCGWINSZ),
+		uintptr(unsafe.Pointer(w)),
+	)
+	if int(res) == -1 {
+		return 0, 0, err
+	}
+	return int(w.Row), int(w.Col), nil
+}
+
+func lockEcho() error {
+	fd := tty.Fd()
+
+	if _, _, err := syscall.Syscall(sysIoctl, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&oldState))); err != 0 {
+		return fmt.Errorf("error when puts the terminal connected to the given file descriptor: %w", err)
+	}
+
+	newState := oldState
+	newState.Lflag &^= syscall.ECHO
+	newState.Lflag |= syscall.ICANON | syscall.ISIG
+	newState.Iflag |= syscall.ICRNL
+	if _, _, e := syscall.Syscall(sysIoctl, fd, ioctlWriteTermios, uintptr(unsafe.Pointer(&newState))); e != 0 {
+		return fmt.Errorf("error update terminal settings: %w", e)
+	}
+	return nil
+}
+
+func unlockEcho() error {
+	fd := tty.Fd()
+	if _, _, err := syscall.Syscall(sysIoctl, fd, ioctlWriteTermios, uintptr(unsafe.Pointer(&oldState))); err != 0 {
+		return fmt.Errorf("error restores the terminal connected to the given file descriptor: %w", err)
+	}
+	return nil
+}