config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config contains functions related to config files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetManifestPath added in v0.3.0

func GetManifestPath(manifestFile string, manifestType string) string

GetManifestPath returns the path of the absolute path of a manifest file

func GetManifestType

func GetManifestType(fullPath string) string

GetManifestType returns the type of manifest file, if any.

func InitializePatterns

func InitializePatterns(patterns map[string]string)

InitializePatterns pre-compiles manifest file name patterns

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 ScanFileList

func ScanFileList(files []string, manifests map[string]string)

ScanFileList looks for manifest files, in a list of file names (incl. path)

func ScanLocalDirectory

func ScanLocalDirectory(baseDirectory string, directory string, manifests map[string]string)

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"`
}

Allow holds the config items of an allow definition

type ChangeInfo

type ChangeInfo struct {
	NewRegistries []RegistryInfo
	NewUpdates    []UpdateInfo
}

ChangeInfo holds the changes applied to a config.

type CommitMessage

type CommitMessage struct {
	Prefix            string `yaml:"prefix,omitempty"`
	PrefixDevelopment string `yaml:"prefix-development,omitempty"`
	Include           string `yaml:"include,omitempty"`
}

CommitMessage holds the config items for the commit message

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"`
}

DependabotConfig holds the configuration defined in dependabot.yml

func ParseDependabotConfig

func ParseDependabotConfig(fileContent []byte) (*DependabotConfig, error)

ParseDependabotConfig parses the config file

func (*DependabotConfig) AddManifest

func (config *DependabotConfig) AddManifest(manifestFile string, manifestType string, toolConfig ToolConfig,
	changeInfo *ChangeInfo, loadFileFn LoadFileContent, loadFileParams LoadFileContentParameters,
)

AddManifest adds config for a new manifest file to dependabot.yml

func (*DependabotConfig) IsManifestCovered

func (config *DependabotConfig) IsManifestCovered(manifestFile string, manifestType 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) ToYaml

func (config *DependabotConfig) ToYaml() []byte

ToYaml returns a YAML representation of a dependabot config.

func (*DependabotConfig) UpdateConfig

func (config *DependabotConfig) UpdateConfig(manifests map[string]string, toolConfig ToolConfig,
	loadFileFn LoadFileContent, loadFileParams LoadFileContentParameters,
) ChangeInfo

UpdateConfig updates a dependabot config with a list of manifests found and the tool's config.

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"`
}

Ignore holds the config items of an ignore definition

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 {
	GitHubClient *github.Client
	Org          string
	Repo         string
	Directory    string
}

LoadFileContentParameters holds all parameters needed for the LoadFileContent function implementations.

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"`
}

PullRequestParameters holds the parameters for PRs created by dependabutler

type Registry

type Registry struct {
	Type     string `yaml:"type"`
	URL      string `yaml:"url"`
	Username string `yaml:"username,omitempty"`
	Password string `yaml:"password,omitempty"`
}

Registry holds the config items of a registry definition

type RegistryInfo

type RegistryInfo struct {
	Type string
	Name string
}

RegistryInfo holds the properties of a registry, for the change message.

type Schedule

type Schedule struct {
	Interval string `yaml:"interval"`
	Day      string `yaml:"day,omitempty"`
	Time     string `yaml:"time,omitempty"`
	Timezone string `yaml:"timezone,omitempty"`
}

Schedule holds the config items of a schedule

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"`
	PullRequestParameters PullRequestParameters        `yaml:"pull-request-parameters"`
}

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) 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"`
	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"`
	InsecureExternalCodeExecution string        `yaml:"insecure-external-code-execution,omitempty"`
	Labels                        []string      `yaml:"labels,omitempty"`
	Milestone                     int           `yaml:"milestone,omitempty"`
	PullRequestBranchName         struct {
		Separator string `yaml:"separator"`
	} `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"`
}

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"`
	InsecureExternalCodeExecution string        `yaml:"insecure-external-code-execution"`
	RebaseStrategy                string        `yaml:"rebase-strategy"`
}

UpdateDefaults holds the default config for new update definitions

type UpdateInfo

type UpdateInfo struct {
	Type      string
	Directory string
	File      string
}

UpdateInfo holds the properties of an update, for the change message.

Jump to

Keyboard shortcuts

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