forked from toolshed/abra
refactor(recipe): don't use README.md path directly
This commit is contained in:
@ -215,9 +215,11 @@ func Get(recipeName string, offline bool) (Recipe, error) {
|
||||
func Get2(name string) Recipe2 {
|
||||
dir := path.Join(config.RECIPES_DIR, name)
|
||||
return Recipe2{
|
||||
Name: name,
|
||||
Dir: dir,
|
||||
SSHURL: fmt.Sprintf(config.SSH_URL_TEMPLATE, name),
|
||||
Name: name,
|
||||
Dir: dir,
|
||||
SSHURL: fmt.Sprintf(config.SSH_URL_TEMPLATE, name),
|
||||
|
||||
ReadmePath: path.Join(dir, "README.md"),
|
||||
SampleEnvPath: path.Join(dir, ".env.sample"),
|
||||
}
|
||||
}
|
||||
@ -227,6 +229,7 @@ type Recipe2 struct {
|
||||
Dir string
|
||||
SSHURL string
|
||||
|
||||
ReadmePath string
|
||||
SampleEnvPath string
|
||||
}
|
||||
|
||||
@ -261,22 +264,20 @@ func GetVersionLabelLocal(recipe Recipe) (string, error) {
|
||||
return label, nil
|
||||
}
|
||||
|
||||
func GetRecipeFeaturesAndCategory(recipeName string) (Features, string, error) {
|
||||
func GetRecipeFeaturesAndCategory(r Recipe2) (Features, string, error) {
|
||||
feat := Features{}
|
||||
|
||||
var category string
|
||||
|
||||
readmePath := path.Join(config.RECIPES_DIR, recipeName, "README.md")
|
||||
log.Debugf("attempting to open %s for recipe metadata parsing", r.ReadmePath)
|
||||
|
||||
log.Debugf("attempting to open %s for recipe metadata parsing", readmePath)
|
||||
|
||||
readmeFS, err := ioutil.ReadFile(readmePath)
|
||||
readmeFS, err := ioutil.ReadFile(r.ReadmePath)
|
||||
if err != nil {
|
||||
return feat, category, err
|
||||
}
|
||||
|
||||
readmeMetadata, err := GetStringInBetween( // Find text between delimiters
|
||||
recipeName,
|
||||
r.Name,
|
||||
string(readmeFS),
|
||||
"<!-- metadata -->", "<!-- endmetadata -->",
|
||||
)
|
||||
@ -327,7 +328,7 @@ func GetRecipeFeaturesAndCategory(recipeName string) (Features, string, error) {
|
||||
if strings.Contains(val, "**Image**") {
|
||||
imageMetadata, err := GetImageMetadata(strings.TrimSpace(
|
||||
strings.TrimPrefix(val, "* **Image**:"),
|
||||
), recipeName)
|
||||
), r.Name)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
Reference in New Issue
Block a user