Documentation
¶
Overview ¶
Package resource loads author manifests, validates self-contained resources, and compares output against expectations.
Index ¶
- func MatchOutput(actual, expected []byte, mode MatchMode) bool
- type ArtifactInput
- type ArtifactOutput
- type Artifacts
- type Expected
- type ImageBuild
- type Job
- type Limits
- type Manifest
- type MatchMode
- type Metadata
- type OutputExpectation
- type Preset
- type Resource
- type RuntimePath
- type SandboxImage
- type Step
- type Version
- type Workflow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchOutput ¶ added in v1.1.0
MatchOutput compares output using the given mode without modifying inputs. Exact compares bytes; easy compares whitespace-separated tokens on each line; sorted additionally ignores token order within each line, preserving duplicates. Easy and sorted recognize LF, CRLF and CR, and remove exactly one final newline. Invalid UTF-8 bytes are preserved and compared. An unknown mode (including the empty string) returns false.
Types ¶
type ArtifactInput ¶
type ArtifactInput struct {
FromJob string `json:"from-job"`
Name string `json:"name" validate:"identifier"`
Path RuntimePath `json:"path" validate:"validateFn"`
}
type ArtifactOutput ¶
type ArtifactOutput struct {
Name string `json:"name" validate:"identifier"`
Path RuntimePath `json:"path" validate:"validateFn"`
Visibility string `json:"visibility" validate:"oneof=public private"`
ContentType string `` /* 156-byte string literal not displayed */
}
type Artifacts ¶
type Artifacts struct {
Inputs []ArtifactInput `json:"inputs" validate:"unique=Path,dive"`
Outputs []ArtifactOutput `json:"outputs" validate:"unique=Name,unique=Path,dive"`
}
type Expected ¶
type Expected struct {
ExitCode *int `json:"exit-code" validate:"omitnil,gte=0,lte=255"` // nil means the exit code is not checked.
Stdout *OutputExpectation `json:"stdout" validate:"omitnil"`
Stderr *OutputExpectation `json:"stderr" validate:"omitnil"`
}
type ImageBuild ¶
type ImageBuild struct {
Context string `json:"context"`
Dockerfile string `json:"dockerfile"`
Image string `json:"image"`
Platforms []string `json:"platforms"`
}
ImageBuild holds CI settings; build files are not read by this package.
type Job ¶
type Job struct {
Name string `json:"name"`
Visibility string `json:"visibility" validate:"oneof=public private"`
Depends []string `json:"depends" validate:"unique"`
SandboxImage SandboxImage `json:"sandbox-image" validate:"validateFn"`
Limits Limits `json:"limits"`
Artifacts *Artifacts `json:"artifacts" validate:"omitnil"`
Steps []Step `json:"steps" validate:"min=1,dive"`
}
type Limits ¶
type Limits struct {
CPU int `json:"cpu" validate:"gte=1,lte=2"`
Memory int64 `json:"memory" validate:"gt=0,lte=536870912"`
PIDs int `json:"pids" validate:"gte=1,lte=256"`
StdoutSize int64 `json:"stdout-size" validate:"gt=0,lte=32768"`
StderrSize int64 `json:"stderr-size" validate:"gt=0,lte=32768"`
WorkspaceSize int64 `json:"workspace-size" validate:"gt=0,lte=134217728"`
ArtifactSize int64 `json:"artifact-size" validate:"gt=0,lte=1048576"`
}
type Manifest ¶
type Manifest struct {
Resources []Resource `json:"resources"`
SandboxImages map[string]ImageBuild `json:"sandbox-images"`
}
Manifest contains resolved resources in registration order and CI image build settings.
func LoadManifest ¶
LoadManifest validates manifest.yaml and resolves every registered resource. The caller must keep the input directory stable throughout the call.
type OutputExpectation ¶
type Preset ¶
type Preset struct {
Content []byte `json:"content"`
Executable bool `json:"executable"`
Path RuntimePath `json:"path" validate:"validateFn"`
}
type Resource ¶
type Resource struct {
Metadata Metadata `json:"metadata"`
RequiredFiles []string `json:"required-files" validate:"dive,notblank"`
Workflows map[string]Workflow `json:"workflows" validate:"min=1,dive,keys,identifier,endkeys"`
}
Resource contains resolved data and retains neither source paths nor file handles. Marshal it with encoding/json to save or distribute it.
func DecodeResource ¶
DecodeResource restores one resolved JSON resource, rejecting unknown fields and invalid runtime data. It does not read files or apply authoring defaults. Missing or null required-files is restored as an empty array.
type RuntimePath ¶ added in v1.5.0
type RuntimePath string
RuntimePath is a POSIX relative path, independent of the local filesystem.
func (RuntimePath) Validate ¶ added in v1.5.0
func (p RuntimePath) Validate() error
type SandboxImage ¶ added in v1.5.0
type SandboxImage string
SandboxImage is a fully qualified container image with a tag or digest.
func (SandboxImage) Validate ¶ added in v1.5.0
func (s SandboxImage) Validate() error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
resource-ci
command
resource-ci runs this repository's GitHub validation and publication tasks.
|
resource-ci runs this repository's GitHub validation and publication tasks. |
|
resource-spec
command
|
|
|
internal
|
|
|
publishing
Package publishing implements this repository's GitHub publication workflow.
|
Package publishing implements this repository's GitHub publication workflow. |