invoke

package
v1.235.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 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 invoke is the transport-neutral request and result mapping of the artifact operations.

The CLI, workflow and custom-command steps, script step calls, and kind: step hooks all describe an operation as Params, run it with Run, and report the typed Result or Collection. One implementation builds the service requests, dispatches the action, populates the result, and names the outputs, so every entry point returns identical payloads, named outputs, and field names. Presentation (flags, text rendering, step output modes) stays with each entry point.

The package depends only on the artifact domain. Production service assembly, which needs the plugin-aware registry preparation and the managed signer, lives in pkg/artifactwire.

Package invoke is a generated GoMock package.

Index

Constants

View Source
const (
	OutputOutcome              = "outcome"
	OutputRef                  = "ref"
	OutputLocation             = "location"
	OutputResolvedDigest       = "resolved_digest"
	OutputRecordDigest         = "record_digest"
	OutputContentDigest        = "content_digest"
	OutputRepresentationDigest = "representation_digest"
	OutputSize                 = "size"
)

Named output names. These are the JSON field names of artifact.OperationResult too.

Variables

This section is empty.

Functions

func Actions

func Actions() []artifact.Action

Actions lists the actions in a stable order.

func NamedOutputs

func NamedOutputs(op *artifact.OperationResult) map[string]string

NamedOutputs is OutputPairs as a map, the shape of StepResult.Outputs.

func SelectorLabels

func SelectorLabels(parsed map[string]string) []artifact.Label

SelectorLabels converts exact key/value selectors into the sorted label list the service takes.

Types

type Collection

type Collection struct {
	// Artifacts are the entries across the selected repositories, sorted lexically.
	Artifacts []Listed `json:"artifacts"`

	// Repositories reports per-repository outcomes.
	Repositories []artifact.RepositoryListing `json:"repositories,omitempty"`

	// Incomplete is true when a selected repository could not be listed, so Artifacts is not the
	// whole collection. The failing repository carries an error diagnostic.
	Incomplete bool `json:"incomplete,omitempty"`

	// Error is set when the query failed.
	Error string `json:"error,omitempty"`
}

Collection is the structured result of list and search: the `artifacts` array plus per-repository outcomes, and the error when the query failed.

type DetailedPublisher

type DetailedPublisher interface {
	PublishDetailed(ctx context.Context, request artifact.PublishRequest) (*service.PublishOutcome, error)
}

DetailedPublisher is implemented by the real service. It returns the sealed Record next to the operation result, which a dry run needs in order to show the files it selected.

type DetailedService

type DetailedService interface {
	artifact.Service
	DetailedPublisher
}

DetailedService is a service that also publishes with details, as the real service does.

type Field

type Field string

Field names an input of an artifact operation. The values are the artifact step field names, which are also the CLI flag names where one exists (`--name` is artifact_name, `--kind` is artifact_kind, `--output` is destination).

const (
	FieldSource       Field = "source"
	FieldRepository   Field = "repository"
	FieldArtifactName Field = "artifact_name"
	FieldVersion      Field = "version"
	FieldArtifactKind Field = "artifact_kind"
	FieldForce        Field = "force"
	FieldDryRun       Field = "dry_run"
	FieldLabels       Field = "labels"
	FieldMetadata     Field = "metadata.labels"
	FieldReadme       Field = "readme"
	FieldChangelog    Field = "changelog"
	FieldRef          Field = "ref"
	FieldDestination  Field = "destination"
	FieldFrom         Field = "from"
	FieldTo           Field = "to"
	FieldDocument     Field = "document"
	FieldQuery        Field = "query"
	FieldRefresh      Field = "refresh"
)

Operation inputs.

func AllFields

func AllFields() []Field

AllFields lists every input of every action in a stable order.

type Listed

type Listed struct {
	Repository     string                   `json:"repository,omitempty"`
	Ref            string                   `json:"ref"`
	Name           string                   `json:"name"`
	Version        string                   `json:"version"`
	Kind           string                   `json:"kind"`
	Description    string                   `json:"description,omitempty"`
	Labels         map[string]string        `json:"labels,omitempty"`
	Documents      []artifact.Document      `json:"documents,omitempty"`
	ResolvedDigest digest.Digest            `json:"resolved_digest,omitempty"`
	RecordDigest   digest.Digest            `json:"record_digest,omitempty"`
	ContentDigest  digest.Digest            `json:"content_digest,omitempty"`
	Pinned         artifact.PinnedReference `json:"pinned"`
}

Listed is one entry of the `artifacts` array. It carries the named outputs of an operation result (ref, resolved_digest, record_digest, content_digest) next to the listing fields, plus the pinned reference a consumer lockfile persists.

