Skip to content

Add Chef Supermarket registry support #64

Description

@andrew

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

Trying to create a Chef Supermarket client after importing all registries currently returns unknown ecosystem: chef:

_, err := registries.New("chef", "https://supermarket.chef.io", nil)

Add a chef registry for public and private Supermarket servers. Use https://supermarket.chef.io as the default, while allowing a caller-supplied base URL and HTTP client for internal servers and authentication.

Supermarket exposes both /universe and /api/v1/universe, plus package and version routes under /api/v1/cookbooks. The route definitions define the endpoints. The universe response maps every cookbook version to its dependency constraints and download URL; its generator and request fixture show the response shape.

Use the cookbook endpoint for name, maintainer, description, latest version, source and issue URLs, timestamps, deprecation, and the list of version URLs. The response fields are defined by the cookbook JSON view. Fetch a version endpoint for license, publication time, file size, download URL, supported platforms, and dependencies as defined by the version JSON view.

Keep version strings exactly as published. Follow version URLs returned by the server rather than changing dots to underscores or rebuilding routes. Cache a fetched universe response within the registry so repeated version and dependency lookups do not download the whole graph each time, but do not let it replace fresher metadata from an individual cookbook or version response.

The public universe response is already close to the client's 10 MB body limit. Either resolve #29 first or add an explicit bounded index read that reports an oversize response. Do not pass a silently truncated body to the JSON decoder.

Map the cookbook owner to FetchMaintainers, normal dependencies to runtime scope, supported platforms and quality fields to metadata, and the version file URL to URLBuilder.Download. Record cookbook deprecation in package metadata and mark its returned versions StatusDeprecated. Follow ordinary HTTP redirects and preserve the caller's authentication transport on requests to a custom server.

This ecosystem name must match an accepted Chef PURL type. Package URL currently has no chef definition; its type proposal process requires an issue and type definition. Add the registry to git-pkgs/purl only after that proposal is accepted. Until then the direct registry API can be implemented and tested, but NewFromPURL cannot parse Chef PURLs.

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

Tests should cover several cookbook versions and dependency graphs, exact version preservation, version publication data, maintainer and source metadata, a custom server URL, cached universe access, redirects, authentication through the supplied HTTP client, missing optional fields, oversize or truncated universe responses, and not-found cookbooks 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