Documentation ¶
Index ¶
- func GetRepositoryNames(repos []*Repository) []string
- func RegisterListener(listener api.EventListener)
- type Bulk
- func (b *Bulk) AddRepositories(repos []*Repository, globalParams Params, commitMsg string, branch string)
- func (b *Bulk) AddRepository(repo *Repository, globalParams Params, mergeRequestDescr string, branch string)
- func (b *Bulk) Apply(repoName string, p *Patch, message string)
- func (b *Bulk) Close() error
- func (b *Bulk) Discard() error
- func (b *Bulk) ForEach(f func(ctx *PatchContext) error) error
- func (b *Bulk) Get(repoName string) *PatchContext
- func (b *Bulk) Len() int
- func (b *Bulk) PushAll()
- type Configuration
- func (cfg *Configuration) GetCurrentBulk() string
- func (cfg *Configuration) GetCurrentBulkDir() Directory
- func (cfg *Configuration) GetProviderApiHost() string
- func (cfg *Configuration) GetProviderHost() string
- func (cfg *Configuration) GetProviderToken() string
- func (cfg *Configuration) GetProviderType() string
- func (cfg *Configuration) GetProviderUser() string
- func (cfg *Configuration) SaveToYaml(file string) error
- func (cfg *Configuration) SetCurrentBulk(bulkID string) error
- func (cfg *Configuration) String() string
- type Directory
- func (d Directory) Clear()
- func (d Directory) File(name string) string
- func (d Directory) FindBySuffix(suffix string, found func(string))
- func (d Directory) IsEmpty() bool
- func (d Directory) IsNotExist() bool
- func (d Directory) IsNotSet() bool
- func (d Directory) Mkdir()
- func (d Directory) Remove()
- func (d Directory) String() string
- func (d Directory) Subdir(name string) Directory
- type Dispatcher
- type Inventory
- type NewBulkOpts
- type Params
- type Patch
- type PatchContext
- type PhaseType
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRepositoryNames ¶
func GetRepositoryNames(repos []*Repository) []string
func RegisterListener ¶
func RegisterListener(listener api.EventListener)
Types ¶
type Bulk ¶
type Bulk struct { ID string // contains filtered or unexported fields }
func NewBulk ¶
func NewBulk(cfg *Configuration) *Bulk
funcion create new empty bulk, folder of this bulk and set it as current.
func OpenBulk ¶
func OpenBulk(cfg *Configuration) (*Bulk, error)
func (*Bulk) AddRepositories ¶
func (b *Bulk) AddRepositories(repos []*Repository, globalParams Params, commitMsg string, branch string)
func (*Bulk) AddRepository ¶
func (b *Bulk) AddRepository(repo *Repository, globalParams Params, mergeRequestDescr string, branch string)
func (*Bulk) Discard ¶
Discarding the Bulk. That means:
- delete bulk dir content
- delette branches if they're created
func (*Bulk) ForEach ¶
func (b *Bulk) ForEach(f func(ctx *PatchContext) error) error
ForEach iterate over contexts and call f function for every context. If f returns some error (not null), the iteration immediately stop and forward this error to you
func (*Bulk) Get ¶
func (b *Bulk) Get(repoName string) *PatchContext
type Configuration ¶
type Configuration struct { // path to workspace where are repositories cloned. Default is {currentdir}/.excav WorkspaceDir string `yaml:"workspace"` // The GitLab host (e.g. https://gitlab.com) GitLabHost string `yaml:"gitlab"` // Private access token which is generated by GitLab. // see https://gitlab.com/profile/personal_access_tokens GitLabToken string `yaml:"gitlab_token"` // The GitHub host (e.g. https://github.com) GitHubHost string `yaml:"github"` // The GitHub API host (e.g. https://api.github.com). Usually API is available in // different hostname starting with api.* GitHubApiHost string `yaml:"github_api"` // User for GitHub GitHubUser string `yaml:"github_user"` // Personal access token which is generated by GitHub // see https://github.com/settings/tokens GitHubToken string `yaml:"github_token"` }
Configuration is loaded from ~/.config/excav/config.yaml file
func LoadConfiguration ¶
func LoadConfiguration() (*Configuration, error)
Default loading of configuration. The order of loading is:
- first we try load config.yaml in current working directory - then try load config.yaml from `{USER_HOME}/.config/excav/config.yaml' - (not implemented) load from env. variables (TODO)
func ReadYamlConfig ¶
func ReadYamlConfig(configFile string) (*Configuration, error)
func TestConfiguration ¶
func TestConfiguration() (*Configuration, error)
create configuration used by tests. This configuration relly on tetmporary workspace;
func (*Configuration) GetCurrentBulk ¶
func (cfg *Configuration) GetCurrentBulk() string
function returns you ID of current bulk The current bulk is written in ${WORKSPACE}/currert file
func (*Configuration) GetCurrentBulkDir ¶
func (cfg *Configuration) GetCurrentBulkDir() Directory
function returns you directory of current bulk
func (*Configuration) GetProviderApiHost ¶
func (cfg *Configuration) GetProviderApiHost() string
func (*Configuration) GetProviderHost ¶
func (cfg *Configuration) GetProviderHost() string
func (*Configuration) GetProviderToken ¶
func (cfg *Configuration) GetProviderToken() string
func (*Configuration) GetProviderType ¶
func (cfg *Configuration) GetProviderType() string
func (*Configuration) GetProviderUser ¶ added in v0.4.0
func (cfg *Configuration) GetProviderUser() string
func (*Configuration) SaveToYaml ¶
func (cfg *Configuration) SaveToYaml(file string) error
SaveToYaml save the config into given file. If file exists, it will be overridden. Ensure the parent directories exists, otherwise saving fail.
func (*Configuration) SetCurrentBulk ¶
func (cfg *Configuration) SetCurrentBulk(bulkID string) error
function set defaul bulk. That means exav will work with this bulk by default.
The bulk ID is written into {WORKSPACE}/current file.
func (*Configuration) String ¶
func (cfg *Configuration) String() string
type Directory ¶
type Directory string
Directory represents path to directory and provide basic operations for directories
func CurrentDirectory ¶
func CurrentDirectory() Directory
func TempDirectory ¶
func TempDirectory() Directory
func (Directory) Clear ¶
func (d Directory) Clear()
The function removes all content but directory stay untouched. This function is bit different as Remove
func (Directory) File ¶
returns absolute path to file in directory. The file may not exist, it's just join of names
func (Directory) FindBySuffix ¶
FindBySuffix go through directory and call 'found' function for every file that suffix is matching.
Any low-level error is ignored and function continue without breaking.
func (Directory) IsNotExist ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher is responsible for delivery events to registered listeners. The code is sending events via Notify and reacting on events by implementing EventListener.
type Inventory ¶
type Inventory struct { // don't use this attribute directly. It's public only because HCL parsing XRepositories []*Repository `yaml:"repositories"` }
func OpenInventory ¶
OpenInventory load the inventory YAML file. If file is empty string, the default value will be used which is '{currentdir}/inventory.yaml'.
Example of the file is in testdata/inventory.yaml
func (*Inventory) Get ¶
func (inv *Inventory) Get(repoName string) *Repository
GetByPath returns repo or null
func (*Inventory) GetAll ¶
func (inv *Inventory) GetAll() []*Repository
func (*Inventory) GetByTags ¶
func (inv *Inventory) GetByTags(tags ...string) []*Repository
GetByTags returns you list of filtered repositories they're matching given tag or all given tags. If tags is empty, the function returns all tags
type NewBulkOpts ¶
type NewBulkOpts struct { Repos []*Repository Branch string Description string GlobalParams Params }
type Params ¶
parameters they're passed into every task. They're used for parametrized tasks like 'append-template' etc. The parameters can be defined as arguments during apply (see excav apply --h)
func MergeParams ¶
merges multiple parameter collections into one. If the parameter is obtained in multiple collections, the value of last collection in function is used. Collections have priorrity from lowest to high.
func StringSliceToParams ¶
ParamsAsStringSlice consume parameters as array of 'KEY=VALUE' strings and parse it to Params structure - which is map btw. The 'KEY=VALUE' is used mainly for parameters given as cli argument.
type Patch ¶
type Patch struct { Params Params Tasks map[string]api.Task Metadata map[string]*api.TaskMetadata // contains filtered or unexported fields }
Patch contains one or more tasks they're applied to some directory.
type PatchContext ¶
type PatchContext struct { RepoName string `yaml:"repo_name"` // from which branch is new branch for patch created, by default it's 'main' DefaultBranch string `yaml:"default_branch"` // this is a created branch (from default) where is patch applied Branch string `yaml:"branch"` Phase PhaseType `yaml:"phase"` // Description is provided by user fist time, when bulk is created // (see CreateNew) Description string `yaml:"descr"` // This field is populated after changes are pushed (see bulk Push()) MergeRequestURL string `yaml:"merge_request"` // This field indicates error state. You can check the state // via IsError func. ErrorMsg string `yaml:"error_msg"` // This field holds all parameters and values for patch AllParams Params `yaml:"params"` // contains filtered or unexported fields }
PatchContext hold the repository and metadata related to current patching. When Bulk represent the group of repositories you apply patch, the PatchContext represent one repository you're currently patching
func (*PatchContext) Apply ¶
func (ctx *PatchContext) Apply(p *Patch, message string) error
apply the given p to repository and commit the changes.
func (*PatchContext) Diff ¶
func (ctx *PatchContext) Diff() string
func (*PatchContext) IsError ¶
func (ctx *PatchContext) IsError() bool
func (*PatchContext) Push ¶
func (ctx *PatchContext) Push() error
type Repository ¶
type Repository struct { // Path of repository is in GitLab `/fodler/folder/repo` or in GitLab `/org/repo` Name string `yaml:"repository"` // not every repository have 'main' as default branch. Some legacy repos // might have 'master' as default branch DefaultBranch string `yaml:"default_branch"` // tags help you identify and select list of // repositories Tags []string `yaml:"tags,flow"` // repository might have some parameters they are // passed into templates RepoParams Params `yaml:"params,omitempty"` }
func (*Repository) GetName ¶
func (r *Repository) GetName() string
get the trimmed name ready to use. We're not using direct access, because Name might have weird characters
func (*Repository) HasTag ¶
func (repo *Repository) HasTag(tag string) bool
func (*Repository) HasTags ¶
func (repo *Repository) HasTags(tags ...string) bool