Documentation
¶
Index ¶
- func BuildRepoMapsAndKeys(src, tgt []models.ExtendedRepository) (map[string]models.ExtendedRepository, map[string]models.ExtendedRepository, ...)
- func BuildRollbackPlan[T any, ID comparable](source []models.ExtendedRepository, diff models.RepoDiff, ...) *models.RollbackPlan
- func DiffRepoItems[T any, ID comparable](sourceRepo, targetRepo models.ExtendedRepository, ops RepoItemOps[T, ID]) (create []T, update []T, delete_ []T)
- func ForceUpdateBySourceIDs[T any, ID comparable](source, target []models.ExtendedRepository, ops RepoItemOps[T, ID]) []models.ExtendedRepository
- func GenerateRepoDiff[T any, ID comparable](src, tgt []models.ExtendedRepository, ops RepoItemOps[T, ID]) (*models.RepoDiff, error)
- func GroupRepositories(repos []models.ExtendedRepository) []models.ExtendedRepository
- func HasOption(options string, target string) bool
- func Int32PtrToString(v *int32) string
- func Int64PtrToString(v *int64) string
- func OptionalBool(b bool) *bool
- func OptionalString(s string) *string
- func ParseColumns(columns string) []string
- func ParseColumnsToLower(columns string) []string
- func ParseFile[T any](filePath string, out *T) error
- func ParseRepositoriesFromArgs(repoIdent, input string) ([]models.ExtendedRepository, error)
- func PrintRepos(repos []models.ExtendedRepository, columns []string)
- func PrintStructured(name string, data interface{}, format string, columns string) error
- func ReadRollbackPlan(path string) (*models.RollbackPlan, error)
- func SafeInterface(v interface{}) string
- func SafeValue[T any](v *T) T
- func SortRepositoriesStable(repos []models.ExtendedRepository) []models.ExtendedRepository
- func WriteRepositoriesToFile(path string, repos []models.ExtendedRepository, format string) error
- func WriteRollbackPlan(path, format string, plan *models.RollbackPlan) error
- type RepoItemOps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRepoMapsAndKeys ¶ added in v0.8.0
func BuildRepoMapsAndKeys(src, tgt []models.ExtendedRepository) (map[string]models.ExtendedRepository, map[string]models.ExtendedRepository, []string)
BuildRepoMapsAndKeys builds source/target maps keyed by projectKey/repositorySlug and returns the union of keys in a deterministic slice order (insertion order: all keys from source, then new keys from target).
func BuildRollbackPlan ¶ added in v0.8.0
func BuildRollbackPlan[T any, ID comparable](source []models.ExtendedRepository, diff models.RepoDiff, updated, created []models.ExtendedRepository, ops RepoItemOps[T, ID]) *models.RollbackPlan
BuildRollbackPlan constructs a rollback plan based on source state and diff result
func DiffRepoItems ¶ added in v0.8.0
func DiffRepoItems[T any, ID comparable](sourceRepo, targetRepo models.ExtendedRepository, ops RepoItemOps[T, ID]) (create []T, update []T, delete_ []T)
DiffRepoItems computes create/update/delete sets between two repositories for a given item type. - create: target items without ID, plus items whose ID is in target but not in source - update: items with IDs present in both repos but differing by Equal - delete: items with IDs present in source but not in target
func ForceUpdateBySourceIDs ¶ added in v0.8.0
func ForceUpdateBySourceIDs[T any, ID comparable](source, target []models.ExtendedRepository, ops RepoItemOps[T, ID]) []models.ExtendedRepository
ForceUpdateBySourceIDs selects from target all items whose IDs are present in source for the same repo
func GenerateRepoDiff ¶ added in v0.8.0
func GenerateRepoDiff[T any, ID comparable](src, tgt []models.ExtendedRepository, ops RepoItemOps[T, ID]) (*models.RepoDiff, error)
GenerateRepoDiff builds a generic repo-level diff using the provided item ops
func GroupRepositories ¶ added in v0.8.0
func GroupRepositories(repos []models.ExtendedRepository) []models.ExtendedRepository
GroupRepositories merges items for the same repo and deduplicates both required-builds and webhooks by id.
func Int32PtrToString ¶ added in v0.3.0
func Int64PtrToString ¶ added in v0.7.0
func OptionalBool ¶ added in v0.3.0
func ParseColumns ¶ added in v0.2.0
ParseColumns splits a comma-separated string and trims whitespace from each element without changing case. Use this for Bitbucket identifiers (project keys, repository slugs) where the original casing must be preserved.
func ParseColumnsToLower ¶ added in v0.4.3
func ParseFile ¶ added in v0.6.0
ParseFile is a universal function that parses YAML or JSON files into the provided struct pointer
func ParseRepositoriesFromArgs ¶ added in v0.9.0
func ParseRepositoriesFromArgs(repoIdent, input string) ([]models.ExtendedRepository, error)
ParseRepositoriesFromArgs parses repositories from either repoIdent (comma-separated project/repo) or input file/stdin. If input is provided, it takes precedence. Returns error if neither is provided.
func PrintRepos ¶ added in v0.2.0
func PrintRepos(repos []models.ExtendedRepository, columns []string)
PrintRepos prints a slice of Repository according to selected columns
func PrintStructured ¶ added in v0.3.0
PrintStructured prints data in JSON, YAML, or plain table format
func ReadRollbackPlan ¶ added in v0.8.0
func ReadRollbackPlan(path string) (*models.RollbackPlan, error)
ReadRollbackPlan reads a rollback plan from JSON or YAML file
func SafeInterface ¶ added in v0.3.0
func SafeInterface(v interface{}) string
func SortRepositoriesStable ¶ added in v0.8.0
func SortRepositoriesStable(repos []models.ExtendedRepository) []models.ExtendedRepository
SortRepositoriesStable returns a sorted copy of repositories ordered by projectKey, repositorySlug, and with inner collections sorted by id: - requiredBuilds[].id (int64) ascending, nil first - webhooks[].id (int32) ascending, nil first
func WriteRepositoriesToFile ¶ added in v0.8.0
func WriteRepositoriesToFile(path string, repos []models.ExtendedRepository, format string) error
WriteRepositoriesToFile writes repositories grouped by projectKey/repositorySlug to a file. The payload is wrapped under key "repositories". Format is controlled by the `format` argument (json|yaml). For each repository, both RequiredBuilds and Webhooks are merged across duplicates and de-duplicated by id.
func WriteRollbackPlan ¶ added in v0.8.0
func WriteRollbackPlan(path, format string, plan *models.RollbackPlan) error
WriteRollbackPlan writes plan to file in json or yaml based on format
Types ¶
type RepoItemOps ¶ added in v0.8.0
type RepoItemOps[T any, ID comparable] struct { GetItems func(models.ExtendedRepository) []T SetItems func(*models.ExtendedRepository, []T) GetID func(T) (ID, bool) // returns (id, true) if item has id, otherwise (_, false) Equal func(T, T) bool // semantic equality }
RepoItemOps defines how to access, identify, and compare repository-scoped items. T is the item type (e.g., RestRequiredBuildCondition or RestWebhook), ID is the id type (e.g., int64 or int32).