craft

package
v1.0.0-beta.17 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package craft provides all structs and functions related to craft configuration reading and writing alongside some useful constants.

For further information, please check the struct documentation or even craft project global README.md explaining each and every property that can be set through .craft file.

Index

Constants

View Source
const (
	// File is the craft configuration file name.
	File = ".craft"

	// TmplExtension is the extension for templates file.
	TmplExtension = ".tmpl"

	// PartExtension is the extension for templates files' subparts.
	//
	// It must be used with TmplExtension
	// and as such files with only templates parts (define) can be created.
	PartExtension = ".part"

	// PatchExtension is the extension for templates files patches.
	//
	// It will be used in the future to patch altered files by users to follow updates with less generation issues.
	PatchExtension = ".patch"

	// Gocmd represents the cmd folder where go main.go should be placed according to go layout.
	Gocmd = "cmd"
	// Gomod represents the go.mod filename.
	Gomod = "go.mod"
	// PackageJSON represents package.json filename.
	PackageJSON = "package.json"

	// License represents the target filename for the generated project LICENSE.
	License = "LICENSE"
)
View Source
const (
	// Bitbucket is just the bitbucket constant.
	Bitbucket = "bitbucket"
	// Gitea is just the gitea constant.
	Gitea = "gitea"
	// GitHub is just the github constant.
	GitHub = "github"
	// GitLab is just the gitlab constant.
	GitLab = "gitlab"
)
View Source
const (
	// CodeCov is the codecov option for CI tuning.
	CodeCov string = "codecov"
	// CodeQL is the codeql option for CI tuning.
	CodeQL string = "codeql"
	// Labeler is the auto labeling option for CI tuning.
	Labeler string = "labeler"
	// Sonar is the sonar option for CI tuning.
	Sonar string = "sonar"
)
View Source
const (
	// Netlify is the static name to deploy on netlify (only available on github actions).
	Netlify string = "netlify"
	// Pages is the static name for pages deployment.
	Pages string = "pages"
)
View Source
const (
	// Dependabot is the dependabot updater name for CI maintenance configuration.
	Dependabot string = "dependabot"
	// Renovate is the renovate updater name for CI maintenance configuration.
	Renovate string = "renovate"
)
View Source
const (
	// GitHubApp is the value for github release mode with a github app.
	GitHubApp string = "github-app"
	// GitHubToken is the value for github release mode with a github token.
	GitHubToken string = "github-token"
	// PersonalToken is the value for github release mode with a personal token (PAT).
	PersonalToken string = "personal-token"
)
View Source
const (
	// Mendio is the value for maintenance mode with renovate and mend.io (meaning no self-hosted renovate).
	Mendio string = "mend.io"
)
View Source
const SemanticRelease string = "semantic-release"

SemanticRelease is the value for github / gitlab release with semantic-release.

Variables

This section is empty.

Functions

func Read

func Read(src string, out any) error

Read reads the .craft file in srcdir input into the out input.

func Validate

func Validate(src string) error

Validate validates .craft file from srcdir following craft schema.

func Write

func Write(dest string, config Configuration) error

Write writes the input craft into the input destdir in .craft file.

Types

type Auth

type Auth struct {
	Maintenance *string `json:"-" yaml:"maintenance,omitempty"`
	Release     *string `json:"-" yaml:"release,omitempty"`
}

Auth contains all authentication methods related to CI configuration.

type CI

type CI struct {
	Auth    Auth     `json:"-" yaml:"auth,omitempty"`
	Name    string   `json:"-" yaml:"name,omitempty"`
	Options []string `json:"-" yaml:"options,omitempty"`
	Release *Release `json:"-" yaml:"release,omitempty"`
	Static  *Static  `json:"-" yaml:"static,omitempty"`
}

CI is the struct for craft continuous integration tuning.

type Configuration

