Help us shape the future of Go! Take the 2026 Go Developer Survey

descriptor

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 19 Imported by: 0

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

View Source
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.

View Source
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

View Source
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

func DownloadRedirectMinSize(ctx context.Context, configs store.ConfigStore) (int64, bool, error)

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 Lookup

type Lookup func(name string) (string, bool)

Lookup resolves an environment variable, as os.LookupEnv does.

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.

func Parse

func Parse(doc []byte, env Lookup) (*Patch, error)

Parse reads a descriptor. String values of the form ${NAME} are resolved through env; an unset variable is an error rather than an empty value, which would silently clear a password.

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.

func (Result) Merged

func (r Result) Merged() string

Merged is the PATCH endpoint's answer, in Artifactory's words. It counts the document's values rather than what changed, as Artifactory does, so applying the same patch again gives the same number.

func (Result) String

func (r Result) String() string

String is the plain-text summary `config apply` prints.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL