The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2388

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: St├ęphane Graber <stgra...@ubuntu.com>
From 7afa69be324efd06781ff7fbb5f03518934b5b36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Fri, 16 Sep 2016 00:13:03 -0400
Subject: [PATCH] init: Change validation functions for consistency
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: St├ęphane Graber <stgra...@ubuntu.com>
---
 lxd/main.go | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lxd/main.go b/lxd/main.go
index d464cfe..6673b99 100644
--- a/lxd/main.go
+++ b/lxd/main.go
@@ -673,7 +673,7 @@ func cmdInit() error {
                }
        }
 
-       askString := func(question string, default_ string, validate 
func(string) string) string {
+       askString := func(question string, default_ string, validate 
func(string) error) string {
                for {
                        fmt.Printf(question)
                        input, _ := reader.ReadString('\n')
@@ -683,7 +683,7 @@ func cmdInit() error {
                        }
                        if validate != nil {
                                result := validate(input)
-                               if result != "" {
+                               if result != nil {
                                        fmt.Printf("Invalid input: %s\n\n", 
result)
                                        continue
                                }
@@ -818,11 +818,11 @@ func cmdInit() error {
                        if askBool("Create a new ZFS pool (yes/no) 
[default=yes]? ", "yes") {
                                storagePool = askString("Name of the new ZFS 
pool [default=lxd]: ", "lxd", nil)
                                if askBool("Would you like to use an existing 
block device (yes/no) [default=no]? ", "no") {
-                                       deviceExists := func(path string) 
string {
+                                       deviceExists := func(path string) error 
{
                                                if !shared.IsBlockdevPath(path) 
{
-                                                       return 
fmt.Sprintf("'%s' is not a block device", path)
+                                                       return fmt.Errorf("'%s' 
is not a block device", path)
                                                }
-                                               return ""
+                                               return nil
                                        }
                                        storageDevice = askString("Path to the 
existing block device: ", "", deviceExists)
                                        storageMode = "device"
@@ -872,11 +872,11 @@ they otherwise would.
                }
 
                if askBool("Would you like LXD to be available over the network 
(yes/no) [default=no]? ", "no") {
-                       isIPAddress := func(s string) string {
+                       isIPAddress := func(s string) error {
                                if s != "all" && net.ParseIP(s) == nil {
-                                       return fmt.Sprintf("'%s' is not an IP 
address", s)
+                                       return fmt.Errorf("'%s' is not an IP 
address", s)
                                }
-                               return ""
+                               return nil
                        }
 
                        networkAddress = askString("Address to bind LXD to (not 
including port) [default=all]: ", "all", isIPAddress)
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to