Documentation
¶
Overview ¶
Package catalog holds the pre-parsed operation index that cchp ships inside the binary. It is generated by cmd/cchp-gen from the pinned upstream spec, spec/cli-overlay.yaml and spec/operation-policy.yaml, so discovery, help and policy checks work offline and start fast.
Index ¶
Constants ¶
const ( StatusAvailable = "available" StatusExcluded = "excluded" StatusUnsupported = "unsupported" )
Coverage outcomes for an upstream operation.
const ( RiskRead = "read" RiskWrite = "write" RiskDestructive = "destructive" )
Risk classes from spec/operation-policy.yaml.
const ( ResponseJSON = "json" ResponseStream = "stream" ResponseBinary = "binary" ResponseEmpty = "empty" )
Response kinds decide how cchp renders a successful response.
Variables ¶
This section is empty.
Functions ¶
func DecodeGzipJSON ¶
DecodeGzipJSON decompresses data and decodes the JSON inside into v.
Types ¶
type Body ¶
type Body struct {
ContentType string `json:"content_type"`
Required bool `json:"required"`
Kind string `json:"kind"` // json, multipart, binary
FileFields []string `json:"file_fields,omitempty"`
}
Body describes the request body.
type Catalog ¶
type Catalog struct {
Source Source `json:"source"`
Groups []Group `json:"groups"`
Operations []*Operation `json:"operations"`
// contains filtered or unexported fields
}
Catalog is the whole generated index.
func DecodeGzip ¶
DecodeGzip parses the gzip-compressed catalog JSON produced by the generator.
func (*Catalog) Search ¶
Search ranks operations by how well they match every word of the query; an operation that misses a word is left out. Unavailable operations are included only when includeAll is set.
Among equal matches a list comes first, because a search that names a thing without saying what to do with it is looking for the list of that thing; then the command whose path holds more of the words exactly as typed; then the command with the shorter name.
type Group ¶
type Group struct {
Name string `json:"name"`
Title string `json:"title"`
Summary string `json:"summary"`
}
Group is a human command group such as "providers".
type Operation ¶
type Operation struct {
ID string `json:"id"`
Method string `json:"method"`
Path string `json:"path"`
Group string `json:"group"`
Name string `json:"name"`
Aliases []string `json:"aliases,omitempty"`
Summary string `json:"summary"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
Public bool `json:"public,omitempty"`
Params []Param `json:"params,omitempty"`
Body *Body `json:"body,omitempty"`
Response Response `json:"response"`
OrgHeader bool `json:"org_header,omitempty"`
Idempotency bool `json:"idempotency,omitempty"`
Policy Policy `json:"policy"`
}
Operation is one upstream OpenAPI operation as cchp sees it.
type OperationSchemas ¶
type OperationSchemas struct {
Body json.RawMessage `json:"body,omitempty"`
Response json.RawMessage `json:"response,omitempty"`
}
OperationSchemas holds the bundled JSON Schemas of one operation.
type Pagination ¶
type Pagination struct {
Style string `json:"style" yaml:"style"` // cursor or page
Param string `json:"param" yaml:"param"`
LimitParam string `json:"limit_param,omitempty" yaml:"limit_param"`
Next string `json:"next,omitempty" yaml:"next"`
HasMore string `json:"has_more,omitempty" yaml:"has_more"`
Items string `json:"items" yaml:"items"`
Total string `json:"total,omitempty" yaml:"total"`
}
Pagination tells cchp how to walk an operation's pages.
type Param ¶
type Param struct {
Name string `json:"name"`
In string `json:"in"`
Flag string `json:"flag"`
Type string `json:"type"`
ItemType string `json:"item_type,omitempty"`
Required bool `json:"required,omitempty"`
Enum []string `json:"enum,omitempty"`
Default any `json:"default,omitempty"`
Description string `json:"description,omitempty"`
}
Param is one path, query or header parameter the CLI exposes.
type Policy ¶
type Policy struct {
Risk string `json:"risk"`
Classified bool `json:"classified"`
Retry bool `json:"retry"`
Permission string `json:"permission,omitempty"`
SecretFields []string `json:"secret_fields,omitempty"`
Pagination *Pagination `json:"pagination,omitempty"`
Note string `json:"note,omitempty"`
// Listing names the operation that lists a download's parts with their sizes
// (same path parameters except the last, which names the part). An empty
// download of a part it lists as not empty is a failure.
Listing string `json:"listing,omitempty"`
}
Policy is the merged entry from spec/operation-policy.yaml.
func (Policy) SecretOutput ¶
SecretOutput reports whether the operation returns a one-time secret that needs an explicit destination.
type Response ¶
type Response struct {
Kind string `json:"kind"`
ContentTypes []string `json:"content_types,omitempty"`
}
Response describes the success response.
type Source ¶
type Source struct {
Repository string `json:"repository"`
Tag string `json:"tag"`
Commit string `json:"commit"`
SpecPath string `json:"spec_path"`
SpecSHA256 string `json:"spec_sha256"`
Exporter string `json:"exporter"`
RestishModule string `json:"restish_module"`
RestishVersion string `json:"restish_version"`
}
Source records where the pinned spec came from (spec/source.lock.json).