Skip to content

Add Vagrant box catalog registry support #65

Description

@andrew

Version: git-pkgs/registries current main at 418e68a.

Trying to create a Vagrant box registry client after importing all registries currently returns unknown ecosystem: vagrant:

_, err := registries.New("vagrant", "https://vagrantcloud.com", nil)

Add a vagrant registry for Vagrant box catalogs and Vagrant Cloud. A box catalog contains a name, description, versions, and a list of provider artifacts for each version. Vagrant's BoxMetadata parser defines the top-level shape, while its Provider records define provider name, artifact URL, checksum type and value, architecture, and default-architecture marker. The upstream box metadata test is a small example with several versions and providers.

Support three ways to locate metadata:

  • For the default https://vagrantcloud.com service and a name such as bento/ubuntu-24.04, use the richer /api/v2/box/<owner>/<box> endpoint. It includes version and provider timestamps in addition to catalog fields. The corresponding public box response is an example.
  • Accept the catalog endpoint /api/v2/vagrant/<owner>/<box> as a fallback for compatible Vagrant servers. Vagrant itself expands shorthand names to that path before trying the direct shorthand URL in BoxAdd.
  • Allow an exact caller-supplied metadata JSON URL for self-hosted catalogs. Do not invent timestamps when this format omits them.

Map box name and owner namespace, description, latest active version, version status, and publication time when supplied. Map revoked versions to StatusYanked and retain other server statuses in metadata. Keep every provider artifact under Version.Metadata, including provider, architecture, URL, checksum, checksum type, hosted state, and timestamps. Legacy catalogs omit architecture; preserve that as unknown and follow Vagrant's default and legacy architecture selection behavior.

The shared Version and URLBuilder.Download types have only one integrity value and one download URL, but a box version can have several provider and architecture artifacts. Do not choose one arbitrarily. Set those single-value fields only when one artifact is unambiguous, and retain all variants in metadata otherwise. Normalize recognized provider checksums to algorithm-hex; keep none empty. Verification of Vagrant's MD5 and SHA-1 catalog values depends on git-pkgs/integrity#1.

Follow redirects for catalog and provider URLs. Support private catalogs and Vagrant Cloud access tokens through the supplied HTTP client without returning credentials in metadata or generated URLs. Return no dependencies or maintainers unless a server response defines such fields.

This ecosystem name must match an accepted Vagrant PURL type. Package URL currently has no vagrant definition; its type proposal process requires an issue and type definition. Add the registry to git-pkgs/purl only after that proposal is accepted. The proposal also needs to settle how provider and architecture identify an artifact before NewFromPURL can select one.

Follow the new ecosystem layout, register the package from all/all.go, and add it to the root ecosystem tests.

Tests should cover multiple versions, providers, and architectures; legacy catalogs without architecture; Vagrant Cloud and exact catalog URLs; active and revoked versions; available checksum types; provider redirects; private catalog authentication; missing optional fields; an ambiguous version with several artifacts; and not-found boxes and versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions