Documentation
¶
Overview ¶
Package report renders the results of artifact operations as CI job summaries and CI output variables.
The package has two halves. Collector is the seam execution boundaries record into: the artifact step handler, the CLI commands, and (through the step handler) workflows, custom commands, and hooks. Session is the collector that renders. It buffers every recorded attempt, keeps the final attempt of each logical operation, orders the operations by their scheduled position, and on Session.Flush writes exactly one summary through the existing ci.Reporter, so the ci.* gates, provider routing, masking, and template loader apply unchanged.
The renderer works over typed results only. It never mutates a repository and never asks a repository for more metadata or evidence: a disabled summary costs nothing, and an enabled one reports exactly what the operation already returned. Collectors are passed explicitly through runner services and options, never through context values.
This is the only package under pkg/artifact that depends on CI reporting. The domain, services, and wiring packages stay free of it, which a boundary test enforces.
Package report is a generated GoMock package.
Index ¶
- Constants
- type Claim
- type Collection
- type Collector
- type Diagnostic
- type Digest
- type Discard
- type Entry
- type Evidence
- type File
- type Inventory
- type Label
- type Lock
- type MockCollector
- type MockCollectorMockRecorder
- type Operation
- type Option
- type Report
- type RepositoryResult
- type Row
- type Session
- type Signature
Constants ¶
const ( // DefaultMaxBytes is the largest summary the renderer produces. GitHub rejects a step summary // over 1 MiB, so the default leaves headroom below it for content other steps already wrote. DefaultMaxBytes = 1024*1024 - 64*1024 )
const OutputPrefix = "artifact_"
OutputPrefix namespaces the CI output variables of artifact operations, so a job that publishes an artifact and also runs Terraform never sees two features write the same name.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Claim ¶
Claim is a verified signer identity. Identity and Issuer are set for keyless signing and KeyID for key-based signing.
type Collection ¶
type Collection struct {
// Count is the number of artifacts returned.
Count int
// Incomplete is true when a repository could not be listed, so Count is not the whole collection.
Incomplete bool
// Repositories reports each repository's result.
Repositories []RepositoryResult
// Artifacts lists the first returned artifacts as code spans; More counts the rest.
Artifacts []string
More int
}
Collection summarizes a list or search.
type Collector ¶
type Collector interface {
// Record stores one entry. It must not block the operation and must not fail it: reporting
// problems are the collector's own to log.
Record(entry *Entry)
}
Collector receives the entries that artifact operations produce. Implementations must be safe for concurrent use: steps in a parallel group record concurrently.
type Diagnostic ¶
type Diagnostic struct {
// Severity is info, warning, or error; Code may be empty.
Severity string
Code string
Message string
}
Diagnostic is one non-fatal message.
type Digest ¶
type Digest struct {
// Label names the digest type: Resolved, Record, Content, or Representation.
Label string
// Meaning says what the digest identifies.
Meaning string
// Value is the full digest as a code span, and Short its shortened form.
Value string
Short string
}
Digest is one labelled digest.
type Discard ¶
type Discard struct{}
Discard is the default collector. It ignores every entry, so an unconfigured runner pays nothing.
type Entry ¶
type Entry struct {
// Step is the name of the step that ran the operation, or empty outside a step.
Step string
// OperationID is the logical operation identifier. Every retry attempt of one operation
// carries the same ID, so a renderer deduplicates by it and keeps the final attempt.
OperationID string
// Action is the requested action. It names the operation when the result carries none, as for a
// list or search collection or for a failure before the service ran.
Action artifact.Action
// Attempt counts the attempts of this logical operation, starting at one.
Attempt int
// Position is the scheduled position of the logical operation: one integer per nesting level,
// compared lexicographically. The boundary that schedules the operation sets it, so a report
// orders operations by where they were scheduled rather than by when they finished. Every
// attempt of one logical operation carries the same position. A nil position orders after
// every positioned entry, in arrival order.
Position []int
// Outcome is the typed outcome of single-artifact actions. It is nil for list and search.
Outcome *invoke.Outcome
// Err is the operation error, or nil on success. A failed attempt still carries the partial
// result in Outcome.
Err error
}
Entry is one completed or failed operation attempt, recorded at an execution boundary.
func EntryFor ¶
EntryFor builds the entry of a standalone command from the outcome of invoke.Run and its error. A command runs each operation once, so the attempt is one, and the operation's own ID, when the service reported one, identifies it.
type Evidence ¶
type Evidence struct {
// Format is the evidence encoding, and Digest the evidence blob digest as a code span.
Format string
Digest string
}
Evidence is one evidence blob.
type File ¶
type File struct {
// Path is a code span, and Size a human-readable size, empty for directories and symlinks.
Path string
Size string
}
File is one payload entry.
type Inventory ¶
type Inventory struct {
// Count is the number of entries in the Record, and Bytes their total size.
Count int
Bytes string
// Files are the first entries; More counts the entries not listed.
Files []File
More int
}
Inventory lists payload files.
type Lock ¶
type Lock struct {
// Scope is the actual lock scope: host, repository, or none.
Scope string
// Guarantee says in a sentence what the scope does and does not exclude.
Guarantee string
}
Lock states the guarantee of the lock that coordinated a mutation.
type MockCollector ¶
type MockCollector struct {
// contains filtered or unexported fields
}
MockCollector is a mock of Collector interface.
func NewMockCollector ¶
func NewMockCollector(ctrl *gomock.Controller) *MockCollector
NewMockCollector creates a new mock instance.
func (*MockCollector) EXPECT ¶
func (m *MockCollector) EXPECT() *MockCollectorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockCollector) Record ¶
func (m *MockCollector) Record(entry *Entry)
Record mocks base method.
type MockCollectorMockRecorder ¶
type MockCollectorMockRecorder struct {
// contains filtered or unexported fields
}
MockCollectorMockRecorder is the mock recorder for MockCollector.
type Operation ¶
type Operation struct {
// Number is the one-based position of the operation in the report.
Number int
// Step is the name of the step that ran the operation, or empty for a standalone command.
Step string
// Action is the action name, for example publish, and ActionLabel its title-cased form.
Action string
ActionLabel string
// Title is the section heading text: the action label and the reference.
Title string
// Icon, Status, and Kind classify the result. Kind is one of success, unchanged, dry-run,
// unchecked, failed, or canceled.
Icon string
Status string
Kind string
// Summary is one sentence stating what happened.
Summary string
// Repository, Requested, Ref, and Destination are code spans. Requested is empty when it equals Ref.
Repository string
Requested string
Ref string
Destination string
// Aliases lists the additional locations or tags that resolve to the same content, as code spans.
Aliases []string
// Size and Duration are human-readable. ExactSize adds the byte count.
Size string
ExactSize string
Duration string
// Attempts is the number of attempts the final result took; one means no retry.
Attempts int
// Lock is the lock guarantee of a mutation, or nil when the operation did not coordinate one.
Lock *Lock
// Digests lists every digest the operation reported, each labelled with its type.
Digests []Digest
// Integrity says what the digests prove and what they do not.
Integrity string
// Signature is the signature subject, evidence, and verification result, or nil when the
// operation neither signed nor verified.
Signature *Signature
// Error is the fenced error block of a failed operation.
Error string
// Diagnostics are the non-fatal messages of the operation, capped; DiagnosticsMore counts the rest.
Diagnostics []Diagnostic
DiagnosticsMore int
// Description and Labels come from the published Record.
Description string
Labels []Label
// Inventory lists the payload files of a published or inspected Record.
Inventory *Inventory
// Collection summarizes a list or search result.
Collection *Collection
}
Operation is the template context of one per-operation section (ci.templates.artifacts.<action>). Every string is already escaped Markdown.
type Option ¶
type Option func(*Session)
Option configures a Session.
func WithMaxBytes ¶
WithMaxBytes sets the largest summary the session writes. Zero or a negative value keeps DefaultMaxBytes. A limit too small to hold even the truncation notice produces the start of the notice cut to the limit, so the summary never exceeds a positive limit.
func WithReporter ¶
func WithReporter(factory func(*schema.AtmosConfiguration) ci.Reporter) Option
WithReporter replaces the factory that builds the CI reporter. The default is ci.NewReporter, which owns provider detection and the ci.* gating. Tests inject a fake reporter.
type Report ¶
type Report struct {
// Heading is the report heading text.
Heading string
// Overview is a one-line count of the operations and their outcomes.
Overview string
// Total is the number of operations in the report.
Total int
// Succeeded, Unchanged, Failed, and Canceled count the operations by result. An unchanged
// operation succeeded without writing anything and is counted only as unchanged.
Succeeded int
Unchanged int
Failed int
Canceled int
// Rows are the compact overview table rows, one per operation, in report order.
Rows []Row
// Sections are the rendered per-operation sections, in report order. When the size limit
// forced operations out of the report, only the first Total-Omitted operations have a section.
Sections []string
// Omitted is the number of operation sections left out to fit the summary size limit.
Omitted int
// Notice is a visible note about a degraded report, such as omitted sections. It is empty
// when the report is complete.
Notice string
}
Report is the template context of the frame template (ci.templates.artifacts.summary). Every string is already escaped Markdown: a template prints the fields as they are and never needs to escape them. Strings that are code spans, such as references and digests, are wrapped in backticks already.
type RepositoryResult ¶
type RepositoryResult struct {
// Repository is the alias as a code span, Count the entries it returned, and Source where they
// came from: live, cache, or catalog.
Repository string
Count int
Source string
}
RepositoryResult is the listing outcome of one repository.
type Row ¶
type Row struct {
// Number is the one-based position of the operation in the report.
Number int
// Operation is the action, for example Publish or Pull.
Operation string
// Icon is the status symbol, and Status the status wording, for example Published.
Icon string
Status string
// Artifact is the resolved reference as a code span, or the requested one when none resolved.
Artifact string
// Repository is the configured repository alias as a code span.
Repository string
// Destination is the primary resolved location as a code span, with credentials and query
// strings removed.
Destination string
// Digest is the shortened primary digest with its type, for example `sha256:0123456789ab…` (resolved).
Digest string
// Size and Duration are human-readable values; empty when the operation has none.
Size string
Duration string
}
Row is one row of the overview table.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is the collector that renders. It buffers the entries recorded during one execution (a CLI command, a workflow, a custom command, or a hook), keeps the final attempt of each logical operation, and on Session.Flush writes one deterministically ordered report through the CI reporter. It is safe for concurrent use.
A session whose reporting surfaces are all disabled ignores every entry, so the gates cost nothing. It never calls a service or repository.
func NewSession ¶
func NewSession(config *schema.AtmosConfiguration, options ...Option) *Session
NewSession returns a session that reports according to the ci.* gates of config. A nil config disables every surface.
func (*Session) Enabled ¶
Enabled reports whether the session reports anything. A disabled session ignores every entry.
func (*Session) Flush ¶
Flush writes the report for everything recorded since the last flush: one summary through the CI reporter and, when output variables are enabled, one set of output variables. It returns the reporting error, if any; the caller logs it and never lets it change the artifact exit status. Flush is meant for a deferred call at the end of an execution, so it runs on failure paths too.
func (*Session) FlushAndLog ¶
func (s *Session) FlushAndLog()
FlushAndLog flushes the session and logs a reporting failure at Warn level. Reporting is best-effort: the failure never reaches the caller, so it cannot change an exit status.
type Signature ¶
type Signature struct {
// Status is signed, verified, unchecked, or failed.
Status string
// Statement says in a sentence what the status does and does not prove.
Statement string
// Subject is the immutable thing the signature covers: its kind and digest.
SubjectKind string
SubjectDigest string
SubjectMediaType string
// Policy is the shortened fingerprint of the verification policy that was applied.
Policy string
// Claims are the verified signer identities.
Claims []Claim
// Evidence lists the signature evidence that was stored or considered.
Evidence []Evidence
}
Signature reports the signature facts of a sign or verify operation. Signed and verified are different claims: signing stores evidence, and only verification against a trust policy authenticates the signer.