supermarket

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package supermarket orchestrates Chef Supermarket cookbook uploads.

It owns the local concerns — locating the cookbook on disk, building the upload tarball, and rendering dry-run results — and delegates every network call (signed share, category lookup) to github.com/cinc-project/cinc-supermarket-api.

Index

Constants

View Source
const DefaultSite = sm.DefaultBaseURL

DefaultSite is the public Supermarket instance.

Variables

ListOrders are the sort orders Supermarket's cookbook list accepts.

Functions

func RequestError added in v0.30.0

func RequestError(site, action string, err error) error

RequestError explains a failed read from the Supermarket at site, for callers that talk to the library directly (the explore TUI). action completes "we couldn't ...", e.g. "list cookbooks".

func ValidateListOrder added in v0.29.0

func ValidateListOrder(order string) error

ValidateListOrder accepts "" (the server's default order) or one of ListOrders.

func ValidateSite added in v0.30.0

func ValidateSite(site string) error

ValidateSite reports whether site is a Supermarket address the client can use, with the same message New and NewAnonymous give.

func VersionFromURL

func VersionFromURL(s string) string

VersionFromURL extracts the version segment from a Supermarket version URL like https://supermarket.chef.io/api/v1/cookbooks/nginx/versions/12_0_4 returning "12.0.4". It delegates to the cinc-supermarket SDK, which owns the Supermarket version-encoding rules.

func VersionListFromURLs

func VersionListFromURLs(urls []string) []string

VersionListFromURLs decodes a slice of Supermarket version URLs and returns the version strings sorted newest-first.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client uploads cookbooks to one Chef Supermarket endpoint.

func New

func New(profile config.Profile, site string, opts ...Option) (*Client, error)

New builds a Supermarket client using the profile's Supermarket identity.

The signing identity is resolved through Profile.SupermarketIdentity, so a profile can override the username and/or key used for uploads via supermarket_client_name/supermarket_key while falling back to client_name/client_key for whichever override is unset.

func NewAnonymous

func NewAnonymous(site string) (*Client, error)

NewAnonymous builds a Supermarket client that performs only anonymous reads. No profile, key, or identity is required — use this for commands like `download` and `explore` that never hit signed endpoints.

func (*Client) Download

func (c *Client) Download(ctx context.Context, opts DownloadOptions) (DownloadResult, error)

Download fetches a cookbook tarball from Supermarket and writes it to opts.File (or the resolved default location).

func (*Client) Install

func (c *Client) Install(ctx context.Context, server *cinc.Client, opts InstallOptions) (InstallResult, error)

Install downloads a cookbook from Supermarket and uploads it to the Cinc Server reached through server. The Supermarket download is anonymous; the upload is signed by the caller-supplied server client.

Only the named cookbook is installed — dependencies are not resolved.

func (*Client) List

func (c *Client) List(ctx context.Context, opts ListOptions) (ListResult, error)

List walks every page of /api/v1/cookbooks (or stops at Limit) and, when Verbose is set, enriches each row with the latest version number from /universe.

func (*Client) Reachable

func (c *Client) Reachable(ctx context.Context) error

Reachable verifies the Supermarket endpoint is responding by hitting its health endpoint through the cinc-supermarket client. It is the unauthenticated preflight used by `cinc config validate`; network access stays delegated to the library rather than being hand-rolled in the command layer.

func (*Client) Search

func (c *Client) Search(ctx context.Context, opts SearchOptions) (SearchResult, error)

Search walks every page of /api/v1/search?q=… (or stops at Limit) and, when Verbose is set, enriches each row with the latest version number from /universe.

func (*Client) Share

func (c *Client) Share(ctx context.Context, opts ShareOptions) (ShareResult, error)

Share packages and optionally uploads a cookbook to Supermarket.

func (*Client) Show

func (c *Client) Show(ctx context.Context, opts ShowOptions) (ShowResult, error)

Show fetches a single cookbook record, or a single version record when opts.Version is set.

type Cookbook

type Cookbook = sm.Cookbook

Cookbook and CookbookVersion are re-exported from the SDK so the cmd layer can render Show results without importing github.com/cinc-project/cinc-supermarket-api directly.

type CookbookVersion

type CookbookVersion = sm.CookbookVersion

Cookbook and CookbookVersion are re-exported from the SDK so the cmd layer can render Show results without importing github.com/cinc-project/cinc-supermarket-api directly.

type DownloadOptions

type DownloadOptions struct {
	Cookbook string
	// Version is "latest" (or empty, treated as "latest") or any Semver
	// the Supermarket API accepts. The resolved version goes into
	// DownloadResult.Version.
	Version string
	// File is the on-disk target. It may be empty (default
	// "<cookbook>-<version>.tar.gz" in the current directory), a
	// directory (default name dropped inside it), or a full file path.
	File string
	// Force overwrites an existing target file.
	Force bool
}

DownloadOptions controls a cookbook download.

type DownloadResult

type DownloadResult struct {
	Cookbook string `json:"cookbook"`
	Version  string `json:"version"`
	File     string `json:"file"`
	Bytes    int64  `json:"bytes"`
}

DownloadResult describes the work done by Download.

type InstallOptions

type InstallOptions struct {
	Cookbook string
	// Version is "latest" (or empty, treated as "latest") or any concrete
	// Semver the Supermarket API accepts. The resolved version goes into
	// InstallResult.Version.
	Version string
}

InstallOptions controls installing a Supermarket cookbook into a Cinc Server.

type InstallResult

type InstallResult struct {
	Cookbook  string `json:"cookbook"`
	Version   string `json:"version"`
	Installed bool   `json:"installed"`
}

InstallResult describes the work done by Install.

type ListEntry

type ListEntry struct {
	Name          string `json:"name"`
	Maintainer    string `json:"maintainer"`
	Description   string `json:"description,omitempty"`
	LatestVersion string `json:"latest_version,omitempty"`
}

ListEntry is one row in a list result.

type ListOptions

type ListOptions struct {
	// Order, when set, is one of ListOrders.
	Order string
	// User, when set, restricts results to cookbooks owned by that
	// Supermarket username.
	User string
	// Limit caps the total number of entries returned. Zero means
	// "every cookbook on the server".
	Limit int
	// Verbose enriches each entry with its latest version, fetched
	// from /universe in a single request.
	Verbose bool
}

ListOptions controls a cookbook list operation.

type ListResult

type ListResult struct {
	Entries []ListEntry `json:"entries"`
	Total   int         `json:"total"`
}

ListResult is the full set of entries the server (or limit) yielded. Total is the server's count for an unfiltered list. Filtered by User, it is the number of entries found, since Supermarket reports the whole catalog there; it is then a lower bound when Limit cut the walk short.

type Option added in v0.30.0

type Option func(*Client)

Option customizes New.

func WithProfileSource added in v0.30.0

func WithProfileSource(profile, path string) Option

WithProfileSource names the profile and credentials file the Supermarket identity came from, so error messages can point at the exact file to edit. Either may be empty when unknown.

type SearchOptions

type SearchOptions struct {
	// Query is the fuzzy search string sent to /api/v1/search. Required.
	Query string
	// Limit caps the total number of entries returned. Zero means
	// "every cookbook that matches".
	Limit int
	// Verbose enriches each entry with its latest version from
	// /universe in a single follow-up request.
	Verbose bool
}

SearchOptions controls a cookbook search.

type SearchResult

type SearchResult struct {
	Entries []ListEntry `json:"entries"`
	Total   int         `json:"total"`
}

SearchResult is the full set of entries the server (or limit) yielded. Total is the number of matches found: Supermarket's own search total is the size of the whole catalog. When Limit cut the walk short it is a lower bound.

type ShareOptions

type ShareOptions struct {
	Cookbook     string
	Category     string
	CookbookPath string
	DryRun       bool
	// SkipChefignore disables filtering the tarball through the
	// cookbook's chefignore file.
	SkipChefignore bool
}

ShareOptions controls a cookbook share operation.

type ShareResult

type ShareResult struct {
	Cookbook    string   `json:"cookbook"`
	Version     string   `json:"version"`
	Category    string   `json:"category"`
	Uploaded    bool     `json:"uploaded"`
	Status      int      `json:"status"`
	Tarball     string   `json:"tarball"`
	TarballSize int      `json:"tarball_size"`
	Files       []string `json:"files,omitempty"`
	// Site is the Supermarket base URL an upload was sent to, and URL is the
	// public page for the uploaded version. Both are empty on a dry run.
	Site string `json:"site,omitempty"`
	URL  string `json:"url,omitempty"`
}

ShareResult describes the work done by Share.

func DryRun

func DryRun(opts ShareOptions) (ShareResult, error)

DryRun packages a cookbook for Supermarket without loading credentials or contacting the configured Supermarket.

type ShowOptions

type ShowOptions struct {
	Cookbook string
	Version  string
}

ShowOptions controls a show operation. When Version is empty the result describes the cookbook as a whole; otherwise it describes that specific version.

type ShowResult

type ShowResult struct {
	Cookbook *Cookbook        `json:"cookbook,omitempty"`
	Version  *CookbookVersion `json:"version,omitempty"`
}

ShowResult carries exactly one of Cookbook or Version, depending on whether ShowOptions.Version was set. JSON marshalling produces just the populated field.

Directories

Path Synopsis
Package explore implements the `cinc supermarket explore` TUI: a bubbletea-driven cookbook browser over the anonymous read endpoints of Chef Supermarket.
Package explore implements the `cinc supermarket explore` TUI: a bubbletea-driven cookbook browser over the anonymous read endpoints of Chef Supermarket.

Jump to

Keyboard shortcuts

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