vagranthttp

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package vagranthttp serves the native Vagrant routes at Artifactory's prefix, /artifactory/api/vagrant/{repo}, on Vagrant local and federated repositories. GET or HEAD of a box name answers the catalog that vagrant box add, outdated and update read, listing its versions and, for each, the providers and architectures whose boxes the caller may read, with each box's download URL and SHA-256. GET or HEAD of a box file's path, which each download URL names, serves the stored box. The box rules and the index are the format package's (artifacts/ecosystem/vagrant); this package answers HTTP with them.

Role

artifacts module, ecosystem layer: the native Vagrant box catalog of the Vagrant slice. It is named vagranthttp so that it does not shadow net/http. Outside tests, only its own http subtree, the module's http adapters and app may import it (decision 0044, dependency rule 9).

Inputs

  • Driving: the server, which mounts Protocol through the router kit (pkgroute) for repositories of package type vagrant. Boxes are deployed, deleted and annotated through the ordinary item API, where the format's hooks keep the index; this package only reads.
  • Driven: the router kit (pkgroute.Kit), which resolves the repository and the caller, checks permissions and the blackout, reads the package index, the items and their properties in one transaction, and serves a box file through the item download (Kit.ServeItem); the generic download policy (generic.CheckDownload), which drops from a catalog a box the repository's include and exclude patterns refuse; the request's base URL (platform/httpkit/baseurl), from which download URLs are built; and the format package, whose rules tell a box file's path from a box name, check the name and verify each box's properties.

Outputs

  • Protocol: the routes, the local and federated sources and the Artifactory error profile.
  • Answers: the catalog as JSON, its name and its versions, each with its providers' name, url, checksum_type (sha256), checksum and optional architecture, versions and providers sorted, private and kept by no cache (Cache-Control: private, no-store); 404 when the box is unknown or no version has a box to list; and the blackout 404 when a blacked-out repository's catalog would list a box.
  • Box files as the item download answers them: the bytes with their checksum headers, 206 to a Range, 401 or 403 to a caller who may not read the path, the download policy's 404 under a blackout or patterns that reject the path, and 404 "Could not find resource" when no file is stored there.

Invariants

  • A path names a box file when it is a valid item path ending .box (vagrant.IsBoxPath) with no matrix parameters, and a box otherwise [I]. A box name is <name> or <namespace>/<name> (400), and a catalog request takes no query (400); matrix parameters on the name filter the boxes by their properties.
  • A box is listed only when the caller may read it, it is in the repository itself (never a remote's cache), the include and exclude patterns allow it and its recorded properties verify. Of several boxes for one version, provider and architecture, the most recently updated is listed, with the path as the tie-break.
  • A blacked-out repository refuses a catalog that would list a box the caller may read with the blackout 404, naming the box the request names (R2a, R9, R10). Read permission comes first (DV-057): a caller who may read none of the box's entries answers 404 "Vagrant box not found", as for an unknown box.
  • Download URLs name the box file under /artifactory/api/vagrant/{repo}/, where 7.x's catalogs point, and never carry a token; neither route takes one from a query (DV-148).
  • A box file is served as the item download serves it: read permission on its path first (DV-057), then the blackout and the patterns at that path (R9, R10), so a refusal says nothing of what is stored.
  • A catalog lists at most 10,000 versions and 10,000 boxes (503 beyond).
  • A remote or virtual repository has no source and answers 501.
  • Statuses and error texts stay byte-identical.

References

Status

Implemented P9c, which delivered the plan's P33 group (issues #782 to #788). Moved here in P9d. The box file route: https://github.com/weaveplatform/artifactweave/issues/1259.

Testing

  • vagrant_test.go (external, vagranthttp_test), which drives the whole server: catalogs and downloads, the lifecycle of new versions, forged and changed properties, copies, moves, deletes, restores and reindex, statuses and permissions, refused boxes, store failures, and the newest readable box for a duplicate provider.
  • policy_test.go (external too): the blackout 404 to a caller who would see a box, as reader or administrator, with matrix parameters and by HEAD, and "Vagrant box not found" to one who would not, with and without the blackout.
  • boxfile_test.go (external too): the box file route, its URL in the catalog, its bytes, checksum headers and ranges, paths with no box, read permission ahead of the lookup, the download policy, and the paths that stay catalog requests.

The @vagrant acceptance scenarios drive the Vagrant client against local and one-node federated repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Protocol

func Protocol() pkgroute.Protocol

Protocol returns the native Vagrant routes for the router kit, under /artifactory/api/vagrant/{repoKey}. GET and HEAD of a box file's path, <path>.box, serve the stored box as the item download does. GET and HEAD of a box name, <name> or <namespace>/<name>, optionally with matrix parameters that filter the boxes by their properties, answer the box's catalog JSON. Only local and federated repositories have a source; a remote or virtual repository answers 501.

Types

This section is empty.

Jump to

Keyboard shortcuts

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