func ListedFrom

func ListedFrom(entries []artifact.ListEntry) []Listed

ListedFrom converts service entries into collection entries. The result is never nil, so an empty listing encodes as an empty array.

type MockDetailedService

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

MockDetailedService is a mock of DetailedService interface.

func NewMockDetailedService

func NewMockDetailedService(ctrl *gomock.Controller) *MockDetailedService

NewMockDetailedService creates a new mock instance.

func (*MockDetailedService) Copy

Copy mocks base method.

func (*MockDetailedService) Delete

Delete mocks base method.

func (*MockDetailedService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDetailedService) Inspect

Inspect mocks base method.

func (*MockDetailedService) List

List mocks base method.

func (*MockDetailedService) Pin

Pin mocks base method.

func (*MockDetailedService) Publish

Publish mocks base method.

func (*MockDetailedService) PublishDetailed

PublishDetailed mocks base method.

func (*MockDetailedService) Pull

Pull mocks base method.

func (*MockDetailedService) Search

Search mocks base method.

func (*MockDetailedService) ShowDocument

ShowDocument mocks base method.

func (*MockDetailedService) Sign

Sign mocks base method.

func (*MockDetailedService) Verify

Verify mocks base method.

type MockDetailedServiceMockRecorder

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

MockDetailedServiceMockRecorder is the mock recorder for MockDetailedService.

func (*MockDetailedServiceMockRecorder) Copy

func (mr *MockDetailedServiceMockRecorder) Copy(ctx, request any) *gomock.Call

Copy indicates an expected call of Copy.

func (*MockDetailedServiceMockRecorder) Delete

func (mr *MockDetailedServiceMockRecorder) Delete(ctx, request any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockDetailedServiceMockRecorder) Inspect

func (mr *MockDetailedServiceMockRecorder) Inspect(ctx, request any) *gomock.Call

Inspect indicates an expected call of Inspect.

func (*MockDetailedServiceMockRecorder) List

func (mr *MockDetailedServiceMockRecorder) List(ctx, request any) *gomock.Call

List indicates an expected call of List.

func (*MockDetailedServiceMockRecorder) Pin

func (mr *MockDetailedServiceMockRecorder) Pin(ctx, request any) *gomock.Call

Pin indicates an expected call of Pin.

func (*MockDetailedServiceMockRecorder) Publish

func (mr *MockDetailedServiceMockRecorder) Publish(ctx, request any) *gomock.Call

Publish indicates an expected call of Publish.

func (*MockDetailedServiceMockRecorder) PublishDetailed

func (mr *MockDetailedServiceMockRecorder) PublishDetailed(ctx, request any) *gomock.Call

PublishDetailed indicates an expected call of PublishDetailed.

func (*MockDetailedServiceMockRecorder) Pull

func (mr *MockDetailedServiceMockRecorder) Pull(ctx, request any) *gomock.Call

Pull indicates an expected call of Pull.

func (*MockDetailedServiceMockRecorder) Search

func (mr *MockDetailedServiceMockRecorder) Search(ctx, request any) *gomock.Call

Search indicates an expected call of Search.

func (*MockDetailedServiceMockRecorder) ShowDocument

func (mr *MockDetailedServiceMockRecorder) ShowDocument(ctx, request any) *gomock.Call

ShowDocument indicates an expected call of ShowDocument.

func (*MockDetailedServiceMockRecorder) Sign

func (mr *MockDetailedServiceMockRecorder) Sign(ctx, request any) *gomock.Call

Sign indicates an expected call of Sign.

func (*MockDetailedServiceMockRecorder) Verify

func (mr *MockDetailedServiceMockRecorder) Verify(ctx, request any) *gomock.Call

Verify indicates an expected call of Verify.

type Outcome

type Outcome struct {
	// Result is set for every action except list and search.
	Result *Result

	// Collection is set for list and search.
	Collection *Collection
}

Outcome is the result of Run: a Result for single-artifact actions, or a Collection for list and search. Exactly one is set.

func Run

func Run(ctx context.Context, svc artifact.Service, params *Params) (*Outcome, error)

Run executes one operation against the service and returns its typed result.

The returned Outcome is never nil, and the matching Result or Collection is never nil, even when the operation fails: a partial result (the identity, whatever the service resolved before it failed, and the failure markers) accompanies the error. Callers report it and then surface the error, so a failure is never reported as a success and never loses what was learned.

func (*Outcome) Payload

func (o *Outcome) Payload() any

Payload returns the typed value that is reported as JSON or stored in step metadata.

type Pair

type Pair struct {
	// Name is the output name.
	Name string

	// Value is the output text.
	Value string
}

