Documentation
¶
Overview ¶
Package repos holds the repository operations that more than one entry point performs: the repositories API, the configuration descriptor (PATCH /api/system/configuration, config apply and the bootstrap descriptor). Its errors are apierror values, so every entry point answers a bad configuration with the same status and message.
Index ¶
- Constants
- Variables
- func CheckEnvironments(ctx context.Context, projects store.ProjectStore, c *repo.Config) error
- func CheckKeypairs(ctx context.Context, keys store.KeyStore, c repo.Config) error
- func CheckMembers(c repo.Config, known []repo.Config) error
- func IsNull(raw json.RawMessage) bool
- func Merge(stored repo.Config, patch map[string]json.RawMessage) (repo.Config, error)
- func OwesReindex(stored, updated repo.Config) bool
- func PrepareCreate(c repo.Config, existing []repo.Config) (repo.Config, error)
- func Protected(key string) bool
- func Remove(ctx context.Context, st store.Store, key, by string) (int64, bool, error)
Constants ¶
const MsgKeyExists = "Case insensitive repository key already exists"
MsgKeyExists answers a create whose key is taken, compared without case.
Variables ¶
var ErrChanged = errors.New("repos: the repository's content changed during the delete")
ErrChanged is a repository delete that found the repository's content changing under it: an item it moved to the trash can was gone by the time it deleted the content. Nothing is deleted, and a retry sees the content as it now is.
Functions ¶
func CheckEnvironments ¶
CheckEnvironments applies Artifactory's rule for a repository's environments (decision 0013). Outside a project they are ignored, so none are stored. In a project an empty list becomes DEV, and every entry must be DEV, PROD, a global environment or one of the project's own environments, which are named "<projectKey>-<name>". Names compare without regard to case and are stored in the environment's own spelling, because renaming or deleting an environment finds its repositories by that spelling.
func CheckKeypairs ¶
CheckKeypairs rejects signing key references (primaryKeyPairRef, secondaryKeyPairRef and Alpine virtual keyPair) to key pairs that do not exist, or whose type the repository cannot use (repo.ValidateKeyPair): a repository would otherwise fail only when it first signs or verifies.
func CheckMembers ¶
CheckMembers rejects a virtual repository whose members do not exist among known, or have a package type the virtual repository cannot aggregate (repo.AcceptsMember). The default deployment repository is a member (repo.Validate), so it is covered too.
The type check holds afterwards without a re-check: a repository's package type cannot change (Merge), and Remove takes a deleted repository out of every virtual repository, so a repository created again under its key joins none until a write names it, which this check sees.
func IsNull ¶
func IsNull(raw json.RawMessage) bool
func Merge ¶
Merge merges an update body into the stored configuration with Artifactory's rules: a field present replaces the stored value, a field left out keeps it, and null resets it to its default. The key, class and package type cannot change, nor can a field the package type takes only when the repository is created (repo.ValidateUpdate). A key that differs from the stored one only in case is a change too: the store finds a repository by its exact key, so accepting the respelling would fail the write after validation (#472).
A class or package type that differs only in case names the stored one, which keeps its spelling (#492): 6.20 reads a package type without regard to case (RepoType.fromType), and taking the respelling would store a type no class allows, which validation then refuses as "not allowed".
func OwesReindex ¶
OwesReindex reports whether an update of stored to updated owes the repository a reindex: one that gives a Terraform repository the terraformType it lacked, so the files it stored before are indexed as that type says (decision 0040).
func PrepareCreate ¶
PrepareCreate applies defaults and validates c for creation against the keys already taken (stored and earlier in the same batch).
func Remove ¶
Remove deletes key with its content, in one transaction: the items of the repository and, for a remote, its cache, the root records that hold their own properties, its package index, its place in the virtual repositories that list it, and its configuration. by is who deletes it. found is false when no configuration exists.
While the trash can is on, the repository's own content moves to it under key, as a delete of its root does, and each file's entry keeps its blob reference until a restore takes it over or a purge releases it. A remote's cache is released for garbage collection, as the trash can holds only what was deleted from local repositories; so is everything while the trash can is off. The root's own properties go with the repository: 7.x fixed a restore of a deleted repository's root copying them onto what it restored (RTDEV-84660).
The whole delete is one transaction, however large the repository, so a failure part of the way leaves it whole, its content where it was and the trash can as it was.
Types ¶
This section is empty.