Skip to content

Add Vagrant box declarations from Vagrantfile #72

Description

@andrew

manifests.Parse("Vagrantfile", ...) currently returns UnknownFileError. Add a static Vagrantfile parser for box dependencies. A Vagrantfile is executable Ruby, so parsing must not evaluate the file, interpolate strings, read constants, or run helper methods.

Recognize literal assignments to:

  • config.vm.box
  • config.vm.box_version
  • config.vm.box_url
  • config.vm.box_download_checksum
  • config.vm.box_download_checksum_type

Return a literal config.vm.box value as a direct runtime dependency. Keep namespaced names such as hashicorp/bionic64 intact, preserve box_version as the declared constraint, and use a literal box_url as its source. When both checksum fields are literal, return the integrity value with its algorithm, such as sha256-<digest>. If either half is dynamic or missing, do not construct an integrity value.

Vagrant's machine settings define these fields. The documentation says that box_url may be an HTTP URL, a file:// URL, or an array of URLs, and lists md5, sha1, sha256, sha384, and sha512 as checksum types. Initial support can stay limited to a single literal string and skip arrays without failing the file. Vagrant's box versioning documentation describes exact versions and constraints.

The Vagrant source declares the fields in VMConfig, its generated Vagrantfile template shows the usual box, version, and URL assignments, and the box handling test shows how checksum fields travel with the box request.

Parse single- and double-quoted literal strings with normal whitespace and trailing comments. Skip an individual assignment when its value is an interpolated string, variable, method call, concatenation, environment lookup, or another Ruby expression. Other Vagrant configuration must not affect the box result.

Generated PURLs should follow accepted Vagrant type rules. Vagrant remains a candidate PURL type, so this work should not invent namespace or provider qualifiers before that definition is accepted.

Add parser registration, unit tests, fixtures, and README entries. Tests should cover namespaced boxes, exact versions and version constraints, a custom catalog URL, each documented checksum type, comments, missing optional fields, unrelated configuration, and dynamic expressions mixed with valid literal assignments.

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