Pair is one named output.

func OutputPairs

func OutputPairs(op *artifact.OperationResult) []Pair

OutputPairs returns the named outputs of an operation in a stable order. An optional value that the operation did not produce is omitted, never filled with a misleading empty string.

type Params

type Params struct {
	// Action selects the operation.
	Action artifact.Action

	// Repository is the configured repository alias for single-repository actions.
	Repository string

	// Repositories restricts list and search; empty means all configured repositories.
	Repositories []string

	// Source is the publish source file or directory, already resolved to a path.
	Source string

	// Name is the artifact name (--name; artifact_name). List uses it to restrict to one name.
	Name string

	// Version is the explicit publish version.
	Version string

	// Kind is the artifact kind (--kind; artifact_kind). Empty means the files kind.
	Kind string

	// Force permits replacing conflicting state where the repository allows it.
	Force bool

	// DryRun validates and plans a publication without writing.
	DryRun bool

	// Refresh bypasses cached discovery snapshots for list and search.
	Refresh bool

	// Labels are the publish metadata labels, or the exact list and search selectors.
	Labels map[string]string

	// Readme and Changelog override the document source paths, relative to the source directory.
	Readme, Changelog string

	// Ref is the artifact reference exactly as the caller typed it.
	Ref string

	// Destination is the pull output directory (--output).
	Destination string

	// From and To are the copy source and destination repository aliases.
	From, To string

	// Document is readme or changelog for show.
	Document string

	// Query is the search text.
	Query string

	// Execution carries the wrapper-owned operation identity and retry budget.
	Execution artifact.Execution
}

Params is the transport-neutral input of one artifact operation: the union of the CLI flags and the artifact step fields. Which fields an action reads is described by SpecFor.

type Result

type Result struct {
	artifact.OperationResult

	// Error is set when the operation failed. The result is still reported, and the exit status is nonzero.
	Error string `json:"error,omitempty"`

	// Record is the sealed Record of a publication (set for dry runs and publications).
	Record *artifact.Record `json:"record,omitempty"`

	// Inspection is the metadata view of an inspected artifact.
	Inspection *artifact.Inspection `json:"inspection,omitempty"`

	// Verification is the authenticated verification result; absent means unchecked.
	Verification *artifact.VerificationResult `json:"verification,omitempty"`

	// Subject is the signed or verified subject.
	Subject *artifact.SignatureSubject `json:"subject,omitempty"`

	// Evidence lists the evidence stored by sign.
	Evidence []artifact.SignatureEvidence `json:"evidence,omitempty"`

	// Document is the descriptor of a shown document.
	Document *artifact.Document `json:"document,omitempty"`

	// Content is the document text of show.
	Content *string `json:"content,omitempty"`
}

Result is the structured result of one operation. The operation fields flatten into the top level with their named-output spelling (ref, location, resolved_digest, record_digest, content_digest, representation_digest, size, outcome), and the action-specific parts follow. JSON and YAML share these names; the display format never changes semantics. The CLI prints it and a step stores it under StepResult.Metadata["artifact"].

func (*Result) MarkFailed

func (r *Result) MarkFailed(err error, action artifact.Action, repository, requested string)

MarkFailed fills the failure markers of a result. The service leaves the outcome empty on failure so a failure is never mistaken for success; the reported result states it explicitly. The requested values fill in what the service could not report, for example when the failure happened before the operation began.

type ServiceFactory

type ServiceFactory func(config *schema.AtmosConfiguration, options ServiceOptions) (artifact.Service, error)

ServiceFactory builds the artifact service for the loaded configuration. Production composes the real repositories lazily, so building the service performs no network access, credential resolution, or directory creation. Tests inject a factory to run an entry point against a fake.

type ServiceOptions

type ServiceOptions struct {
	// AcceptTransparencyLog accepts Sigstore transparency log publication without prompting.
	AcceptTransparencyLog bool
}

ServiceOptions are the per-invocation settings that reach the composition root.

type Spec

type Spec struct {
	// Required inputs must be present and non-empty.
	Required []Field

	// Optional inputs may be present.
	Optional []Field
}

Spec lists the inputs an action requires and the optional inputs it also accepts. Any other input is invalid for the action.

func SpecFor

func SpecFor(action artifact.Action) (Spec, bool)

SpecFor returns the input contract of an action. The second result is false for an action that is not available as a CLI command or step action.

func (Spec) Accepts

func (s Spec) Accepts(field Field) bool

Accepts reports whether the field is required or optional for the action.

func (Spec) Fields

func (s Spec) Fields() []Field

Fields lists every input the action accepts, required first.

Jump to

Keyboard shortcuts

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