Documentation ¶
Overview ¶
Package plasmactlbump implements a launchr plugin with bump functionality
Index ¶
- func GetDiffFiles(dirA, dirB string) ([]string, error)
- func PromptError(err error)
- type ArtifactStorage
- type BumpAction
- type BumperRepo
- type Inventory
- func (i *Inventory) GetChangedResources(modifiedFiles []string) *OrderedResourceMap
- func (i *Inventory) GetChangedVarsResources(modifiedFiles []string) (*OrderedResourceMap, map[string]map[string]bool, error)
- func (i *Inventory) GetDependenciesMap() map[string]map[string]bool
- func (i *Inventory) GetRequiredMap() map[string]map[string]bool
- func (i *Inventory) GetResourcesOrder() []string
- func (i *Inventory) Init() error
- type OrderedResourceMap
- type Plugin
- type Resource
- type ResourcesCrawler
- func (cr *ResourcesCrawler) FindDefaultFiles(platform string) []string
- func (cr *ResourcesCrawler) FindGroupVarsFiles(platform string) []string
- func (cr *ResourcesCrawler) FindTaskFiles(platform string) []string
- func (cr *ResourcesCrawler) FindTemplateFiles(platform string) []string
- func (cr *ResourcesCrawler) SearchVariableResources(platform string, names map[string]*Variable, ...) error
- func (cr *ResourcesCrawler) SearchVariablesInGroupFiles(name string, files []string) ([]*Variable, error)
- type SyncAction
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDiffFiles ¶ added in v1.2.0
GetDiffFiles takes two directory paths as inputs and returns a slice of updated file paths and an error. It compares the files in the two directories (excluding subdirectories specified in the excludeSubDirs variable) and checks if they are equal. If a file is modified, its path is added to the updated slice.
Types ¶
type ArtifactStorage ¶ added in v1.2.0
type ArtifactStorage struct {
// contains filtered or unexported fields
}
ArtifactStorage represents a storage for artifacts.
func (*ArtifactStorage) PrepareComparisonArtifact ¶ added in v1.2.0
func (s *ArtifactStorage) PrepareComparisonArtifact(comparisonDir string) error
PrepareComparisonArtifact prepares the artifact for comparison by downloading and extracting it into the specified directory.
type BumpAction ¶
BumpAction is a launchr.Service providing bumper functionality.
type BumperRepo ¶
type BumperRepo struct {
// contains filtered or unexported fields
}
BumperRepo encapsulates Git-related operations for bumping versions in a Git repository.
func (*BumperRepo) Commit ¶
func (r *BumperRepo) Commit() error
Commit stores the current changes to the Git repository with the default commit message and author.
func (*BumperRepo) GetComparisonCommit ¶ added in v1.7.0
func (r *BumperRepo) GetComparisonCommit(from plumbing.Hash, searchMessage string) (*plumbing.Hash, error)
GetComparisonCommit returns the commit that contains the specified search message.
func (*BumperRepo) GetLastCommitShortHash ¶
func (r *BumperRepo) GetLastCommitShortHash() (string, error)
GetLastCommitShortHash gets the short hash of the latest commit in the Git repository.
func (*BumperRepo) GetRepoName ¶ added in v1.2.0
func (r *BumperRepo) GetRepoName() (string, error)
GetRepoName retrieves the name of the remote repository. It looks for the remote named "origin" and extracts the repository name from the remote's URL. It returns the repository name as a string and an error if the remote is not found or the repository name cannot be extracted.
func (*BumperRepo) IsOwnCommit ¶
func (r *BumperRepo) IsOwnCommit() bool
IsOwnCommit checks if the latest commit in the Git repository was made by the bumper.
type Inventory ¶ added in v1.2.0
type Inventory struct { ResourcesCrawler *ResourcesCrawler // contains filtered or unexported fields }
Inventory represents the inventory used in the application to search and collect resources and variable resources.
func NewInventory ¶ added in v1.2.0
NewInventory creates a new instance of Inventory with the provided vault password. It then calls the Init method of the Inventory to build the resources graph and returns the initialized Inventory or any error that occurred during initialization.
func (*Inventory) GetChangedResources ¶ added in v1.2.0
func (i *Inventory) GetChangedResources(modifiedFiles []string) *OrderedResourceMap
GetChangedResources returns an OrderedResourceMap containing the resources that have been modified, based on the provided list of modified files. It iterates over the modified files, builds a resource from each file path, and adds it to the result map if it is not already present.
func (*Inventory) GetChangedVarsResources ¶ added in v1.2.0
func (i *Inventory) GetChangedVarsResources(modifiedFiles []string) (*OrderedResourceMap, map[string]map[string]bool, error)
GetChangedVarsResources returns the resources and variable maps associated with the changed variables in the modified files. It takes a slice of modified file paths as input. It returns the resources as an OrderedResourceMap and the variable maps as a map[string]map[string]bool. If there are no changed variables, it returns nil for both the resources and variable maps.
func (*Inventory) GetDependenciesMap ¶ added in v1.4.0
GetDependenciesMap returns the map, which represents the dependencies between resources in the Inventory. The map is of type `map[string]map[string]bool`, where the keys are the resource names and the values are maps of dependent resource names.
func (*Inventory) GetRequiredMap ¶ added in v1.2.0
GetRequiredMap returns the required map, which represents the dependencies between resources in the Inventory. The map is of type `map[string]map[string]bool`, where the keys are the resource names and the values are maps of dependent resource names.
func (*Inventory) GetResourcesOrder ¶ added in v1.2.0
GetResourcesOrder returns the order of resources in the inventory. It returns a slice of strings representing the order of the resources.
type OrderedResourceMap ¶ added in v1.2.0
type OrderedResourceMap struct {
// contains filtered or unexported fields
}
OrderedResourceMap represents a map of resources with ordered keys
type OrderedResourceMap struct { keys []string dict map[string]*Resource }
The `keys` field is a slice of strings that represents the order of the keys in the map. The `dict` field is a map where the key is a string and the value is a pointer to a Resource object.
func NewOrderedResourceMap ¶ added in v1.2.0
func NewOrderedResourceMap() *OrderedResourceMap
NewOrderedResourceMap returns a new instance of OrderedResourceMap with an empty dictionary.
func (*OrderedResourceMap) Get ¶ added in v1.2.0
func (orm *OrderedResourceMap) Get(key string) (*Resource, bool)
Get a value from the OrderedResourceMap.
func (*OrderedResourceMap) Len ¶ added in v1.2.0
func (orm *OrderedResourceMap) Len() int
Len returns the length of the OrderedResourceMap.
func (*OrderedResourceMap) OrderBy ¶ added in v1.2.0
func (orm *OrderedResourceMap) OrderBy(orderList []string)
OrderBy updates the order of keys in the OrderedResourceMap based on the orderList. It removes any keys in orderList that are not present in the OrderedResourceMap. The keys are reordered in the OrderedResourceMap according to the order of appearance in orderList. The order of keys not present in orderList remains unchanged.
func (*OrderedResourceMap) OrderedKeys ¶ added in v1.2.0
func (orm *OrderedResourceMap) OrderedKeys() []string
OrderedKeys returns the ordered keys from the OrderedResourceMap.
func (*OrderedResourceMap) Set ¶ added in v1.2.0
func (orm *OrderedResourceMap) Set(key string, value *Resource)
Set a value in the OrderedResourceMap.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin is launchr plugin providing bump action.
func (*Plugin) CobraAddCommands ¶
CobraAddCommands implements launchr.CobraPlugin interface to provide bump functionality.
func (*Plugin) PluginInfo ¶
func (p *Plugin) PluginInfo() launchr.PluginInfo
PluginInfo implements launchr.Plugin interface.
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource represents a platform resource
func BuildResourceFromPath ¶ added in v1.4.0
BuildResourceFromPath builds a new instance of Resource from the given path.
func (*Resource) GetVersion ¶
GetVersion retrieves the version of the resource from the plasma.yaml
func (*Resource) UpdateVersion ¶
UpdateVersion updates the version of the resource in the plasma.yaml file
type ResourcesCrawler ¶ added in v1.2.0
type ResourcesCrawler struct {
// contains filtered or unexported fields
}
ResourcesCrawler is a type that represents a crawler for resources in a given directory.
func NewResourcesCrawler ¶ added in v1.2.0
func NewResourcesCrawler(directory string) *ResourcesCrawler
NewResourcesCrawler creates a new instance of ResourcesCrawler with initialized taskSources and templateSources maps.
func (*ResourcesCrawler) FindDefaultFiles ¶ added in v1.6.0
func (cr *ResourcesCrawler) FindDefaultFiles(platform string) []string
FindDefaultFiles returns a slice of file paths that match certain criteria for defaults on a specific platform.
func (*ResourcesCrawler) FindGroupVarsFiles ¶ added in v1.2.0
func (cr *ResourcesCrawler) FindGroupVarsFiles(platform string) []string
FindGroupVarsFiles returns a slice of file paths that match certain criteria for group vars on a specific platform.
func (*ResourcesCrawler) FindTaskFiles ¶ added in v1.2.0
func (cr *ResourcesCrawler) FindTaskFiles(platform string) []string
FindTaskFiles returns a slice of file paths that match certain criteria for tasks on a specific platform.
func (*ResourcesCrawler) FindTemplateFiles ¶ added in v1.2.0
func (cr *ResourcesCrawler) FindTemplateFiles(platform string) []string
FindTemplateFiles returns a slice of file paths that match certain criteria for templates on a specific platform.
func (*ResourcesCrawler) SearchVariableResources ¶ added in v1.2.0
func (cr *ResourcesCrawler) SearchVariableResources(platform string, names map[string]*Variable, resources map[string]map[string]bool) error
SearchVariableResources searches for variable resources on a specific platform using the provided names and resources map. If the platform is rootPlatform, an empty string is used as the search platform. It retrieves task and template files for the platform if they are not already stored in the taskSources and templateSources maps of the ResourcesCrawler. It scans each file and checks if the variables in the names map are present in the resources map for that file. If a variable is missing, it adds it to the toIterate slice. It then scans each line of the file and checks if it contains any of the variables in the toIterate slice. If a variable is found, it adds it to the foundList map. After scanning all the files, it updates the resources map with the variables found in each file.
func (*ResourcesCrawler) SearchVariablesInGroupFiles ¶ added in v1.2.0
func (cr *ResourcesCrawler) SearchVariablesInGroupFiles(name string, files []string) ([]*Variable, error)
SearchVariablesInGroupFiles searches for variables in a group of files that match the specified name. It takes a name string and a slice of files. It returns a slice of Variable pointers that contain information about each found variable. The function iterates over each file in the files slice, read it and if the string representation of the value contains the specified name, it creates a Variable object and appends it to the variables slice. Finally, it returns the variables slice. Example usage:
crawler := &ResourcesCrawler{} files := crawler.FindGroupVarsFiles("platform") variables := crawler.SearchVariablesInGroupFiles("variable", files)
type SyncAction ¶ added in v1.2.0
type SyncAction struct {
// contains filtered or unexported fields
}
SyncAction is a type representing a resources version synchronization action.
func (*SyncAction) Execute ¶ added in v1.2.0
func (s *SyncAction) Execute(username, password, override, vaultpass string) error
Execute executes the sync action by following these steps: - Calls the prepareArtifact method to prepare the comparison artifact. - Calls the GetDiffFiles function to get the modified files. - Prints the modified files. - Calls the propagate method to propagate resources' versions. - Returns any error that occurs during the execution of the sync action.