Documentation
¶
Overview ¶
Package helm is the format of classic Helm chart repositories (decision 0039); Helm OCI repositories are the Docker format's. It reads each chart archive's Chart.yaml, indexes every chart in the repository, in any folder, as a version of the package its name gives (decision 0018), with the per-version Metadata that index.yaml is built from, and sets the chart.* properties. Every write reaches it through the item service, so a chart deployed by a REST PUT, by checksum, from an archive, or landed by a copy, a move or a restore is indexed the same way.
A chart's provenance file, <chart>.prov, is a sidecar the format keeps with its chart (format.SidecarKeeper): it follows the chart through a delete, a copy, a move and a restore, and is never a version file.
Each write that changes a repository's charts queues the repository's index.yaml work, one item per repository (KindIndex).
Role ¶
artifacts module, ecosystem layer: the format rules of the classic Helm slice (package type helm). Its Handler plugs into the item service through the format hooks (decision 0032); the repository protocol that serves what it keeps is the slice's http package (artifacts/ecosystem/helm/http).
Inputs ¶
- Driving: the format registry (artifacts/ecosystem), which hands the item service's hooks for Helm repositories to Handler; the persistent work queue, which runs the index.yaml work (KindIndex) and every format's reindex through Handler (decision 0033); and the protocol, which serves the derived index.yaml (IndexPath, Index, EncodeIndex, Settings) and checks a remote repository's index and charts (ReadChart, IsChartPath, IsSemver).
- Driven: the format hooks' environment (format.Env), through which Handler reads stored charts, keeps the package index (artifacts/core/pkgindex), queues and derives the index.yaml, and finds chart archives by AQL (artifacts/core/aql) for a reindex; and the generic deploy policy (artifacts/ecosystem/generic), which Handler embeds.
- Settings: the server's Helm options (decision 0039, "Configuration"), which reach the protocol through ecosystem.Settings; Handler takes none.
Outputs ¶
- Handler: the hooks that inspect and admit a write (Admit adds Enforce Layout to the generic policy), index a chart, hand a version over when its newest chart goes (Deleting), keep the .prov sidecar (Sidecars), keep the root index.yaml out of replication (Classify), derive the index.yaml (Work, Resolve, Owed) and rebuild the package index (Reindex, ReindexPath).
- The chart.* properties (PropName, PropVersion, PropAppVersion), each version's Metadata in the package index, and the derived index.yaml at IndexPath.
- The rules the protocol shares: Chart and ReadChart, Index, ChartVersion and EncodeIndex, IsChartPath, IsSemver and Settings.
Invariants ¶
- A read of the root index.yaml of a local or federated repository waits for the work its writes queued (Owed), so a client never reads an index that lags a completed write.
- The stored index.yaml holds relative chart URLs; only the protocol makes them absolute, when Settings turn relative URLs off.
- A .prov follows its chart and is never a version file.
- The persisted names (the helm.index work kind and the chart.* properties) and every status and message a client sees, Enforce Layout's refusals included, stay byte-identical.
References ¶
- Decision 0039: docs/research/decisions/0039-helm.md ("Scope", "index.yaml is per-repository derived work", ".prov is a sidecar the Helm format owns", "Charts and the package index", "The shape of index.yaml", "Enforce Layout", "Reindex", "Configuration").
- Decision 0033: docs/research/decisions/0033-persistent-work-queue.md (the index.yaml work); decision 0032: docs/research/decisions/0032-package-format-handlers.md (the format hooks); decision 0018: docs/research/decisions/0018-package-index.md.
- docs/operations/helm-remote.md (the remote cache this format indexes).
- JFrog Helm chart repositories, which Enforce Layout and the partial reindex follow: https://docs.jfrog.com/artifactory/docs/kubernetes-helm-chart-repositories; and the metadata read rule that decision 0039 cites: https://docs.jfrog.com/artifactory/docs/docker-repositories.md.
- Target layout: docs/research/architecture-options/5-modular-monolith.md, line 231 (ecosystem/helm), line 664 (virtual.go) and line 997 (the mapping row).
- Plan: docs/implementation/plan.md#p8-pypi-nuget-helm-terraform-locals, #p9-remote-repositories and #p9d-modular-monolith-migration, epic ECO (https://github.com/weaveplatform/artifactweave/issues/943).
- https://github.com/weaveplatform/artifactweave/issues/1033
Status ¶
Implemented P8 (Helm local repositories), with remote repositories in P9. Moved here in P9d. Roadmap: virtual.go (P10), the Merger that merges the Helm index.yaml for virtual repositories.
Testing ¶
- handler_test.go and fault_test.go: indexing, duplicates, overwrites, transfers and restores, queueing, the remote cache, Owed, Inspect and store faults.
- chart_test.go and enforce_test.go: reading a chart and Enforce Layout.
- derived_test.go and reindex_test.go: the derived index.yaml, its encoding and settings, cold reads and parked work, and full and partial reindexes.
- contract_test.go: the format contract suite (artifacts/core/formattest).
Index ¶
- Constants
- Variables
- func EncodeIndex(index Index) ([]byte, error)
- func IsChartPath(p string) bool
- func IsSemver(v string) bool
- func Serves(t repo.PackageType) bool
- type Chart
- type ChartVersion
- type Dependency
- type Handler
- func (Handler) Admit(ctx context.Context, env format.Env, c repo.Config, w format.Write) (format.Write, error)
- func (Handler) Classify(_ repo.Config, path string) format.Class
- func (Handler) Deleting(ctx context.Context, env format.Env, c repo.Config, it model.Item) error
- func (Handler) Deployed(ctx context.Context, env format.Env, c repo.Config, it model.Item) error
- func (Handler) Inspect(ctx context.Context, env format.Env, _ repo.Config, w format.Write) (any, error)
- func (Handler) Owed(c repo.Config, cached bool, p string) []format.WorkRef
- func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error
- func (Handler) ReindexPath(ctx context.Context, env format.Env, c repo.Config, p string) error
- func (Handler) Resolve(ctx context.Context, env format.Env, c repo.Config, d format.Download) (string, error)
- func (Handler) Sidecars(_ repo.Config, p string) []string
- func (Handler) Work(ctx context.Context, env format.Env, work work.WorkItem) error
- func (Handler) WorkKinds() []string
- type Index
- type Maintainer
- type Metadata
- type Settings
Constants ¶
const ( PropName = "chart.name" PropVersion = "chart.version" PropAppVersion = "chart.appVersion" )
Properties the format sets on an indexed chart from its Chart.yaml: the keys of Artifactory's Helm package search (6.20 PackageSearchCriteria; RTFACT-15566). 7.x still writes appVersion as a property (RTFACT-26509); that 7.161 writes these three keys and no other is [I] (#216).
const APIVersionV1 = "v1"
APIVersionV1 is the apiVersion Helm gives a Chart.yaml that names none (pkg/chart/loader: "if c.Metadata.APIVersion == "" { ... APIVersionV1 }").
const IndexPath = "index.yaml"
IndexPath is where a repository's index.yaml lies: its root alone. An index.yaml in any other folder is an ordinary file.
const KindIndex = "helm.index"
KindIndex is the format's derived work (decisions 0033 and 0039): a repository's index.yaml, keyed by the repository's key alone, since one file lists every chart of the repository. Every write that changes the charts of a local or federated repository queues it in the write's own transaction, so a burst of deploys coalesces into one item.
const ProvSuffix = ".prov"
ProvSuffix makes a chart's path its provenance file's: helm fetches the file at the chart's URL plus .prov (Helm's provenance documentation).
Variables ¶
var ErrNotChart = errors.New("helm: not a usable chart archive")
ErrNotChart is content the format cannot index: no tar or tar.gz, no readable Chart.yaml where a chart keeps it, one that is no YAML mapping of Helm's fields, or one without a name or a version. Such a file is stored but not indexed (decision 0039).
Functions ¶
func EncodeIndex ¶
EncodeIndex writes Helm's fields alphabetically, omitting absent chart fields as Helm's JSON model does. Versions remain quoted even when they resemble numbers, booleans or scientific notation (RTFACT-20334).
func IsChartPath ¶
IsChartPath reports whether p names a file the format reads as a chart archive: one whose name ends .tgz or .tar.gz, as 6.20's HelmAddon.isHelmFile reads it (research 30, section 3). Anything else, a .prov included, is an ordinary file.
func Serves ¶
func Serves(t repo.PackageType) bool
Serves reports whether t is the package type of this format.
Types ¶
type Chart ¶
type Chart struct {
Name string `json:"name,omitempty" yaml:"name"`
Home string `json:"home,omitempty" yaml:"home"`
Sources []string `json:"sources,omitempty" yaml:"sources"`
Version string `json:"version,omitempty" yaml:"version"`
Description string `json:"description,omitempty" yaml:"description"`
Keywords []string `json:"keywords,omitempty" yaml:"keywords"`
Maintainers []Maintainer `json:"maintainers,omitempty" yaml:"maintainers"`
Icon string `json:"icon,omitempty" yaml:"icon"`
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion"`
Condition string `json:"condition,omitempty" yaml:"condition"`
Tags string `json:"tags,omitempty" yaml:"tags"`
AppVersion string `json:"appVersion,omitempty" yaml:"appVersion"`
Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated"`
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations"`
KubeVersion string `json:"kubeVersion,omitempty" yaml:"kubeVersion"`
Dependencies []Dependency `json:"dependencies,omitempty" yaml:"dependencies"`
Type string `json:"type,omitempty" yaml:"type"`
}
Chart is a chart's Chart.yaml as Helm's chart.Metadata reads it: the fields of its model, under the names Helm writes in index.yaml, and no other. Helm reads an index strictly, so a key outside the model would make a whole index.yaml unreadable (decision 0039); unknown keys are dropped here. A scalar read into a string keeps its text as written, so a version of 1.10 stays "1.10" and an appVersion of 504e199 stays a string (RTFACT-20334).
func ReadChart ¶
ReadChart reads the chart archive in ra, of size bytes: the Chart.yaml at its root, which a chart packed by hand may have (RTFACT-16103), or else the one directly inside a top-level folder, where helm package puts it, never a subchart's under charts/ (RTFACT-17119). A requirements.yaml beside it is read into it afterwards, as Helm's loader reads a v1 chart's dependencies (pkg/chart/loader, LoadFiles). Within one place a later entry replaces an earlier one, as extracting the archive would. ErrNotChart when the format cannot index the content; any other error is a failure to read it.
type ChartVersion ¶
type ChartVersion struct {
Chart ` yaml:",inline"`
Created string `yaml:"created" json:"created"`
Digest string `yaml:"digest" json:"digest"`
URLs []string `yaml:"urls" json:"urls"`
}
ChartVersion adds the archive's location and digest to Chart.yaml.
type Dependency ¶
type Dependency struct {
Name string `json:"name" yaml:"name"`
Version string `json:"version,omitempty" yaml:"version"`
Repository string `json:"repository" yaml:"repository"`
Condition string `json:"condition,omitempty" yaml:"condition"`
Tags []string `json:"tags,omitempty" yaml:"tags"`
Enabled bool `json:"enabled,omitempty" yaml:"enabled"`
// ImportValues holds strings and child/parent mappings, which Helm
// keeps as it reads them.
ImportValues []any `json:"import-values,omitempty" yaml:"import-values"`
Alias string `json:"alias,omitempty" yaml:"alias"`
}
Dependency is Helm's chart.Dependency, alias included: 7.x strips it from its index (RTFACT-30329), which Helm's own index keeps (decision 0039).
type Handler ¶
type Handler struct {
// The generic format's hooks for what Helm leaves alone. Admit adds
// Enforce Layout to its deploy policy (enforce.go).
generic.Handler
}
Handler is the Helm format.
func (Handler) Admit ¶
func (Handler) Admit( ctx context.Context, env format.Env, c repo.Config, w format.Write, ) (format.Write, error)
Admit applies the deploy policy of every package type, then Enforce Layout (decision 0039) to every write that lands a chart-named file in a repository that turned it on: a deploy, a checksum deploy, an archive entry, and the target of a copy or move, which the item service then reports and skips. A .prov and every other file pass, as does a checksum upload, which lands no file. The checks run in the order 7.x's documentation lists them, which is [I] (#216):
- forceMetadataNameVersion: Chart.yaml can be read and names a chart and a version;
- forceMetadataNameVersion: the version is SemVer 2.0.0;
- forceMetadataNameVersion: the file is <name>-<version> with its extension;
- forceNonDuplicateChart: no chart at another path of the repository has the same name and version. A write to the same path is an overwrite, and a move's own source is no duplicate of it.
func (Handler) Classify ¶
Classify keeps the root index out of replication: each repository derives its own metadata from the charts it receives.
func (Handler) Deleting ¶
Deleting runs before a file is removed. The item service drops a chart's version link with it and prunes a version left without files; a version that keeps another archive takes that one's Chart.yaml when the newest goes (handOver). A chart's delete, or a client's delete of the root index.yaml, queues the repository's index.yaml.
func (Handler) Deployed ¶
Deployed indexes a chart as a file of its version, and takes a file that no longer holds a chart, or holds another, out of the version it was one of. A chart anywhere in the repository is indexed (RTFACT-25956). It queues the repository's index.yaml when the charts changed, and when a client stored the root index.yaml, which the next run replaces (RTFACT-18128).
func (Handler) Inspect ¶
func (Handler) Inspect( ctx context.Context, env format.Env, _ repo.Config, w format.Write, ) (any, error)
Inspect reads a chart-named file before the write's transaction, so no decompression holds the store's write lock. Other content needs no reading.
func (Handler) Owed ¶
Owed names the work a read of the root index.yaml of a local or federated repository waits for, so a client never reads an index that lags a completed write.
func (Handler) Reindex ¶
Reindex rebuilds the repository's Helm index from every chart archive in it, a remote repository's from its cache, and queues its index.yaml. Which repositories the JFrog reindex operation accepts is the API's rule, not the index's (the item kit's ReindexOps).
func (Handler) ReindexPath ¶
ReindexPath rebuilds the part of the index that the chart archives under p give: a folder, read to its last level, or one archive, as Helm's partial reindex names them (kubernetes-helm-chart-repositories, "Helm Charts Partial Re-Indexing"). A version some of whose archives lie elsewhere keeps them, as the index holds them. An empty path is the whole repository.
func (Handler) Resolve ¶
func (Handler) Resolve( ctx context.Context, env format.Env, c repo.Config, d format.Download, ) (string, error)
Resolve seeds work for a cold index before the item service calls EnsureFresh. A parked item is deliberately left parked: reading must surface its failure, not silently reset its retry budget.
func (Handler) Sidecars ¶
Sidecars names a chart's provenance file, <chart>.prov beside it, which the item service keeps with the chart (decision 0039). Any other file owns none.
type Index ¶
type Index struct {
APIVersion string `json:"apiVersion" yaml:"apiVersion"`
Entries map[string][]ChartVersion `json:"entries" yaml:"entries"`
Generated string `json:"generated" yaml:"generated"`
}
Index is Helm's repository index. Stored chart URLs are relative; only the protocol's absolute mode rewrites them for the requesting proxy.
type Maintainer ¶
type Maintainer struct {
Name string `json:"name,omitempty" yaml:"name"`
Email string `json:"email,omitempty" yaml:"email"`
URL string `json:"url,omitempty" yaml:"url"`
}
Maintainer is Helm's chart.Maintainer.
type Metadata ¶
type Metadata struct {
// Chart is the newest archive's Chart.yaml.
Chart Chart `json:"chart"`
// Path is the archive's path from the repository root, which an index
// entry's URL names.
Path string `json:"path"`
// Digest is the archive's SHA-256 in hex, index.yaml's digest.
Digest string `json:"digest"`
// Created is when the archive was last deployed, index.yaml's created:
// its item's last-modified time, which a copy and a move keep, in UTC
// to the microsecond the stores keep.
Created time.Time `json:"created"`
}
Metadata is a version's document in the package index (PackageVersion.Metadata, decision 0039): what index.yaml's entry for the version is built from, so building it opens no archive. A version's files are every chart archive in the repository with its name and version; the document is the newest one's. Everything in it follows from that archive and its item, so a reindex writes the same bytes.
func DecodeMetadata ¶
DecodeMetadata reads a version's Metadata.
type Settings ¶
type Settings struct{ RelativeURLs *bool }
Settings controls how the protocol serves the stored index. Nil retains Artifactory's default: chart URLs relative to the repository URL.
func (Settings) IsRelative ¶
IsRelative reports whether chart URLs remain relative.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package helmhttp serves classic Helm repositories under /api/helm/: at /artifactory/api/helm/{repoKey}/, through the router kit (decision 0032), the root index.yaml, the charts and their provenance files that helm repo add, helm repo update and helm pull read.
|
Package helmhttp serves classic Helm repositories under /api/helm/: at /artifactory/api/helm/{repoKey}/, through the router kit (decision 0032), the root index.yaml, the charts and their provenance files that helm repo add, helm repo update and helm pull read. |