Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
fleetctl: just inline getUnitInstanceInfo() and restore previous erro…
Browse files Browse the repository at this point in the history
…r messages
  • Loading branch information
Djalal Harouni committed Mar 2, 2016
1 parent 60a7c54 commit cab3099
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions fleetctl/fleetctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
info := unit.NewUnitNameInfo(name)
if err != nil {
return nil, fmt.Errorf("failed getting Unit(%s) info: %v", name, err)
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cab3099

Please sign in to comment.