forked from toolshed/abra
fix: add warning for long secret names (!359)
A start of a fix for coop-cloud/organising#463 Putting some code out to start a discussion. I've added a linting rule for recipes to establish a general principal but I want to put some validation into cli/app/new.go as that's the point we have both the recipe and the domain and can say for sure whether or not the secret names lengths cause a problem but that will have to wait for a bit. Let me know if I've missed the mark somewhere Reviewed-on: coop-cloud/abra#359 Reviewed-by: decentral1se <decentral1se@noreply.git.coopcloud.tech> Co-authored-by: Rich M <r.p.makepeace@gmail.com> Co-committed-by: Rich M <r.p.makepeace@gmail.com>
This commit is contained in:
@ -115,6 +115,13 @@ var LintRules = map[string][]LintRule{
|
||||
HowToResolve: "upload your recipe to git.coopcloud.tech/coop-cloud/...",
|
||||
Function: LintHasRecipeRepo,
|
||||
},
|
||||
{
|
||||
Ref: "R014",
|
||||
Level: "warn",
|
||||
Description: "Long secret names",
|
||||
HowToResolve: "Reduce the length of secret names to 12 characters.",
|
||||
Function: LintSecretLengths,
|
||||
},
|
||||
},
|
||||
"error": {
|
||||
{
|
||||
@ -401,6 +408,16 @@ func LintHasRecipeRepo(recipe recipe.Recipe) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintSecretLengths(recipe recipe.Recipe) (bool, error) {
|
||||
for name := range recipe.Config.Secrets {
|
||||
if len(name) > 12 {
|
||||
return false, fmt.Errorf("secret %s is longer than 12 characters", name)
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func LintValidTags(recipe recipe.Recipe) (bool, error) {
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipe.Name)
|
||||
|
||||
|
Reference in New Issue
Block a user