Documentation
¶
Overview ¶
Package descriptor reads Artifactory's YAML configuration descriptor and applies it (decision 0009): the body of PATCH /api/system/configuration, `artifactweave config apply` and the bootstrap descriptor. Named entities that do not exist are created, existing ones are updated field by field, omitted keys are untouched, and an entry or a string field whose value is null is deleted.
Index ¶
Constants ¶
const ( SectionLocal = "localRepositories" SectionRemote = "remoteRepositories" SectionVirtual = "virtualRepositories" SectionProxies = "proxies" SectionPropertySets = "propertySets" SectionLayouts = "repoLayouts" )
Sections artifactweave applies. Any other top-level section is refused, so a pipeline never takes a 200 for settings that changed nothing.
const SectionDownloadRedirect = "downloadRedirectConfig"
SectionDownloadRedirect is the system's direct cloud storage download settings: "Minimum Direct Cloud Storage Download Size" in 7.x's General settings, <downloadRedirectConfig><fileMinimumSize> in its descriptor. Unlike the named sections it is one mapping, not entries by name.
Variables ¶
var ErrInvalid = errors.New("invalid configuration descriptor")
ErrInvalid reports a descriptor that cannot be applied; its message names the first problem. Entry points answer it with 400.
Functions ¶
func DownloadRedirectMinSize ¶
DownloadRedirectMinSize returns, in bytes, the minimum redirect size a descriptor set with downloadRedirectConfig.fileMinimumSize; ok is false when none has. It then takes precedence over download.redirect.min_size, the installation's default: the descriptor is the instance's own setting, which the API and its clients change at run time.
Types ¶
type ConfigChange ¶
type ConfigChange struct {
Section string
Kind types.ConfigKind
Key string
Delete bool
// Fields are the descriptor's own names; a nil value removes the field.
Fields map[string]any
// contains filtered or unexported fields
}
ConfigChange is one entry of a proxies, propertySets or repoLayouts section.
type Patch ¶
type Patch struct {
Repos []RepoChange
Configs []ConfigChange
// Changes is the number Artifactory reports as "<n> changes to config
// merged successfully": every value in the document, whether or not it
// differs from what is stored (see values).
Changes int
}
Patch is a parsed descriptor.
type RepoChange ¶
type RepoChange struct {
Section string
Class repo.Class
Key string
Delete bool
// Fields uses the JSON API's names, so updates go through the same
// merge as the repositories API; a JSON null, which Parse lets through
// only on a string field, clears it.
Fields map[string]json.RawMessage
}
RepoChange is one entry of a repository section.
type Result ¶
type Result struct {
Created, Updated, Deleted, Unchanged []string
// Changes is Patch.Changes.
Changes int
// DryRun is set when nothing was written.
DryRun bool
}
Result names what a patch changed, as "section.key".
func Apply ¶
func Apply( ctx context.Context, st store.Store, p *Patch, now time.Time, dryRun bool, ) (Result, error)
Apply checks the whole patch against the store's current state, then, unless dryRun, writes it in one transaction, so a patch with one bad entry changes nothing. Entries that would not change are left alone, which makes applying the same descriptor twice a no-op the second time.