Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTimeout is the default timeout for operations.
	DefaultTimeout = 5 * time.Minute
	// DefaultIssuesExitCode is the default exit code when lint issues are found.
	DefaultIssuesExitCode = 1
)
View Source
const (
	LinterVersions    = "versions"
	LinterPermissions = "permissions"
	LinterFormat      = "format"
	LinterSecrets     = "secrets"
	LinterInjection   = "injection"
	LinterStyle       = "style"
)

Linter name constants.

View Source
const DefaultConfigFileName = ".github-ci.yaml"

DefaultConfigFileName is the default name of the configuration file.

Variables

View Source
var DefaultActionConfig = ActionConfig{Constraint: defaultVersionConstraint}

DefaultActionConfig is the default configuration for newly discovered actions.

Functions

func NormalizeActionName

func NormalizeActionName(uses string) string

NormalizeActionName extracts the action name from a uses string.

func SaveConfig

func SaveConfig(cfg *Config, filename string) error

SaveConfig saves the configuration to the specified file.

func ShouldUpdate

func ShouldUpdate(currentVersion, newVersion, constraint string) bool

ShouldUpdate determines if a version update should be applied. Constraints:

  • "": any newer version
  • "^X.0.0": same major version (X.y.z)
  • "~X.Y.0": same major.minor version (X.Y.z)

Types

type ActionConfig

type ActionConfig struct {
	Constraint string `yaml:"constraint"`
}

ActionConfig specifies the version constraint for a GitHub Action.

type Config

type Config struct {
	Run     *RunConfig     `yaml:"run,omitempty"`
	Linters *LinterConfig  `yaml:"linters,omitempty"`
	Upgrade *UpgradeConfig `yaml:"upgrade,omitempty"`
}

Config represents the GitHub CI configuration file structure.

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig loads configuration from the specified file. Returns defaults if file doesn't exist.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig creates a new Config with default values.

func NewFullDefaultConfig

func NewFullDefaultConfig() *Config

NewFullDefaultConfig creates a new Config with all settings explicitly set to defaults. This is useful for generating a complete configuration file with all options visible.

func (*Config) GetActionConfig

func (c *Config) GetActionConfig(actionName string) ActionConfig

GetActionConfig returns the action config, or default if not found.

func (*Config) GetFormatSettings

func (c *Config) GetFormatSettings() *FormatSettings

GetFormatSettings returns the format linter settings from config.

func (*Config) GetIssuesExitCode

func (c *Config) GetIssuesExitCode() int

GetIssuesExitCode returns the configured exit code for when issues are found. Returns DefaultIssuesExitCode (1) if not configured or invalid. Exit codes must be in range 1-255; values outside this range return the default.

func (*Config) GetStyleSettings

func (c *Config) GetStyleSettings() *StyleSettings

GetStyleSettings returns the style linter settings from config.

func (*Config) GetTimeout

func (c *Config) GetTimeout() time.Duration

GetTimeout returns the configured timeout duration. Returns DefaultTimeout if not configured or invalid.

func (*Config) GetVersionFormat

func (c *Config) GetVersionFormat() string

GetVersionFormat returns the version format for upgrades: "tag", "hash", or "major". Defaults to "tag" if not specified.

func (*Config) IsLinterEnabled

func (c *Config) IsLinterEnabled(linterName string) bool

IsLinterEnabled checks if a linter is enabled based on configuration.

func (*Config) SetActionConfig

func (c *Config) SetActionConfig(actionName string, cfg ActionConfig)

SetActionConfig sets the configuration for an action.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks all configuration values for validity.

type FormatSettings

type FormatSettings struct {
	// IndentWidth is the number of spaces per indentation level (default: 2)
	IndentWidth int `yaml:"indent-width"`
	// MaxLineLength is the maximum allowed line length (default: 120)
	MaxLineLength int `yaml:"max-line-length"`
}

FormatSettings contains settings for the format linter.

func DefaultFormatSettings

