Documentation
¶
Overview ¶
Package cicontext reads what the CI system says about a run.
Everything here is a claim. The CI environment is writable by whatever ran earlier in the job, so a row that carries these values stays unverified and unattributed until a server has checked them against the job's OIDC token.
Index ¶
Constants ¶
const ResourceAttributesVariable = "OTEL_RESOURCE_ATTRIBUTES"
ResourceAttributesVariable is the variable OpenTelemetry SDKs read.
Variables ¶
var ErrNoEventFile = errors.New("GITHUB_EVENT_PATH is not set")
ErrNoEventFile is why a run on GitHub Actions has no event to read.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// Repository is host and path in lower case, the form of costroid/repo.
Repository string
// RepositoryURL is the repository's address, for vcs.repository.url.full.
RepositoryURL string
PullRequest string
Head string
Base string
Run string
Task string
// Visibility is who can read the repository, as the CI system states it:
// one of focus.VisibilityPublic, focus.VisibilityPrivate and
// focus.VisibilityInternal, or empty when the system did not state it.
Visibility string
}
Context is one CI run's stated facts. A zero Context means no CI system was found, and adds nothing to a row or to the agent's environment.
func Read ¶
Read reads the run from the CI system's variables. An error means the system was found and its event could not be read: the Context still holds what the variables said, without a head that might name a merge commit.
func (Context) ResourceAttributes ¶
ResourceAttributes merges the run's vcs.* and cicd.* attributes into the value of OTEL_RESOURCE_ATTRIBUTES the job already set, and returns the result. Costroid's value replaces one the job set under the same key. Empty means there is nothing to set.
type Event ¶
type Event struct {
// Issue is set on issue_comment. Its pull_request field is set when the
// issue is a pull request.
Issue *struct {
Number int `json:"number"`
PullRequest *struct{} `json:"pull_request"`
} `json:"issue"`
PullRequest *struct {
Number int `json:"number"`
Head struct {
SHA string `json:"sha"`
} `json:"head"`
Base struct {
SHA string `json:"sha"`
} `json:"base"`
} `json:"pull_request"`
// Repository is the repository the workflow runs in. It is read only for
// its visibility, and a field of a shape Costroid does not expect states
// none rather than making the rest of the event unreadable.
Repository json.RawMessage `json:"repository"`
}
Event is the part of a GitHub event file Costroid reads.