From 891228faaf81eea551309f227e0f9e4e254104e0 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Tue, 23 Aug 2016 10:38:32 -0700 Subject: [PATCH] osprepare: Ensure its ok to fail early It is quite likely that we either encounter a distro or configuration that is new to us, due to the nature of the new osprepare module, so we shouldn't fail here. Rather, we should fail later on so that osprepare can be improved retroactively to fix whatever setup issue we encountered. With this change it is also OK to pass nil dependencies, to enable easier plugging in of the functionality, and future expansion of the core entry method, PrepareOsDeps. Signed-off-by: Ikey Doherty --- osprepare/main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/osprepare/main.go b/osprepare/main.go index c619b2c80..6fb99cb4e 100644 --- a/osprepare/main.go +++ b/osprepare/main.go @@ -74,9 +74,9 @@ func collectPackages(dist distro, reqs *PackageRequirements) []string { return nil } -// PrepareCIAO installs all the dependencies defined in +// PrepareOsDeps installs all the dependencies defined in // PackageRequirements in order to run the ciao component -func PrepareCIAO(reqs *PackageRequirements) bool { +func PrepareOsDeps(reqs *PackageRequirements) { distro := getDistro() if distro == nil { @@ -86,14 +86,15 @@ func PrepareCIAO(reqs *PackageRequirements) bool { } else { fmt.Fprintln(os.Stderr, "No os-release found on this host") } - return false + return + } + // Nothing requested to install + if reqs == nil { + return } - fmt.Println(distro.getID()) if reqPkgs := collectPackages(distro, reqs); reqPkgs != nil { if distro.InstallPackages(reqPkgs) == false { fmt.Fprintf(os.Stderr, "Failed to install: %s\n", strings.Join(reqPkgs, ", ")) - return false } } - return true }