forked from toolshed/abra
fix: stream logs without hitting git.coopcloud.tech
Medium-sized options refactor in here too! See coop-cloud/organising#292.
This commit is contained in:
@ -18,6 +18,7 @@ import (
|
||||
"coopcloud.tech/abra/pkg/formatter"
|
||||
gitPkg "coopcloud.tech/abra/pkg/git"
|
||||
"coopcloud.tech/abra/pkg/limit"
|
||||
"coopcloud.tech/abra/pkg/runtime"
|
||||
"coopcloud.tech/abra/pkg/upstream/stack"
|
||||
loader "coopcloud.tech/abra/pkg/upstream/stack"
|
||||
"coopcloud.tech/abra/pkg/web"
|
||||
@ -206,8 +207,8 @@ func (r Recipe) Tags() ([]string, error) {
|
||||
}
|
||||
|
||||
// Get retrieves a recipe.
|
||||
func Get(recipeName string) (Recipe, error) {
|
||||
if err := EnsureExists(recipeName); err != nil {
|
||||
func Get(recipeName string, conf *runtime.Config) (Recipe, error) {
|
||||
if err := EnsureExists(recipeName, conf); err != nil {
|
||||
return Recipe{}, err
|
||||
}
|
||||
|
||||
@ -233,7 +234,7 @@ func Get(recipeName string) (Recipe, error) {
|
||||
return Recipe{}, err
|
||||
}
|
||||
|
||||
meta, err := GetRecipeMeta(recipeName)
|
||||
meta, err := GetRecipeMeta(recipeName, conf)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "does not exist") {
|
||||
meta = RecipeMeta{}
|
||||
@ -250,7 +251,11 @@ func Get(recipeName string) (Recipe, error) {
|
||||
}
|
||||
|
||||
// EnsureExists ensures that a recipe is locally cloned
|
||||
func EnsureExists(recipeName string) error {
|
||||
func EnsureExists(recipeName string, conf *runtime.Config) error {
|
||||
if !conf.EnsureRecipeExists {
|
||||
return nil
|
||||
}
|
||||
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
|
||||
|
||||
if _, err := os.Stat(recipeDir); os.IsNotExist(err) {
|
||||
@ -333,7 +338,7 @@ func EnsureVersion(recipeName, version string) error {
|
||||
}
|
||||
|
||||
// EnsureLatest makes sure the latest commit is checked out for a local recipe repository
|
||||
func EnsureLatest(recipeName string) error {
|
||||
func EnsureLatest(recipeName string, conf *runtime.Config) error {
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
|
||||
|
||||
isClean, err := gitPkg.IsClean(recipeDir)
|
||||
@ -361,7 +366,7 @@ func EnsureLatest(recipeName string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
meta, err := GetRecipeMeta(recipeName)
|
||||
meta, err := GetRecipeMeta(recipeName, conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -790,7 +795,7 @@ func VersionsOfService(recipe, serviceName string) ([]string, error) {
|
||||
}
|
||||
|
||||
// GetRecipeMeta retrieves the recipe metadata from the recipe catalogue.
|
||||
func GetRecipeMeta(recipeName string) (RecipeMeta, error) {
|
||||
func GetRecipeMeta(recipeName string, conf *runtime.Config) (RecipeMeta, error) {
|
||||
catl, err := ReadRecipeCatalogue()
|
||||
if err != nil {
|
||||
return RecipeMeta{}, err
|
||||
@ -801,7 +806,7 @@ func GetRecipeMeta(recipeName string) (RecipeMeta, error) {
|
||||
return RecipeMeta{}, fmt.Errorf("recipe %s does not exist?", recipeName)
|
||||
}
|
||||
|
||||
if err := EnsureExists(recipeName); err != nil {
|
||||
if err := EnsureExists(recipeName, conf); err != nil {
|
||||
return RecipeMeta{}, err
|
||||
}
|
||||
|
||||
@ -923,8 +928,9 @@ func ReadReposMetadata() (RepoCatalogue, error) {
|
||||
}
|
||||
|
||||
// GetRecipeVersions retrieves all recipe versions.
|
||||
func GetRecipeVersions(recipeName string) (RecipeVersions, error) {
|
||||
func GetRecipeVersions(recipeName string, opts ...runtime.Option) (RecipeVersions, error) {
|
||||
versions := RecipeVersions{}
|
||||
conf := runtime.New(opts...)
|
||||
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
|
||||
|
||||
@ -962,7 +968,7 @@ func GetRecipeVersions(recipeName string) (RecipeVersions, error) {
|
||||
|
||||
logrus.Debugf("successfully checked out %s in %s", ref.Name(), recipeDir)
|
||||
|
||||
recipe, err := Get(recipeName)
|
||||
recipe, err := Get(recipeName, conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user