From a3703b3223d6a01904e6ac9be502b76b8f7cfc58 Mon Sep 17 00:00:00 2001 From: Djalal Harouni Date: Fri, 4 Mar 2016 15:16:15 +0100 Subject: [PATCH] fleetctl: just inline getUnitInstanceInfo() and restore previous error messages --- fleetctl/fleetctl.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/fleetctl/fleetctl.go b/fleetctl/fleetctl.go index 8d4954088..cc3b7fffb 100644 --- a/fleetctl/fleetctl.go +++ b/fleetctl/fleetctl.go @@ -506,9 +506,11 @@ func getUnitFile(file string) (*unit.UnitFile, error) { } else { // Otherwise (if the unit file does not exist), check if the // name appears to be an instance of a template unit - info, err := getUnitInstanceInfo(name) - if err != nil { - return nil, fmt.Errorf("failed getting Unit(%s) info: %v", name, err) + info := unit.NewUnitNameInfo(name) + if info == nil { + return nil, fmt.Errorf("error extracting information from unit name %s", name) + } else if !info.IsInstance() { + return nil, fmt.Errorf("unable to find Unit(%s) in Registry or on filesystem", name) } // If it is an instance check for a corresponding template @@ -540,18 +542,6 @@ func getUnitFromFile(file string) (*unit.UnitFile, error) { return unit.NewUnitFile(string(out)) } -func getUnitInstanceInfo(name string) (*unit.UnitNameInfo, error) { - // Check if the name appears to be an instance unit - uni := unit.NewUnitNameInfo(name) - if uni == nil { - return nil, errors.New("unable to extract information from unit name") - } else if !uni.IsInstance() { - return nil, errors.New("unable to find Unit in Registry or on filesystem") - } - - return uni, nil -} - // getUnitFileFromTemplate attempts to get a Unit from a template unit that // is either in the registry or on the file system // It takes two arguments, the template information and the unit file name