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
- Variables
- func RequestError(site, action string, err error) error
- func ValidateListOrder(order string) error
- func ValidateSite(site string) error
- func VersionFromURL(s string) string
- func VersionListFromURLs(urls []string) []string
- type Client
- func (c *Client) Download(ctx context.Context, opts DownloadOptions) (DownloadResult, error)
- func (c *Client) Install(ctx context.Context, server *cinc.Client, opts InstallOptions) (InstallResult, error)
- func (c *Client) List(ctx context.Context, opts ListOptions) (ListResult, error)
- func (c *Client) Reachable(ctx context.Context) error
- func (c *Client) Search(ctx context.Context, opts SearchOptions) (SearchResult, error)
- func (c *Client) Share(ctx context.Context, opts ShareOptions) (ShareResult, error)
- func (c *Client) Show(ctx context.Context, opts ShowOptions) (ShowResult, error)
- type Cookbook
- type CookbookVersion
- type DownloadOptions
- type DownloadResult
- type InstallOptions
- type InstallResult
- type ListEntry
- type ListOptions
- type ListResult
- type Option
- type SearchOptions
- type SearchResult
- type ShareOptions
- type ShareResult
- type ShowOptions
- type ShowResult
Constants ¶
const DefaultSite = sm.DefaultBaseURL
DefaultSite is the public Supermarket instance.
Variables ¶
var ListOrders = []string{ sm.OrderByName, sm.OrderRecentlyUpdated, sm.OrderRecentlyAdded, sm.OrderMostDownloaded, sm.OrderMostFollowed, }
ListOrders are the sort orders Supermarket's cookbook list accepts.
Functions ¶
func RequestError ¶ added in v0.30.0
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
ValidateListOrder accepts "" (the server's default order) or one of ListOrders.
func ValidateSite ¶ added in v0.30.0
ValidateSite reports whether site is a Supermarket address the client can use, with the same message New and NewAnonymous give.
func VersionFromURL ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
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 ¶
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's chefignore file.
SkipChefignore bool
}
ShareOptions controls a cookbook share operation.
type ShareResult ¶
type ShareResult struct {
// 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.
}
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 ¶
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.
Source Files
¶
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. |