diff --git a/catalogue/catalogue.go b/catalogue/catalogue.go index 32856933..f9cdebd9 100644 --- a/catalogue/catalogue.go +++ b/catalogue/catalogue.go @@ -148,6 +148,7 @@ func (r RecipeCatalogue) Flatten() []Recipe { return recipes } +// ByRecipeName sorts recipes by name. type ByRecipeName []Recipe func (r ByRecipeName) Len() int { return len(r) } @@ -156,6 +157,8 @@ func (r ByRecipeName) Less(i, j int) bool { return strings.ToLower(r[i].Name) < strings.ToLower(r[j].Name) } +// recipeCatalogueFSIsLatest checks whether the recipe catalogue stored locally +// is up to date. func recipeCatalogueFSIsLatest() (bool, error) { httpClient := &http.Client{Timeout: web.Timeout} res, err := httpClient.Head(RecipeCatalogueURL) @@ -186,6 +189,7 @@ func recipeCatalogueFSIsLatest() (bool, error) { return true, nil } +// ReadRecipeCatalogue reads the recipe catalogue. func ReadRecipeCatalogue() (RecipeCatalogue, error) { recipes := make(RecipeCatalogue) @@ -208,6 +212,7 @@ func ReadRecipeCatalogue() (RecipeCatalogue, error) { return recipes, nil } +// readRecipeCatalogueFS reads the catalogue from the file system. func readRecipeCatalogueFS(target interface{}) error { recipesJSONFS, err := ioutil.ReadFile(config.APPS_JSON) if err != nil { @@ -219,6 +224,7 @@ func readRecipeCatalogueFS(target interface{}) error { return nil } +// readRecipeCatalogueWeb reads the catalogue from the web. func readRecipeCatalogueWeb(target interface{}) error { if err := web.ReadJSON(RecipeCatalogueURL, &target); err != nil { return err @@ -236,6 +242,7 @@ func readRecipeCatalogueWeb(target interface{}) error { return nil } +// VersionsOfService lists the version of a service. func VersionsOfService(recipe, serviceName string) ([]string, error) { catalogue, err := ReadRecipeCatalogue() if err != nil {