type Configuration struct {
	Bot          *string       `json:"-"                     yaml:"bot,omitempty"`
	CI           *CI           `json:"-"                     yaml:"ci,omitempty"`
	Description  *string       `json:"description,omitempty" yaml:"description,omitempty"`
	Docker       *Docker       `json:"docker,omitempty"      yaml:"docker,omitempty"`
	License      *string       `json:"-"                     yaml:"license,omitempty"`
	Maintainers  []*Maintainer `json:"maintainers,omitempty" yaml:"maintainers,omitempty"`
	NoChart      bool          `json:"-"                     yaml:"no_chart,omitempty"`
	NoGoreleaser bool          `json:"-"                     yaml:"no_goreleaser,omitempty"`
	NoMakefile   bool          `json:"-"                     yaml:"no_makefile,omitempty"`
	NoReadme     bool          `json:"-"                     yaml:"no_readme,omitempty"`
	Platform     string        `json:"-"                     yaml:"platform,omitempty"`
}

Configuration represents all options configurable in .craft file at root project.

Note that yaml tags are for .craft file property keys and json tags for templating data.

func (*Configuration) EnsureDefaults

func (c *Configuration) EnsureDefaults()

EnsureDefaults migrates old properties into new fields and ensures default properties are always sets.

func (Configuration) HasDockerRegistry

func (c Configuration) HasDockerRegistry() bool

HasDockerRegistry returns truthy in case the configuration has a docker registry configuration.

func (Configuration) HasRelease

func (c Configuration) HasRelease() bool

HasRelease returns truthy in case the configuration has CI enabled and Release configuration.

func (Configuration) IsAutoRelease

func (c Configuration) IsAutoRelease() bool

IsAutoRelease returns truthy in case the configuration has CI enabled, release enabled and auto actived.

func (Configuration) IsBot

func (c Configuration) IsBot(bot string) bool

IsBot returns truthy in case the input bot is the one specified in configuration.

It returns false if no maintenance bot is specified in configuration.

func (Configuration) IsCI

func (c Configuration) IsCI(name string) bool

IsCI returns truthy in case the input name is the one specified in configuration.

It returns false if CI is disabled.

func (Configuration) IsMaintenanceAuth

func (c Configuration) IsMaintenanceAuth(auth string) bool

IsMaintenanceAuth returns truthy in case the input auth value is the one specified in configuration maintenance auth.

It returns false if neither CI or auth maintenance isn't specified in configuration.

func (Configuration) IsReleaseAuth

func (c Configuration) IsReleaseAuth(auth string) bool

IsReleaseAuth returns truthy in case the input auth value is the one specified in configuration release auth.

It returns false if neither CI or auth release isn't specified in configuration.

func (Configuration) IsStatic

func (c Configuration) IsStatic(static string) bool

IsStatic returns truthy in case the input static value is the one specified in configuration as static name.

It returns false in case there's no CI or no Static configuration.

type Docker

type Docker struct {
	Port     *uint16 `json:"port,omitempty"     yaml:"port,omitempty"`
	Registry *string `json:"registry,omitempty" yaml:"registry,omitempty"`
}

Docker is the struct for craft docker tuning.

type Maintainer

type Maintainer struct {
	Email *string `json:"email,omitempty" yaml:"email,omitempty"`
	Name  string  `json:"name,omitempty"  yaml:"name,omitempty"`
	URL   *string `json:"url,omitempty"   yaml:"url,omitempty"`
}

Maintainer represents a project maintainer. It's inspired from helm Maintainer struct.

The only difference are the present tags and the pointers on both email and url properties.

type Release

type Release struct {
	Auto      bool `json:"-" yaml:"auto,omitempty"`
	Backmerge bool `json:"-" yaml:"backmerge,omitempty"`
}

Release is the struct for craft continuous integration release specifics configuration.

type Static

type Static struct {
	Auto bool   `json:"-" yaml:"auto,omitempty"`
	Name string `json:"-" yaml:"name,omitempty"`
}

Static represents the configuration for static deployment.

type ValidationError

type ValidationError struct {
	Message  string
	Property string
}

ValidationError represents a simplified view of jsonschema.ValidationError.

It it used to override specific error messages (like kind.FalseSchema "false schema") in craft validation context.

func (*ValidationError) Error

func (v *ValidationError) Error() string

Jump to

Keyboard shortcuts

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