lint

package
v0.0.0-...-004cd70 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2024 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Critical = "critical"
View Source
var LintRules = map[string][]LintRule{
	"warn": {
		{
			Ref:          "R001",
			Level:        "warn",
			Description:  "compose config has expected version",
			HowToResolve: "ensure 'version: \"3.8\"' in compose configs",
			Function:     LintComposeVersion,
		},
		{
			Ref:          "R002",
			Level:        "warn",
			Description:  "healthcheck enabled for all services",
			HowToResolve: "wire up healthchecks",
			Function:     LintHealthchecks,
		},
		{
			Ref:          "R003",
			Level:        "warn",
			Description:  "all images use a tag",
			HowToResolve: "use a tag for all images",
			Function:     LintAllImagesTagged,
		},
		{
			Ref:          "R004",
			Level:        "warn",
			Description:  "no unstable tags",
			HowToResolve: "tag all images with stable tags",
			Function:     LintNoUnstableTags,
		},
		{
			Ref:          "R005",
			Level:        "warn",
			Description:  "tags use semver-like format",
			HowToResolve: "use semver-like tags",
			Function:     LintSemverLikeTags,
		},
		{
			Ref:          "R006",
			Level:        "warn",
			Description:  "has published catalogue version",
			HowToResolve: "publish a recipe version to the catalogue",
			Function:     LintHasPublishedVersion,
		},
		{
			Ref:          "R007",
			Level:        "warn",
			Description:  "README.md metadata filled in",
			HowToResolve: "fill out all the metadata",
			Function:     LintMetadataFilledIn,
		},
		{
			Ref:          "R013",
			Level:        "warn",
			Description:  "git.coopcloud.tech repo exists",
			HowToResolve: "upload your recipe to git.coopcloud.tech/coop-cloud/...",
			Function:     LintHasRecipeRepo,
		},
		{
			Ref:          "R015",
			Level:        "warn",
			Description:  "long secret names",
			HowToResolve: "reduce length of secret names to 12 chars",
			Function:     LintSecretLengths,
		},
	},
	"error": {
		{
			Ref:          "R008",
			Level:        "error",
			Description:  ".env.sample provided",
			HowToResolve: "create an example .env.sample",
			Function:     LintEnvConfigPresent,
		},
		{
			Ref:          "R009",
			Level:        "error",
			Description:  "one service named 'app'",
			HowToResolve: "name a servce 'app'",
			Function:     LintAppService,
		},
		{
			Ref:           "R010",
			Level:         "error",
			Description:   "traefik routing enabled",
			HowToResolve:  "include \"traefik.enable=true\" deploy label",
			Function:      LintTraefikEnabled,
			SkipCondition: LintTraefikEnabledSkipCondition,
		},
		{
			Ref:          "R011",
			Level:        "error",
			Description:  "all services have images",
			HowToResolve: "ensure \"image: ...\" set on all services",
			Function:     LintImagePresent,
		},
		{
			Ref:          "R012",
			Level:        "error",
			Description:  "config version are vendored",
			HowToResolve: "vendor config versions in an abra.sh",
			Function:     LintAbraShVendors,
		},
		{
			Ref:          "R014",
			Level:        "error",
			Description:  "only annotated tags used for recipe version",
			HowToResolve: "replace lightweight tag with annotated tag",
			Function:     LintValidTags,
		},
	},
}
View Source
var Warn = "warn"

Functions

func LintAbraShVendors

func LintAbraShVendors(recipe recipe.Recipe) (bool, error)

func LintAllImagesTagged

func LintAllImagesTagged(recipe recipe.Recipe) (bool, error)

func LintAppService

func LintAppService(recipe recipe.Recipe) (bool, error)

func LintComposeVersion

func LintComposeVersion(recipe recipe.Recipe) (bool, error)

func LintEnvConfigPresent

func LintEnvConfigPresent(recipe recipe.Recipe) (bool, error)

func LintForErrors

func LintForErrors(recipe recipe.Recipe) error

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 LintHasPublishedVersion

func LintHasPublishedVersion(recipe recipe.Recipe) (bool, error)

func LintHasRecipeRepo

func LintHasRecipeRepo(recipe recipe.Recipe) (bool, error)

func LintHealthchecks

func LintHealthchecks(recipe recipe.Recipe) (bool, error)

func LintImagePresent

func LintImagePresent(recipe recipe.Recipe) (bool, error)

func LintMetadataFilledIn

func LintMetadataFilledIn(r recipe.Recipe) (bool, error)

func LintNoUnstableTags

func LintNoUnstableTags(recipe recipe.Recipe) (bool, error)

func LintSecretLengths

func LintSecretLengths(recipe recipe.Recipe) (bool, error)

func LintSemverLikeTags

func LintSemverLikeTags(recipe recipe.Recipe) (bool, error)

func LintTraefikEnabled

func LintTraefikEnabled(recipe recipe.Recipe) (bool, error)

func LintTraefikEnabledSkipCondition

func LintTraefikEnabledSkipCondition(recipe recipe.Recipe) (bool, error)

LintTraefikEnabledSkipCondition signals a skip for this linting rule if it 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 LintValidTags

func LintValidTags(recipe recipe.Recipe) (bool, error)

Types

type LintFunction

type LintFunction func(recipe.Recipe) (bool, error)

type LintRule

type LintRule struct {
	Ref           string       // Reference of the linting rule
	Level         string       // Level of the warning
	Description   string       // Description of the issue
	HowToResolve  string       // Documentation for recipe maintainer
	Function      LintFunction // Rule implementation
	SkipCondition SkipFunction // Whether or not to execute the lint rule
}

LintRule is a linting rule which helps a recipe maintainer avoid common problems in their recipe configurations. We aim to highlight things that might result in critical errors or hours lost in debugging obscure Docker-isms. Humans make the final call on these rules, please raise an issue if you disagree.

func (LintRule) Skip

func (l LintRule) Skip(recipe recipe.Recipe) bool

Skip implements the SkipFunction for the lint rule.

type SkipFunction

type SkipFunction 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL