diff --git a/core/serror/serror.go b/core/serror/serror.go index 79bdb75be..7ff7ab49b 100644 --- a/core/serror/serror.go +++ b/core/serror/serror.go @@ -19,14 +19,6 @@ limitations under the License. package serror -import ( - "errors" -) - -var ( - ErrBadAddress = errors.New("Address for binding can not contain comma") -) - type SnapError interface { error Fields() map[string]interface{} diff --git a/mgmt/rest/server.go b/mgmt/rest/server.go index cac15a43d..ae222ad5c 100644 --- a/mgmt/rest/server.go +++ b/mgmt/rest/server.go @@ -309,11 +309,11 @@ func (s *Server) Name() string { return "REST" } -func (s *Server) SetAddress(addrString string, dfltPort int) error { +func (s *Server) SetAddress(addrString string, dfltPort int) { restLogger.Info(fmt.Sprintf("Setting address to: [%v] Default port: %v", addrString, dfltPort)) // In the future, we could extend this to support multiple comma separated IP[:port] values if strings.Index(addrString, ",") != -1 { - return serror.ErrBadAddress + restLogger.Fatal("Invalid address") } // If no port is specified, use default port if strings.Index(addrString, ":") != -1 { @@ -322,7 +322,6 @@ func (s *Server) SetAddress(addrString string, dfltPort int) error { s.addrString = fmt.Sprintf("%s:%d", addrString, dfltPort) } restLogger.Info(fmt.Sprintf("Address used for binding: [%v]", s.addrString)) - return nil } func (s *Server) Start() error { diff --git a/snapd.go b/snapd.go index fa1f430bb..e92784cea 100644 --- a/snapd.go +++ b/snapd.go @@ -660,7 +660,7 @@ func checkCmdLineFlags(ctx *cli.Context) error { addr := ctx.String("api-addr") // Contains a comma if strings.Index(addr, ",") != -1 { - return serror.ErrBadAddress + return errors.New("Invalid address") } idx := strings.Index(addr, ":") // Port is specified in address string @@ -682,7 +682,7 @@ func checkCmdLineFlags(ctx *cli.Context) error { func applyCmdLineFlags(cfg *Config, ctx *cli.Context) { err := checkCmdLineFlags(ctx) if err != nil { - panic(err) + log.Fatal(err) } invertBoolean := true // apply any command line flags that might have been set, first for the @@ -699,7 +699,7 @@ func applyCmdLineFlags(cfg *Config, ctx *cli.Context) { // next for the RESTful server related flags cfg.RestAPI.Enable = setBoolVal(cfg.RestAPI.Enable, ctx, "disable-api", invertBoolean) cfg.RestAPI.Port = setIntVal(cfg.RestAPI.Port, ctx, "api-port") - cfg.RestAPI.Address = setStringVal(cfg.RestAPI.Address, ctx, "ip-addr") + cfg.RestAPI.Address = setStringVal(cfg.RestAPI.Address, ctx, "api-addr") cfg.RestAPI.HTTPS = setBoolVal(cfg.RestAPI.HTTPS, ctx, "rest-https") cfg.RestAPI.RestCertificate = setStringVal(cfg.RestAPI.RestCertificate, ctx, "rest-cert") cfg.RestAPI.RestKey = setStringVal(cfg.RestAPI.RestKey, ctx, "rest-key")