forked from toolshed/abra
refactor(recipe): rename Recipe2 -> Recipe
This commit is contained in:
@ -19,13 +19,13 @@ import (
|
||||
var Warn = "warn"
|
||||
var Critical = "critical"
|
||||
|
||||
type LintFunction func(recipe.Recipe2) (bool, error)
|
||||
type LintFunction func(recipe.Recipe) (bool, error)
|
||||
|
||||
// SkipFunction determines whether the LintFunction is run or not. It should
|
||||
// not take the lint rule level into account because some rules are always an
|
||||
// error but may depend on some additional context of the recipe configuration.
|
||||
// This function aims to cover those additional cases.
|
||||
type SkipFunction func(recipe.Recipe2) (bool, error)
|
||||
type SkipFunction func(recipe.Recipe) (bool, error)
|
||||
|
||||
// LintRule is a linting rule which helps a recipe maintainer avoid common
|
||||
// problems in their recipe configurations. We aim to highlight things that
|
||||
@ -42,7 +42,7 @@ type LintRule struct {
|
||||
}
|
||||
|
||||
// Skip implements the SkipFunction for the lint rule.
|
||||
func (l LintRule) Skip(recipe recipe.Recipe2) bool {
|
||||
func (l LintRule) Skip(recipe recipe.Recipe) bool {
|
||||
if l.SkipCondition != nil {
|
||||
ok, err := l.SkipCondition(recipe)
|
||||
if err != nil {
|
||||
@ -173,7 +173,7 @@ var LintRules = map[string][]LintRule{
|
||||
// LintForErrors lints specifically for errors and not other levels. This is
|
||||
// used in code paths such as "app deploy" to avoid nasty surprises but not for
|
||||
// the typical linting commands, which do handle other levels.
|
||||
func LintForErrors(recipe recipe.Recipe2) error {
|
||||
func LintForErrors(recipe recipe.Recipe) error {
|
||||
log.Debugf("linting for critical errors in %s configs", recipe.Name)
|
||||
|
||||
for level := range LintRules {
|
||||
@ -201,7 +201,7 @@ func LintForErrors(recipe recipe.Recipe2) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func LintComposeVersion(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintComposeVersion(recipe recipe.Recipe) (bool, error) {
|
||||
config, err := recipe.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -213,8 +213,8 @@ func LintComposeVersion(recipe recipe.Recipe2) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintEnvConfigPresent(r recipe.Recipe2) (bool, error) {
|
||||
r2 := recipe.Get2(r.Name)
|
||||
func LintEnvConfigPresent(r recipe.Recipe) (bool, error) {
|
||||
r2 := recipe.Get(r.Name)
|
||||
if _, err := os.Stat(r2.SampleEnvPath); !os.IsNotExist(err) {
|
||||
return true, nil
|
||||
}
|
||||
@ -222,7 +222,7 @@ func LintEnvConfigPresent(r recipe.Recipe2) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func LintAppService(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintAppService(recipe recipe.Recipe) (bool, error) {
|
||||
config, err := recipe.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -240,8 +240,8 @@ func LintAppService(recipe recipe.Recipe2) (bool, error) {
|
||||
// confirms that there is no "DOMAIN=..." in the .env.sample configuration of
|
||||
// the recipe. This typically means that no domain is required to deploy and
|
||||
// therefore no matching traefik deploy label will be present.
|
||||
func LintTraefikEnabledSkipCondition(r recipe.Recipe2) (bool, error) {
|
||||
r2 := recipe.Get2(r.Name)
|
||||
func LintTraefikEnabledSkipCondition(r recipe.Recipe) (bool, error) {
|
||||
r2 := recipe.Get(r.Name)
|
||||
sampleEnv, err := r2.SampleEnv()
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("Unable to discover .env.sample for %s", r2.Name)
|
||||
@ -254,7 +254,7 @@ func LintTraefikEnabledSkipCondition(r recipe.Recipe2) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func LintTraefikEnabled(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintTraefikEnabled(recipe recipe.Recipe) (bool, error) {
|
||||
config, err := recipe.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -272,7 +272,7 @@ func LintTraefikEnabled(recipe recipe.Recipe2) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func LintHealthchecks(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintHealthchecks(recipe recipe.Recipe) (bool, error) {
|
||||
config, err := recipe.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -286,7 +286,7 @@ func LintHealthchecks(recipe recipe.Recipe2) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintAllImagesTagged(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintAllImagesTagged(recipe recipe.Recipe) (bool, error) {
|
||||
config, err := recipe.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -304,7 +304,7 @@ func LintAllImagesTagged(recipe recipe.Recipe2) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintNoUnstableTags(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintNoUnstableTags(recipe recipe.Recipe) (bool, error) {
|
||||
config, err := recipe.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -331,7 +331,7 @@ func LintNoUnstableTags(recipe recipe.Recipe2) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintSemverLikeTags(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintSemverLikeTags(recipe recipe.Recipe) (bool, error) {
|
||||
config, err := recipe.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -358,7 +358,7 @@ func LintSemverLikeTags(recipe recipe.Recipe2) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintImagePresent(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintImagePresent(recipe recipe.Recipe) (bool, error) {
|
||||
config, err := recipe.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -371,7 +371,7 @@ func LintImagePresent(recipe recipe.Recipe2) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintHasPublishedVersion(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintHasPublishedVersion(recipe recipe.Recipe) (bool, error) {
|
||||
catl, err := recipePkg.ReadRecipeCatalogue(false)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -389,8 +389,8 @@ func LintHasPublishedVersion(recipe recipe.Recipe2) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintMetadataFilledIn(r recipe.Recipe2) (bool, error) {
|
||||
r2 := recipe.Get2(r.Name)
|
||||
func LintMetadataFilledIn(r recipe.Recipe) (bool, error) {
|
||||
r2 := recipe.Get(r.Name)
|
||||
features, category, err := recipe.GetRecipeFeaturesAndCategory(r2)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -411,7 +411,7 @@ func LintMetadataFilledIn(r recipe.Recipe2) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintAbraShVendors(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintAbraShVendors(recipe recipe.Recipe) (bool, error) {
|
||||
config, err := recipe.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -430,7 +430,7 @@ func LintAbraShVendors(recipe recipe.Recipe2) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintHasRecipeRepo(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintHasRecipeRepo(recipe recipe.Recipe) (bool, error) {
|
||||
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, recipe.Name)
|
||||
|
||||
res, err := http.Get(url)
|
||||
@ -445,7 +445,7 @@ func LintHasRecipeRepo(recipe recipe.Recipe2) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintSecretLengths(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintSecretLengths(recipe recipe.Recipe) (bool, error) {
|
||||
config, err := recipe.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -459,7 +459,7 @@ func LintSecretLengths(recipe recipe.Recipe2) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintValidTags(recipe recipe.Recipe2) (bool, error) {
|
||||
func LintValidTags(recipe recipe.Recipe) (bool, error) {
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipe.Name)
|
||||
|
||||
repo, err := git.PlainOpen(recipeDir)
|
||||
|
Reference in New Issue
Block a user