func DefaultFormatSettings() *FormatSettings

DefaultFormatSettings returns the default format linter settings.

func (*FormatSettings) Validate

func (f *FormatSettings) Validate() error

Validate checks FormatSettings for invalid values.

type LinterConfig

type LinterConfig struct {
	Default  string          `yaml:"default"`            // "all" or "none"
	Enable   []string        `yaml:"enable"`             // Linters to enable
	Disable  []string        `yaml:"disable"`            // Linters to disable
	Settings *LinterSettings `yaml:"settings,omitempty"` // Per-linter settings
}

LinterConfig specifies which linters to enable and their behavior. Disabled linters take precedence over enabled linters.

func DefaultLinterConfig

func DefaultLinterConfig() *LinterConfig

DefaultLinterConfig returns a minimal LinterConfig with default values.

func FullDefaultLinterConfig

func FullDefaultLinterConfig() *LinterConfig

FullDefaultLinterConfig returns a LinterConfig with all settings explicitly set.

func (*LinterConfig) Validate

func (l *LinterConfig) Validate() error

Validate checks LinterConfig for invalid values.

type LinterSettings

type LinterSettings struct {
	Format *FormatSettings `yaml:"format,omitempty"`
	Style  *StyleSettings  `yaml:"style,omitempty"`
}

LinterSettings contains per-linter configuration.

func (*LinterSettings) Validate

func (s *LinterSettings) Validate() error

Validate checks LinterSettings for invalid values.

type RunConfig

type RunConfig struct {
	Timeout        string `yaml:"timeout"`          // Duration string (e.g., "2m", "30s")
	IssuesExitCode int    `yaml:"issues-exit-code"` // Exit code when issues are found (default: 1)
}

RunConfig specifies general runtime settings.

func (*RunConfig) Validate

func (r *RunConfig) Validate() error

Validate checks RunConfig for invalid values.

type StyleSettings

type StyleSettings struct {
	// MinNameLength is the minimum allowed characters for names (default: 3)
	MinNameLength int `yaml:"min-name-length"`
	// MaxNameLength is the maximum allowed characters for names (default: 50)
	MaxNameLength int `yaml:"max-name-length"`
	// NamingConvention enforces naming style (default: "" - no enforcement):
	//   - "title": Every word must start with uppercase (e.g., "Build And Test", "Setup Go")
	//   - "sentence": Name must start with uppercase (e.g., "Build and test", "Upload to Codecov")
	//   - "": No naming convention enforced
	NamingConvention string `yaml:"naming-convention"`
	// CheckoutFirst warns if actions/checkout is not the first step
	CheckoutFirst bool `yaml:"checkout-first"`
	// RequireStepNames requires all steps to have explicit names
	RequireStepNames bool `yaml:"require-step-names"`
	// MaxRunLines is the maximum allowed lines in a run script (0 = disabled)
	MaxRunLines int `yaml:"max-run-lines"`
}

StyleSettings contains settings for the style linter.

func DefaultStyleSettings

func DefaultStyleSettings() *StyleSettings

DefaultStyleSettings returns the default style linter settings.

func (*StyleSettings) Validate

func (s *StyleSettings) Validate() error

Validate checks StyleSettings for invalid values.

type UpgradeConfig

type UpgradeConfig struct {
	Actions map[string]ActionConfig `yaml:"actions"`
	Format  string                  `yaml:"format"` // "tag", "hash", or "major"
}

UpgradeConfig specifies settings for the upgrade command.

func DefaultUpgradeConfig

func DefaultUpgradeConfig() *UpgradeConfig

DefaultUpgradeConfig returns an UpgradeConfig with default values.

func (*UpgradeConfig) EnsureDefaults

func (u *UpgradeConfig) EnsureDefaults()

EnsureDefaults sets default values for any uninitialized fields.

func (*UpgradeConfig) Validate

func (u *UpgradeConfig) Validate() error

Validate checks UpgradeConfig for invalid values.

Jump to

Keyboard shortcuts

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