Documentation
¶
Overview ¶
Package sync contains tools to provide bump propagation.
Index ¶
- Constants
- Variables
- func ConvertMRNtoPath(mrn string) (string, error)
- func GatherDependentKeys(vd *VariableDependency, result map[string]map[string]bool)
- func GetMetaVersion(meta map[string]any) string
- func IsUpdatableKind(kind string) bool
- func IsVaultFile(path string) bool
- func LoadVariablesFile(path, vaultPassword string, isVault bool) (map[string]any, []string, error)
- func LoadVariablesFileFromBytes(input []byte, path string, vaultPassword string, isVault bool) (map[string]any, []string, error)
- func LoadYamlFileFromBytes(input []byte) (map[string]any, error)
- func PrepareMachineResourceName(platform, kind, role string) string
- func ProcessResourcePath(path string) (string, string, string, error)
- func SortTimeline(list []TimelineItem, order string)
- func UnmarshallFixDuplicates(data []byte) (map[string]any, map[string]bool, []string, error)
- type FilesCrawler
- type Inventory
- func (i *Inventory) CalculateResourcesUsage() error
- func (i *Inventory) CalculateVariablesUsage(vaultpass string) error
- func (i *Inventory) GetDependsOnMap() map[string]*OrderedMap[bool]
- func (i *Inventory) GetDependsOnResources(resourceName string, depth int8) map[string]bool
- func (i *Inventory) GetRequiredByMap() map[string]*OrderedMap[bool]
- func (i *Inventory) GetRequiredByResources(resourceName string, depth int8) map[string]bool
- func (i *Inventory) GetResourcesMap() *OrderedMap[*Resource]
- func (i *Inventory) GetResourcesOrder() []string
- func (i *Inventory) GetUsedResources() map[string]bool
- func (i *Inventory) GetVariableResources(variableName, variablePlatform string) []string
- func (i *Inventory) Init() error
- func (i *Inventory) IsUsedVariable(checkResourcesUsage bool, variableName, variablePlatform string) bool
- type MultiPrinter
- func (p MultiPrinter) GenericStart() (*pterm.LivePrinter, error)
- func (p MultiPrinter) GenericStop() (*pterm.LivePrinter, error)
- func (p *MultiPrinter) NewWriter() io.Writer
- func (p *MultiPrinter) SetWriter(writer io.Writer)
- func (p *MultiPrinter) Start() (*MultiPrinter, error)
- func (p *MultiPrinter) Stop() (*MultiPrinter, error)
- func (p MultiPrinter) WithUpdateDelay(delay time.Duration) *MultiPrinter
- func (p MultiPrinter) WithWriter(writer io.Writer) *MultiPrinter
- type OrderedMap
- func (m *OrderedMap[T]) Get(key string) (T, bool)
- func (m *OrderedMap[T]) Keys() []string
- func (m *OrderedMap[T]) Len() int
- func (m *OrderedMap[T]) OrderBy(orderList []string)
- func (m *OrderedMap[T]) Set(key string, value T)
- func (m *OrderedMap[T]) SortKeysAlphabetically()
- func (m *OrderedMap[T]) ToDict() map[string]T
- func (m *OrderedMap[T]) ToList() []T
- func (m *OrderedMap[T]) Unset(key string)
- type Resource
- func (r *Resource) BuildMetaPath() string
- func (r *Resource) GetBaseVersion() (string, string, []string, error)
- func (r *Resource) GetKind() string
- func (r *Resource) GetName() string
- func (r *Resource) GetPlatform() string
- func (r *Resource) GetRole() string
- func (r *Resource) GetVersion() (string, []string, error)
- func (r *Resource) IsValidResource() bool
- func (r *Resource) UpdateVersion(version string) ([]string, error)
- type TimelineItem
- type TimelineResourcesItem
- func (i *TimelineResourcesItem) AddResource(r *Resource)
- func (i *TimelineResourcesItem) GetCommit() string
- func (i *TimelineResourcesItem) GetDate() time.Time
- func (i *TimelineResourcesItem) GetResources() *OrderedMap[*Resource]
- func (i *TimelineResourcesItem) GetVersion() string
- func (i *TimelineResourcesItem) Merge(item TimelineItem)
- func (i *TimelineResourcesItem) Print()
- type TimelineVariablesItem
- func (i *TimelineVariablesItem) AddVariable(v *Variable)
- func (i *TimelineVariablesItem) GetCommit() string
- func (i *TimelineVariablesItem) GetDate() time.Time
- func (i *TimelineVariablesItem) GetVariables() *OrderedMap[*Variable]
- func (i *TimelineVariablesItem) GetVersion() string
- func (i *TimelineVariablesItem) Merge(item TimelineItem)
- func (i *TimelineVariablesItem) Print()
- type Variable
- type VariableDependency
Constants ¶
const ( // SortAsc const. SortAsc = "asc" // SortDesc const. SortDesc = "desc" )
Variables ¶
var InventoryExcluded = []string{
".git",
".plasma",
".plasmactl",
".gitlab-ci.yml",
"ansible_collections",
"scripts/ci/.gitlab-ci.platform.yaml",
"venv",
"__pycache__",
}
InventoryExcluded is list of excluded files and folders from inventory.
var Kinds = map[string]struct{}{
"applications": {},
"services": {},
"softwares": {},
"executors": {},
"flows": {},
"skills": {},
"functions": {},
"libraries": {},
"entities": {},
}
Kinds are list of resources kinds which version can be propagated.
Functions ¶
func ConvertMRNtoPath ¶
ConvertMRNtoPath transforms machine resource name to templated path to resource.
func GatherDependentKeys ¶
func GatherDependentKeys(vd *VariableDependency, result map[string]map[string]bool)
GatherDependentKeys recursively gathers dependent keys and stores them in the result map.
func GetMetaVersion ¶
GetMetaVersion searches for version in meta data.
func IsUpdatableKind ¶
IsUpdatableKind checks if resource kind is in Kinds range.
func IsVaultFile ¶
IsVaultFile is helper to determine if file is vault file.
func LoadVariablesFile ¶
LoadVariablesFile loads vars yaml file from path.
func LoadVariablesFileFromBytes ¶
func LoadVariablesFileFromBytes(input []byte, path string, vaultPassword string, isVault bool) (map[string]any, []string, error)
LoadVariablesFileFromBytes loads vars yaml file from bytes input.
func LoadYamlFileFromBytes ¶
LoadYamlFileFromBytes loads yaml file from bytes input.
func PrepareMachineResourceName ¶
PrepareMachineResourceName concatenates resource platform, kind and role via specific template. It allows to have common resource names.
func ProcessResourcePath ¶
ProcessResourcePath splits resource path onto platform, kind and role.
func SortTimeline ¶
func SortTimeline(list []TimelineItem, order string)
SortTimeline sorts timeline items in slice.
Types ¶
type FilesCrawler ¶
type FilesCrawler struct {
// contains filtered or unexported fields
}
FilesCrawler is a type that represents a crawler for resources in a given directory.
func NewFilesCrawler ¶
func NewFilesCrawler(directory string) *FilesCrawler
NewFilesCrawler creates a new instance of FilesCrawler with initialized taskSources and templateSources maps.
func (*FilesCrawler) FindResourcesFiles ¶
func (cr *FilesCrawler) FindResourcesFiles(platform string) (map[string][]string, error)
FindResourcesFiles return list of resources files in platform. If platform is empty, search across all.
func (*FilesCrawler) FindVarsFiles ¶
func (cr *FilesCrawler) FindVarsFiles(platform string) (map[string][]string, error)
FindVarsFiles return list of variables files in platform. If platform is empty, search across all.
type Inventory ¶
type Inventory struct {
// contains filtered or unexported fields
}
Inventory represents the inventory used in the application to search and collect resources and variable resources.
func NewInventory ¶
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) CalculateResourcesUsage ¶
CalculateResourcesUsage parse platform playbooks and determine resources used in platform.
func (*Inventory) CalculateVariablesUsage ¶
CalculateVariablesUsage precalculates all variables dependencies across platform.
func (*Inventory) GetDependsOnMap ¶
func (i *Inventory) GetDependsOnMap() map[string]*OrderedMap[bool]
GetDependsOnMap returns the map, which represents the 'depends on' dependencies between resources in the Inventory.
func (*Inventory) GetDependsOnResources ¶
GetDependsOnResources returns list of resources which are used by argument resource (directly or not).
func (*Inventory) GetRequiredByMap ¶
func (i *Inventory) GetRequiredByMap() map[string]*OrderedMap[bool]
GetRequiredByMap returns the required by map, which represents the `required by` dependencies between resources in the Inventory.
func (*Inventory) GetRequiredByResources ¶
GetRequiredByResources returns list of resources which depend on argument resource (directly or not).
func (*Inventory) GetResourcesMap ¶
func (i *Inventory) GetResourcesMap() *OrderedMap[*Resource]
GetResourcesMap returns map of all resources found in source dir.
func (*Inventory) GetResourcesOrder ¶
GetResourcesOrder returns the order of resources in the inventory.
func (*Inventory) GetUsedResources ¶
GetUsedResources returns list of used resources.
func (*Inventory) GetVariableResources ¶
GetVariableResources returns list of resources which depends on variable.
type MultiPrinter ¶
type MultiPrinter struct {
IsActive bool
Writer io.Writer
UpdateDelay time.Duration
// contains filtered or unexported fields
}
MultiPrinter overrides pterm.MultiPrinter to properly set area writer. @todo remove when it will be fixed in pterm.
func NewMultiPrinter ¶
func NewMultiPrinter(areaWriter *launchr.Out) *MultiPrinter
NewMultiPrinter creates and initializes a new MultiPrinter instance with the provided output writer.
func (MultiPrinter) GenericStart ¶
func (p MultiPrinter) GenericStart() (*pterm.LivePrinter, error)
GenericStart runs Start, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Start instead of this in your program.
func (MultiPrinter) GenericStop ¶
func (p MultiPrinter) GenericStop() (*pterm.LivePrinter, error)
GenericStop runs Stop, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Stop instead of this in your program.
func (*MultiPrinter) NewWriter ¶
func (p *MultiPrinter) NewWriter() io.Writer
NewWriter creates new multiWriter buffer.
func (*MultiPrinter) SetWriter ¶
func (p *MultiPrinter) SetWriter(writer io.Writer)
SetWriter sets the writer for the AreaPrinter.
func (*MultiPrinter) Start ¶
func (p *MultiPrinter) Start() (*MultiPrinter, error)
Start activates the MultiPrinter, initializes printers, and schedules periodic updates for the area content.
func (*MultiPrinter) Stop ¶
func (p *MultiPrinter) Stop() (*MultiPrinter, error)
Stop deactivates the MultiPrinter, stops all associated printers, updates the area content, and terminates the area.
func (MultiPrinter) WithUpdateDelay ¶
func (p MultiPrinter) WithUpdateDelay(delay time.Duration) *MultiPrinter
WithUpdateDelay returns a fork of the MultiPrinter with a new update delay.
func (MultiPrinter) WithWriter ¶
func (p MultiPrinter) WithWriter(writer io.Writer) *MultiPrinter
WithWriter returns a fork of the MultiPrinter with a new writer.
type OrderedMap ¶
type OrderedMap[T any] struct { // contains filtered or unexported fields }
OrderedMap represents generic struct with map and order keys.
func NewOrderedMap ¶
func NewOrderedMap[T any]() *OrderedMap[T]
NewOrderedMap returns a new instance of OrderedMap.
func (*OrderedMap[T]) Get ¶
func (m *OrderedMap[T]) Get(key string) (T, bool)
Get a value from the OrderedMap.
func (*OrderedMap[T]) Keys ¶
func (m *OrderedMap[T]) Keys() []string
Keys returns the ordered keys from the OrderedMap.
func (*OrderedMap[T]) Len ¶
func (m *OrderedMap[T]) Len() int
Len returns the length of the OrderedMap.
func (*OrderedMap[T]) OrderBy ¶
func (m *OrderedMap[T]) OrderBy(orderList []string)
OrderBy updates the order of keys in the OrderedMap based on the orderList.
func (*OrderedMap[T]) Set ¶
func (m *OrderedMap[T]) Set(key string, value T)
Set a value in the OrderedMap.
func (*OrderedMap[T]) SortKeysAlphabetically ¶
func (m *OrderedMap[T]) SortKeysAlphabetically()
SortKeysAlphabetically sorts internal keys alphabetically.
func (*OrderedMap[T]) ToDict ¶
func (m *OrderedMap[T]) ToDict() map[string]T
ToDict returns copy of OrderedMap dictionary.
func (*OrderedMap[T]) ToList ¶
func (m *OrderedMap[T]) ToList() []T
ToList converts map to ordered list OrderedMap.
func (*OrderedMap[T]) Unset ¶
func (m *OrderedMap[T]) Unset(key string)
Unset a value from the OrderedMap.
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource represents a platform resource
func BuildResourceFromPath ¶
BuildResourceFromPath builds a new instance of Resource from the given path.
func NewResource ¶
NewResource returns new Resource instance.
func (*Resource) BuildMetaPath ¶
BuildMetaPath returns common path to resource meta.
func (*Resource) GetBaseVersion ¶
GetBaseVersion returns resource version without `-` if any.
func (*Resource) GetPlatform ¶
GetPlatform returns a resource platform.
func (*Resource) GetVersion ¶
GetVersion retrieves the version of the resource from the plasma.yaml
func (*Resource) IsValidResource ¶
IsValidResource checks if resource has meta file.
type TimelineItem ¶
type TimelineItem interface {
GetCommit() string
GetVersion() string
GetDate() time.Time
Merge(item TimelineItem)
Print()
}
TimelineItem is interface for storing commit, date and version of propagated items. Storing such items in slice allows us to propagate items in the same order they were changed.
func AddToTimeline ¶
func AddToTimeline(list []TimelineItem, item TimelineItem) []TimelineItem
AddToTimeline inserts items into timeline slice.
func CreateTimeline ¶
func CreateTimeline() []TimelineItem
CreateTimeline returns fresh timeline slice.
type TimelineResourcesItem ¶
type TimelineResourcesItem struct {
// contains filtered or unexported fields
}
TimelineResourcesItem implements TimelineItem interface and stores Resource map.
func NewTimelineResourcesItem ¶
func NewTimelineResourcesItem(version, commit string, date time.Time, printer *launchr.Terminal) *TimelineResourcesItem
NewTimelineResourcesItem returns new instance of TimelineResourcesItem
func (*TimelineResourcesItem) AddResource ¶
func (i *TimelineResourcesItem) AddResource(r *Resource)
AddResource pushes Resource into timeline item.
func (*TimelineResourcesItem) GetCommit ¶
func (i *TimelineResourcesItem) GetCommit() string
GetCommit returns timeline item commit.
func (*TimelineResourcesItem) GetDate ¶
func (i *TimelineResourcesItem) GetDate() time.Time
GetDate returns timeline item date.
func (*TimelineResourcesItem) GetResources ¶
func (i *TimelineResourcesItem) GetResources() *OrderedMap[*Resource]
GetResources returns Resource map of timeline.
func (*TimelineResourcesItem) GetVersion ¶
func (i *TimelineResourcesItem) GetVersion() string
GetVersion returns timeline item version to propagate.
func (*TimelineResourcesItem) Merge ¶
func (i *TimelineResourcesItem) Merge(item TimelineItem)
Merge allows to merge other timeline item resources.
func (*TimelineResourcesItem) Print ¶
func (i *TimelineResourcesItem) Print()
Print outputs common item info.
type TimelineVariablesItem ¶
type TimelineVariablesItem struct {
// contains filtered or unexported fields
}
TimelineVariablesItem implements TimelineItem interface and stores Variable map.
func NewTimelineVariablesItem ¶
func NewTimelineVariablesItem(version, commit string, date time.Time, printer *launchr.Terminal) *TimelineVariablesItem
NewTimelineVariablesItem returns new instance of TimelineVariablesItem
func (*TimelineVariablesItem) AddVariable ¶
func (i *TimelineVariablesItem) AddVariable(v *Variable)
AddVariable pushes Variable into timeline item.
func (*TimelineVariablesItem) GetCommit ¶
func (i *TimelineVariablesItem) GetCommit() string
GetCommit returns timeline item commit.
func (*TimelineVariablesItem) GetDate ¶
func (i *TimelineVariablesItem) GetDate() time.Time
GetDate returns timeline item date.
func (*TimelineVariablesItem) GetVariables ¶
func (i *TimelineVariablesItem) GetVariables() *OrderedMap[*Variable]
GetVariables returns Variable map of timeline.
func (*TimelineVariablesItem) GetVersion ¶
func (i *TimelineVariablesItem) GetVersion() string
GetVersion returns timeline item version to propagate.
func (*TimelineVariablesItem) Merge ¶
func (i *TimelineVariablesItem) Merge(item TimelineItem)
Merge allows to merge other timeline item variables.
func (*TimelineVariablesItem) Print ¶
func (i *TimelineVariablesItem) Print()
Print outputs common item info.
type Variable ¶
type Variable struct {
// contains filtered or unexported fields
}
Variable represents a variable used in the application.
func NewVariable ¶
NewVariable returns instance of Variable struct.
func (*Variable) GetPlatform ¶
GetPlatform returns variable platform.
type VariableDependency ¶
type VariableDependency struct {
Name string
Platform string
Dependent map[string]map[string]*VariableDependency
}
VariableDependency stores variable name, platform and reference to dependent vars.
func NewVariableDependency ¶
func NewVariableDependency(name, platform string) *VariableDependency
NewVariableDependency creates new instance of VariableDependency
func (*VariableDependency) SetDependent ¶
func (v *VariableDependency) SetDependent(d *VariableDependency)
SetDependent adds new dependent variable to variable.