Documentation
¶
Overview ¶
Package config contains functions related to config files
Index ¶
- Constants
- func GetManifestPath(manifestFile string, manifestType string) string
- func GetManifestType(fullPath string) string
- func IsRegistryUsed(manifestFile string, manifestPath string, defaultRegistry DefaultRegistry, ...) bool
- func PathWithEndingSlash(path string) string
- func ScanFileList(files []string, manifests map[string]string)
- func ScanLocalDirectory(baseDirectory string, directory string, manifests map[string]string)
- func SlotFor(salt string, repo string, slotCount int) int
- type Allow
- type ChangeInfo
- type CheckDirectoryExists
- type CheckDirectoryExistsParameters
- type CommitMessage
- type Cooldown
- type DefaultRegistries
- type DefaultRegistry
- type DependabotConfig
- func (config *DependabotConfig) IsManifestCovered(manifestFile string, manifestType string, updateRegistries []string) bool
- func (config *DependabotConfig) Parse(data []byte) error
- func (config *DependabotConfig) ProcessManifest(manifestFile string, manifestType string, toolConfig ToolConfig, ...)
- func (config *DependabotConfig) ToYaml() []byte
- func (config *DependabotConfig) ToYamlKeepingQuotes(original []byte) []byte
- func (config *DependabotConfig) UpdateConfig(manifests map[string]string, toolConfig ToolConfig, repoSettings RepoSettings, ...) (ChangeInfo, error)
- type DirectoryGrouping
- type Enforce
- type EnforceException
- type EnforcedUpdateInfo
- type Group
- type Groups
- type Ignore
- type KeyValue
- type LenientBool
- type LoadFileContent
- type LoadFileContentParameters
- type ManifestReport
- type NamedGroup
- type PullRequestParameters
- type Registry
- type RegistryInfo
- type RemoteClient
- type RepoReport
- type RepoSettings
- type Schedule
- type ScheduleReport
- type ScheduleSlots
- type SkippedRepoReport
- type SlotWindow
- type ToolConfig
- type Update
- type UpdateDefaults
- type UpdateInfo
- type UpdateReport
Constants ¶
const ( DirectoriesGlobal = "global" DirectoriesPerApp = "per-app" )
Directory grouping modes.
const ( EnforceSchedule = "schedule" EnforceCooldown = "cooldown" EnforceOpenPullRequestsLimit = "open-pull-requests-limit" EnforceGroups = "groups" EnforceDirectoryGrouping = "directory-grouping" )
Fields of an existing update entry that can be enforced.
Variables ¶
This section is empty.
Functions ¶
func GetManifestPath ¶ added in v0.3.0
GetManifestPath returns the path of the absolute path of a manifest file
func GetManifestType ¶
GetManifestType returns the type of manifest file, if any.
func IsRegistryUsed ¶ added in v0.3.0
func IsRegistryUsed(manifestFile string, manifestPath string, defaultRegistry DefaultRegistry, loadFileFn LoadFileContent, loadFileParams LoadFileContentParameters, ) bool
IsRegistryUsed returns if a registry is used by a manifest file
func PathWithEndingSlash ¶ added in v0.3.2
PathWithEndingSlash returns a path with an added slash, if needed
func ScanFileList ¶
ScanFileList looks for manifest files, in a list of file names (incl. path)
func ScanLocalDirectory ¶
ScanLocalDirectory lists all files in a directory, recursively
Types ¶
type Allow ¶ added in v0.2.0
type Allow struct {
DependencyName string `yaml:"dependency-name,omitempty"`
DependencyType string `yaml:"dependency-type,omitempty"`
Unknown map[string]any `yaml:",inline"`
}
Allow holds the config items of an allow definition
type ChangeInfo ¶
type ChangeInfo struct {
NewRegistries []RegistryInfo
RemovedRegistries []RegistryInfo
NewUpdates []UpdateInfo
FixedUpdates []UpdateInfo
RemovedUpdates []UpdateInfo
EnforcedUpdates []EnforcedUpdateInfo
}
ChangeInfo holds the changes applied to a config.
func (ChangeInfo) OnlyEnforced ¶ added in v0.11.0
func (changeInfo ChangeInfo) OnlyEnforced() bool
OnlyEnforced returns whether enforced fields of existing updates are the only changes.
type CheckDirectoryExists ¶ added in v0.7.0
type CheckDirectoryExists func(directory string, params CheckDirectoryExistsParameters) (bool, error)
CheckDirectoryExists is a function type for checking if a folder exists. It returns an error when it cannot tell.
type CheckDirectoryExistsParameters ¶ added in v0.7.0
type CheckDirectoryExistsParameters struct {
Client RemoteClient
Org string
Repo string
Directory string
}
CheckDirectoryExistsParameters holds all parameters needed for the CheckDirectoryExists function implementations.
type CommitMessage ¶
type CommitMessage struct {
Prefix string `yaml:"prefix,omitempty"`
PrefixDevelopment string `yaml:"prefix-development,omitempty"`
Include string `yaml:"include,omitempty"`
Unknown map[string]any `yaml:",inline"`
}
CommitMessage holds the config items for the commit message
type Cooldown ¶ added in v0.8.0
type Cooldown struct {
SemverMajorDays int `yaml:"semver-major-days,omitempty"`
SemverMinorDays int `yaml:"semver-minor-days,omitempty"`
SemverPatchDays int `yaml:"semver-patch-days,omitempty"`
DefaultDays int `yaml:"default-days,omitempty"`
Include []string `yaml:"include,omitempty"`
Exclude []string `yaml:"exclude,omitempty"`
Unknown map[string]any `yaml:",inline"`
}
Cooldown holds the cooldown configuration for different semver update types
type DefaultRegistries ¶
type DefaultRegistries map[string]DefaultRegistry
DefaultRegistries holds the default registries for new update definitions
type DefaultRegistry ¶ added in v0.2.0
type DefaultRegistry struct {
Type string `yaml:"type"`
URL string `yaml:"url"`
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
URLMatchRequired bool `yaml:"url-match-required,omitempty"`
URLMatchAdditionalFiles []string `yaml:"url-match-additional-files,omitempty"`
}
DefaultRegistry holds the config items of a default registry
type DependabotConfig ¶
type DependabotConfig struct {
Version int `yaml:"version"`
Registries map[string]Registry `yaml:"registries,omitempty"`
Updates []Update `yaml:"updates"`
EnableBetaEcoSystems bool `yaml:"enable-beta-ecosystems,omitempty"`
Unknown map[string]any `yaml:",inline"`
}
DependabotConfig holds the configuration defined in dependabot.yml
func ParseDependabotConfig ¶
func ParseDependabotConfig(fileContent []byte) (*DependabotConfig, error)
ParseDependabotConfig parses the config file
func (*DependabotConfig) IsManifestCovered ¶
func (config *DependabotConfig) IsManifestCovered(manifestFile string, manifestType string, updateRegistries []string) bool
IsManifestCovered returns if a manifest file is covered within a dependabot.yml config
func (*DependabotConfig) Parse ¶
func (config *DependabotConfig) Parse(data []byte) error
Parse parses the dependabot.yml format
func (*DependabotConfig) ProcessManifest ¶ added in v0.3.3
func (config *DependabotConfig) ProcessManifest(manifestFile string, manifestType string, toolConfig ToolConfig, repoSettings RepoSettings, changeInfo *ChangeInfo, loadFileFn LoadFileContent, loadFileParams LoadFileContentParameters, )
ProcessManifest adds config for a new manifest file to dependabot.yml if necessary
func (*DependabotConfig) ToYaml ¶
func (config *DependabotConfig) ToYaml() []byte
ToYaml returns a YAML representation of a dependabot config.
func (*DependabotConfig) ToYamlKeepingQuotes ¶ added in v0.11.1
func (config *DependabotConfig) ToYamlKeepingQuotes(original []byte) []byte
ToYamlKeepingQuotes returns the config as YAML. Values quoted in original keep their quotes, so a rewrite does not fight the style a repository's formatter chose; other values that need quotes get double quotes.
func (*DependabotConfig) UpdateConfig ¶
func (config *DependabotConfig) UpdateConfig(manifests map[string]string, toolConfig ToolConfig, repoSettings RepoSettings, loadFileFn LoadFileContent, loadFileParams LoadFileContentParameters, checkDirectoryExists CheckDirectoryExists, checkDirectoryExistsParams CheckDirectoryExistsParameters, ) (ChangeInfo, error)
UpdateConfig updates a dependabot config with a list of manifests found and the tool's config.
type DirectoryGrouping ¶ added in v0.11.0
type DirectoryGrouping struct {
Default string `yaml:"default"`
Property string `yaml:"property,omitempty"`
}
DirectoryGrouping chooses between one update entry per ecosystem for all directories of a repository (global), whose groups then cover all directories, and one entry per directory (per-app).
func (*DirectoryGrouping) ModeFor ¶ added in v0.11.0
func (grouping *DirectoryGrouping) ModeFor(propertyValue string) string
ModeFor returns the mode of a repository: the value of its custom property if that is a mode, the default otherwise.
type Enforce ¶ added in v0.11.0
type Enforce struct {
Fields []string `yaml:"fields"`
ExceptionsFile string `yaml:"exceptions-file,omitempty"`
ReposFile string `yaml:"repos-file,omitempty"`
// contains filtered or unexported fields
}
Enforce lists the fields of existing update entries that get the values a new entry would get.
type EnforceException ¶ added in v0.11.0
type EnforceException struct {
Repo string `yaml:"repo"`
Fields []string `yaml:"fields"`
Reason string `yaml:"reason"`
Owner string `yaml:"owner"`
}
EnforceException lets a repository keep its own values for some fields.
type EnforcedUpdateInfo ¶ added in v0.11.0
EnforcedUpdateInfo holds the fields of an existing update that were set to the configured values, for the change message.
type Group ¶ added in v0.4.0
type Group struct {
DependencyType string `yaml:"dependency-type,omitempty"`
Patterns []string `yaml:"patterns,omitempty"`
ExcludePatterns []string `yaml:"exclude-patterns,omitempty"`
UpdateTypes []string `yaml:"update-types,omitempty"`
AppliesTo string `yaml:"applies-to,omitempty"`
GroupBy string `yaml:"group-by,omitempty"`
Unknown map[string]any `yaml:",inline"`
}
Group holds the config items of a group definition
type Groups ¶ added in v0.11.0
type Groups []NamedGroup
Groups holds the groups of an update in the order they are written. Dependabot puts a dependency in the first group it matches, so the order must survive a rewrite.
func (Groups) MarshalYAML ¶ added in v0.11.0
MarshalYAML writes the groups as a mapping in their order.
type Ignore ¶ added in v0.2.0
type Ignore struct {
DependencyName string `yaml:"dependency-name"`
Versions []string `yaml:"versions,omitempty"`
UpdateTypes []string `yaml:"update-types,omitempty"`
Unknown map[string]any `yaml:",inline"`
}
Ignore holds the config items of an ignore definition
type KeyValue ¶ added in v0.3.2
KeyValue holds a key/value pair of strings. Used as a sortable key/value map.
type LenientBool ¶ added in v0.10.1
type LenientBool bool
LenientBool is a boolean that is also read from a string, as dependabutler up to v0.10.0 wrote replaces-base: "true".
func (*LenientBool) UnmarshalYAML ¶ added in v0.10.1
func (value *LenientBool) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML reads a boolean or a string holding one.
type LoadFileContent ¶ added in v0.2.0
type LoadFileContent func(file string, params LoadFileContentParameters) string
LoadFileContent is a function type for loading the content of a file.
type LoadFileContentParameters ¶ added in v0.2.0
type LoadFileContentParameters struct {
Client RemoteClient
Org string
Repo string
Directory string
}
LoadFileContentParameters holds all parameters needed for the LoadFileContent function implementations.
type ManifestReport ¶ added in v0.10.0
type ManifestReport struct {
Path string `json:"path"`
Ecosystem string `json:"ecosystem"`
Covered bool `json:"covered"`
}
ManifestReport is a manifest file found in a repository, and whether an update entry covers it.
type NamedGroup ¶ added in v0.11.0
NamedGroup is a group and its name.
type PullRequestParameters ¶
type PullRequestParameters struct {
AuthorName string `yaml:"author-name"`
AuthorEmail string `yaml:"author-email"`
CommitMessage string `yaml:"commit-message"`
PRTitle string `yaml:"pr-title"`
BranchName string `yaml:"branch-name"`
BranchNameRandomSuffix bool `yaml:"branch-name-random-suffix"`
SleepAfterPRAction int `yaml:"sleep-after-pr-action"`
PRLabels []string `yaml:"pr-labels,omitempty"`
EnforceCommitMessage string `yaml:"enforce-commit-message,omitempty"`
EnforcePRTitle string `yaml:"enforce-pr-title,omitempty"`
EnforcePRNote string `yaml:"enforce-pr-note,omitempty"`
}
PullRequestParameters holds the parameters for PRs created by dependabutler
func (PullRequestParameters) ForEnforcement ¶ added in v0.11.0
func (params PullRequestParameters) ForEnforcement() PullRequestParameters
ForEnforcement returns the parameters of a PR that only enforces fields: the enforce title and commit message, if set.
type Registry ¶
type Registry struct {
Type string `yaml:"type"`
URL string `yaml:"url"`
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
Key string `yaml:"key,omitempty"`
Token string `yaml:"token,omitempty"`
ReplacesBase *LenientBool `yaml:"replaces-base,omitempty"`
Unknown map[string]any `yaml:",inline"`
}
Registry holds the config items of a registry definition
type RegistryInfo ¶
RegistryInfo holds the properties of a registry, for the change message.
type RemoteClient ¶ added in v0.9.5
type RemoteClient interface {
GetFileContent(org string, repo string, path string, branchName string) ([]byte, error)
CheckDirectoryExists(org string, repo string, directory string, branchName string) (bool, error)
}
RemoteClient is the GitHub API client used by the remote LoadFileContent and CheckDirectoryExists implementations. It is declared here, as the interface this package needs, so that this package does not have to import the package implementing it - which imports this one.
type RepoReport ¶ added in v0.10.0
type RepoReport struct {
Repo string `json:"repo"`
DefaultBranch string `json:"default_branch"`
DependabotYml bool `json:"dependabot_yml"`
TreeTruncated bool `json:"tree_truncated"`
Manifests []ManifestReport `json:"manifests"`
Updates []UpdateReport `json:"updates"`
}
RepoReport is the coverage report of a repository, as printed by report mode.
func NewRepoReport ¶ added in v0.10.0
func NewRepoReport(repo string, defaultBranch string, currentConfig []byte, files []string, treeTruncated bool) (RepoReport, error)
NewRepoReport builds the coverage report of a repository from its current dependabot.yml content (nil if the file does not exist) and its file list.
type RepoSettings ¶ added in v0.11.0
type RepoSettings struct {
SlotSchedule *Schedule
EnforcedFields []string
DirectoryGrouping string
}
RepoSettings holds the settings that depend on the repository being processed.
type Schedule ¶
type Schedule struct {
Interval string `yaml:"interval"`
Cronjob string `yaml:"cronjob,omitempty"`
Day string `yaml:"day,omitempty"`
Time string `yaml:"time,omitempty"`
Timezone string `yaml:"timezone,omitempty"`
Unknown map[string]any `yaml:",inline"`
}
Schedule holds the config items of a schedule
type ScheduleReport ¶ added in v0.10.0
type ScheduleReport struct {
Interval string `json:"interval"`
Cronjob string `json:"cronjob,omitempty"`
Day string `json:"day,omitempty"`
Time string `json:"time,omitempty"`
Timezone string `json:"timezone,omitempty"`
}
ScheduleReport is the schedule of an update entry.
type ScheduleSlots ¶ added in v0.11.0
type ScheduleSlots struct {
Salt string `yaml:"salt"`
Windows []SlotWindow `yaml:"windows"`
}
ScheduleSlots spreads the schedules of new update entries over fixed slots, derived from the repository name.
func (*ScheduleSlots) LoadReposFiles ¶ added in v0.11.0
func (slots *ScheduleSlots) LoadReposFiles(configDir string) error
LoadReposFiles reads the repos-file of every window, relative to the directory of the tool config.
func (*ScheduleSlots) NeedsRulesets ¶ added in v0.11.0
func (slots *ScheduleSlots) NeedsRulesets(repo string) bool
NeedsRulesets returns whether the rulesets of a repository can change its window: not when the repos-file of a window before the first ruleset window, or of that window itself, lists it. Reading them costs an API call, and a failed call skips the repository.
func (*ScheduleSlots) UnmarshalYAML ¶ added in v0.11.0
func (slots *ScheduleSlots) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML rejects unknown keys: a typo would otherwise be dropped without a word.
func (*ScheduleSlots) WindowFor ¶ added in v0.11.0
func (slots *ScheduleSlots) WindowFor(repo string, rulesets []string) SlotWindow
WindowFor returns the first window that one of the repository's rulesets or its repos-file selects, or the last window when none does. Repository names match regardless of case, as on GitHub.
type SkippedRepoReport ¶ added in v0.10.0
type SkippedRepoReport struct {
Repo string `json:"repo"`
Skipped string `json:"skipped,omitempty"`
Error string `json:"error,omitempty"`
}
SkippedRepoReport is printed by report mode instead of a RepoReport, if a repository was skipped or could not be read.
type SlotWindow ¶ added in v0.11.0
type SlotWindow struct {
Name string `yaml:"name"`
Hours []int `yaml:"hours"`
Days []string `yaml:"days,omitempty"`
RunsPerWeek int `yaml:"runs-per-week,omitempty"`
Timezone string `yaml:"timezone"`
Rulesets []string `yaml:"rulesets,omitempty"`
ReposFile string `yaml:"repos-file,omitempty"`
// contains filtered or unexported fields
}
SlotWindow is a set of hours a repository can be scheduled in, and which repositories use it. The last window has no rulesets and no repos-file, and holds every repository no other window matches.
func (SlotWindow) Runs ¶ added in v0.11.0
func (window SlotWindow) Runs() int
Runs returns how many times a week a repository in the window runs, twice unless runs-per-week is set.
func (SlotWindow) Schedule ¶ added in v0.11.0
func (window SlotWindow) Schedule(salt string, repo string) Schedule
Schedule returns the cron schedule of a repository in this window.
func (*SlotWindow) UnmarshalYAML ¶ added in v0.11.0
func (window *SlotWindow) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML rejects unknown keys: a typo like "ruleset" would otherwise put the repos the window selects in the last window.
func (SlotWindow) Weekdays ¶ added in v0.11.0
func (window SlotWindow) Weekdays() []string
Weekdays returns the days the window runs on, Monday to Friday unless days is set.
type ToolConfig ¶
type ToolConfig struct {
UpdateDefaults UpdateDefaults `yaml:"update-defaults"`
UpdateOverrides map[string]UpdateDefaults `yaml:"update-overrides"`
Registries map[string]DefaultRegistries `yaml:"registries"`
ManifestPatterns map[string]string `yaml:"manifest-patterns"`
ManifestIgnorePattern string `yaml:"manifest-ignore-pattern"`
PullRequestParameters PullRequestParameters `yaml:"pull-request-parameters"`
StableGroupPrefixes *bool `yaml:"stable-group-prefixes,omitempty"`
UpdateMissingCooldownSettings *bool `yaml:"update-missing-cooldown-settings,omitempty"`
ScheduleSlots *ScheduleSlots `yaml:"schedule-slots,omitempty"`
Enforce *Enforce `yaml:"enforce,omitempty"`
DirectoryGrouping *DirectoryGrouping `yaml:"directory-grouping,omitempty"`
}
ToolConfig holds the tool's configuration defined in config.yml
func ParseToolConfig ¶
func ParseToolConfig(fileContent []byte) (*ToolConfig, error)
ParseToolConfig parses the config file
func (*ToolConfig) InitializePatterns ¶ added in v0.5.0
func (config *ToolConfig) InitializePatterns()
InitializePatterns pre-compiles manifest file name patterns
func (*ToolConfig) Parse ¶
func (config *ToolConfig) Parse(data []byte) error
Parse parses the config.yml format
type Update ¶
type Update struct {
PackageEcosystem string `yaml:"package-ecosystem"`
Directory string `yaml:"directory,omitempty"`
Directories []string `yaml:"directories,omitempty"`
Schedule Schedule `yaml:"schedule,omitempty"`
Registries []string `yaml:"registries,omitempty"`
CommitMessage CommitMessage `yaml:"commit-message,omitempty"`
OpenPullRequestsLimit *int `yaml:"open-pull-requests-limit,omitempty"`
Assignees []string `yaml:"assignees,omitempty"`
Allow []Allow `yaml:"allow,omitempty"`
Ignore []Ignore `yaml:"ignore,omitempty"`
Groups Groups `yaml:"groups,omitempty"`
InsecureExternalCodeExecution string `yaml:"insecure-external-code-execution,omitempty"`
Labels []string `yaml:"labels,omitempty"`
Milestone int `yaml:"milestone,omitempty"`
PullRequestBranchName struct {
Separator string `yaml:"separator"`
Unknown map[string]any `yaml:",inline"`
} `yaml:"pull-request-branch-name,omitempty"`
RebaseStrategy string `yaml:"rebase-strategy,omitempty"`
Reviewers []string `yaml:"reviewers,omitempty"`
TargetBranch string `yaml:"target-branch,omitempty"`
Vendor bool `yaml:"vendor,omitempty"`
VersioningStrategy string `yaml:"versioning-strategy,omitempty"`
Cooldown Cooldown `yaml:"cooldown,omitempty"`
Unknown map[string]any `yaml:",inline"`
}
Update holds the config items of an update definition
type UpdateDefaults ¶
type UpdateDefaults struct {
Schedule Schedule `yaml:"schedule"`
CommitMessage CommitMessage `yaml:"commit-message"`
OpenPullRequestsLimit *int `yaml:"open-pull-requests-limit,omitempty"`
InsecureExternalCodeExecution string `yaml:"insecure-external-code-execution"`
RebaseStrategy string `yaml:"rebase-strategy"`
Cooldown Cooldown `yaml:"cooldown"`
Groups Groups `yaml:"groups,omitempty"`
}
UpdateDefaults holds the default config for new update definitions
type UpdateInfo ¶
UpdateInfo holds the properties of an update, for the change message.
type UpdateReport ¶ added in v0.10.0
type UpdateReport struct {
Ecosystem string `json:"ecosystem"`
Directory string `json:"directory,omitempty"`
Directories []string `json:"directories,omitempty"`
Schedule ScheduleReport `json:"schedule"`
}
UpdateReport is an update entry of a dependabot.yml file.