craft

package
v1.0.0-beta.18 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package craft provides all structs related to craft generation.

Index

Constants

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 File = ".craft"

File is the craft configuration file name.

View Source
const (
	// Mendio is the value for maintenance mode with renovate and mend.io (meaning no self-hosted renovate).
	Mendio string = "mend.io"
)

Variables

This section is empty.

Functions

func EncodeOpts

func EncodeOpts() []yaml.EncodeOption

EncodeOpts returns the options related to YAML encoding with goccy/go-yaml.

Types

type Auth

type Auth struct {
	// Maintenance represents the authentication method for the maintenance bot (renovate, dependabot, etc.).
	Maintenance *string `json:"-" yaml:"maintenance,omitempty"`

	// Release represents the authentication method for the release process (GitHub Token, Personal Access Token, etc.).
	// It's unavailable when working with a GitLab project.
	Release *string `json:"-" yaml:"release,omitempty"`
}

Auth contains all authentication methods related to CI configuration.

type CI

type CI struct {
	// Auth contains all authentication methods related to CI configuration.
	Auth Auth `json:"-" yaml:"auth,omitempty"`

	// Name represents the CI name (GitHub, GitLab, etc.).
	//
	// Note that those must be in lowercase.
	Name string `json:"-" yaml:"name,omitempty"`

	// Options is the slice of CI options.
	Options []string `json:"-" yaml:"options,omitempty"`

	// Release is the struct containing all tuning around release process (auto release, backmerge, etc.).
	Release *Release `json:"-" yaml:"release,omitempty"`

	// Static is the struct containing all tuning around static deployment (auto, name, etc.).
	Static *Static `json:"-" yaml:"static,omitempty"`
}

CI is the struct for craft continuous integration tuning.

type Config

type Config struct {
	parser.Executables `yaml:",inline"`

	// Bot represents the name of the maintenance bot (renovate, dependabot, etc).
	//
	// It's optional and some restrictions may apply (see craft JSON schema).
	// For instance, when working with GitLab, only Renovate is supported.
	Bot *string `json:"-" yaml:"bot,omitempty"`

	// CI is the structure containing all optional and configurable properties for CI purposes.
	CI *CI `json:"-" yaml:"ci,omitempty"`

	// Description represents the project description.
	Description *string `json:"description,omitempty" yaml:"description,omitempty"`

	// Docker is the structure containing all optional and configurable properties
	// for Dockerfile (and Helm in case a chart is generated).
	Docker *Docker `json:"docker,omitempty" yaml:"docker,omitempty"`

	// License is the project license name.
	License *string `json:"-" yaml:"license,omitempty"`

	// Languages is a map of languages name with its specificities.
	Languages map[string]any `json:"-" yaml:"-"`

	// Maintainers is the slice of all project maintainers.
	Maintainers []*Maintainer `json:"maintainers,omitempty" yaml:"maintainers,omitempty"`

	// NoChart can be given to avoid generating an Helm chart.
	//
	// By default, an Helm chart is generated since a project could satisfies one of the following possibilities:
	//	- the project is just an Helm chart for another product
	// 	- the project is a product with an Helm chart (with one or multiple resources, cronjobs, job, worker, etc)
	NoChart bool `json:"-" yaml:"no_chart,omitempty"`

	// NoGoreleaser can be given to avoid generating a .goreleaser.yml file.
	//
	// By default, if a given project is a Go project,
	// and a cmd CLI is defined (cmd/<some useful CLI name>)
	// a .goreleaser.yml file is generated.
	//
	// As such, it's unnecessary to specify this property when your project isn't a Go one.
	NoGoreleaser bool `json:"-" yaml:"no_goreleaser,omitempty"`

	// NoMakefile can be given to avoid generating a Makefile and additional Makefiles in scripts/mk/*.mk.
	//
	// When crafting a Node project, it's unnecessary to specify this property since no Makefile will be generated anyway.
	// It's because Node projects contain all their scripts in package.json.
	NoMakefile bool `json:"-" yaml:"no_makefile,omitempty"`

	parser.VCS `yaml:",inline"` // put at the end to get sorted properties (Platform especially) in written yaml file.
}

Config 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 (*Config) EnsureDefaults

func (c *Config) EnsureDefaults()

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

func (Config) HasDockerRegistry

func (c Config) HasDockerRegistry() bool

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

func (Config) HasRelease

func (c Config) HasRelease() bool

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

func (Config) IsAutoRelease

func (c Config) IsAutoRelease() bool

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

func (Config) IsBot

func (c Config) 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 (Config) IsCI

func (c Config) 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 (Config) IsMaintenanceAuth

func (c Config) 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 (Config) IsReleaseAuth

func (c Config) 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 (Config) IsStatic

func (c Config) 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.

func (*Config) SetLanguage

func (c *Config) SetLanguage(name string, value any)

SetLanguage sets a language with its specificities.

type Docker

type Docker struct {
	// Port represents the port to expose in the Dockerfile / Helm chart.
	//
	// It's shared for all cmd executables that could be defined in the project.
	Port *uint16 `json:"port,omitempty" yaml:"port,omitempty"`

	// Registry represents the Docker registry to use.
	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 is the boolean indicating whether release should be done automatically on default branch.
	Auto bool `json:"-" yaml:"auto,omitempty"`

	// Backmerge is the boolean indicating whether backmerge should be done during release process (with semantic-release).
	Backmerge bool `json:"-" yaml:"backmerge,omitempty"`
}

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

type Static

type Static struct {
	// Auto is the boolean indicating whether static deployment
	// should be done automatically on default branch.
	Auto bool `json:"-" yaml:"auto,omitempty"`

	// Name is the name of the static deployment (netlify, pages, etc.).
	Name string `json:"-" yaml:"name,omitempty"`
}

Static represents the configuration for static deployment.

Jump to

Keyboard shortcuts

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