app

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultContractPath = "pacto.yaml"

DefaultContractPath is the default filename looked up when no path is given.

Variables

View Source
var ErrArtifactAlreadyExists = errors.New("artifact already exists")

ErrArtifactAlreadyExists is returned when a push is attempted for a reference that already exists in the registry and --force was not specified.

Functions

This section is empty.

Types

type BundlePuller added in v0.0.6

type BundlePuller interface {
	Pull(ctx context.Context, ref string) (*contract.Bundle, error)
	ListTags(ctx context.Context, repo string) ([]string, error)
}

BundlePuller is the subset of oci.BundleStore needed by the fetcher. Defined here to avoid importing pkg/oci from internal/graph.

type DependencyDiff added in v0.9.0

type DependencyDiff struct {
	Name           string        `json:"name"`
	Classification string        `json:"classification"`
	Changes        []diff.Change `json:"changes"`
	SBOMDiff       *sbom.Result  `json:"sbomDiff,omitempty"`
}

DependencyDiff holds the diff result for a single dependency.

type DiffOptions

type DiffOptions struct {
	OldPath      string
	NewPath      string
	OldOverrides override.Overrides
	NewOverrides override.Overrides
}

DiffOptions holds options for the diff command.

type DiffResult

type DiffResult struct {
	OldPath         string           `json:"oldPath"`
	NewPath         string           `json:"newPath"`
	Classification  string           `json:"classification"`
	Changes         []diff.Change    `json:"changes"`
	DependencyDiffs []DependencyDiff `json:"dependencyDiffs,omitempty"`
	GraphDiff       *graph.GraphDiff `json:"graphDiff,omitempty"`
	SBOMDiff        *sbom.Result     `json:"sbomDiff,omitempty"`
}

DiffResult holds the result of the diff command.

type DocOptions added in v0.3.0

type DocOptions struct {
	Path      string
	OutputDir string
	Overrides override.Overrides
}

DocOptions holds options for the doc command.

type DocResult added in v0.3.0

type DocResult struct {
	ServiceName string `json:"serviceName"`
	Markdown    string `json:"markdown"`
	Path        string `json:"path,omitempty"`

	// Bundle contains the contract and filesystem needed for features like
	// the interactive API explorer (--swagger). These are not serialised.
	Bundle *contract.Bundle `json:"-"`
}

DocResult holds the result of the doc command.

type ExplainDependency

type ExplainDependency struct {
	Name          string `json:"name"`
	Ref           string `json:"ref"`
	Required      bool   `json:"required"`
	Compatibility string `json:"compatibility"`
}

ExplainDependency is a simplified dependency summary.

type ExplainInterface

type ExplainInterface struct {
	Name       string `json:"name"`
	Type       string `json:"type"`
	Port       *int   `json:"port,omitempty"`
	Visibility string `json:"visibility,omitempty"`
}

ExplainInterface is a simplified interface summary.

type ExplainOptions

type ExplainOptions struct {
	Path      string
	Overrides override.Overrides
}

ExplainOptions holds options for the explain command.

type ExplainResult

type ExplainResult struct {
	Name         string                 `json:"name"`
	Version      string                 `json:"version"`
	Owner        contract.Owner         `json:"owner,omitempty"`
	PactoVersion string                 `json:"pactoVersion"`
	Runtime      ExplainRuntime         `json:"runtime"`
	Interfaces   []ExplainInterface     `json:"interfaces,omitempty"`
	Dependencies []ExplainDependency    `json:"dependencies,omitempty"`
	Scaling      *contract.Scaling      `json:"scaling,omitempty"`
	Metadata     map[string]interface{} `json:"metadata,omitempty"`
}

ExplainResult holds the result of the explain command.

type ExplainRuntime

type ExplainRuntime struct {
	WorkloadType    string `json:"workloadType"`
	StateType       string `json:"stateType"`
	Scope           string `json:"scope"`
	Durability      string `json:"durability"`
	DataCriticality string `json:"dataCriticality"`
}

ExplainRuntime is a simplified runtime summary.

type GenerateOptions

type GenerateOptions struct {
	Path      string
	OutputDir string
	Plugin    string
	Options   map[string]any
	Overrides override.Overrides
}

GenerateOptions holds options for the generate command.

type GenerateResult

type GenerateResult struct {
	Plugin     string `json:"plugin"`
	OutputDir  string `json:"outputDir"`
	FilesCount int    `json:"filesCount"`
	Message    string `json:"message,omitempty"`
}

GenerateResult holds the result of the generate command.

type GraphOptions

type GraphOptions struct {
	Path              string
	Overrides         override.Overrides
	IncludeReferences bool
	OnlyReferences    bool
}

GraphOptions holds options for the graph command.

type GraphResult

type GraphResult = graph.Result

GraphResult is the result of the graph command.

type InitOptions

type InitOptions struct {
	Name string
}

InitOptions holds options for the init command.

type InitResult

type InitResult struct {
	Dir  string
	Path string
}

InitResult holds the result of the init command.

type PackOptions

type PackOptions struct {
	Path      string
	Output    string
	Overrides override.Overrides
}

PackOptions holds options for the pack command.

type PackResult

type PackResult struct {
	Output  string
	Name    string
	Version string
}

PackResult holds the result of the pack command.

type PluginRunner

type PluginRunner interface {
	Run(ctx context.Context, name string, req plugin.GenerateRequest) (*plugin.GenerateResponse, error)
}

PluginRunner abstracts plugin execution so the app layer does not depend on the concrete subprocess implementation.

type PullOptions

type PullOptions struct {
	Ref    string
	Output string
}

PullOptions holds options for the pull command.

type PullResult

type PullResult struct {
	Ref     string
	Output  string
	Name    string
	Version string
}

PullResult holds the result of the pull command.

type PushOptions

type PushOptions struct {
	Ref       string
	Path      string
	Force     bool
	Overrides override.Overrides
}

PushOptions holds options for the push command.

type PushResult

type PushResult struct {
	Ref     string
	Digest  string
	Name    string
	Version string
}

PushResult holds the result of the push command.

type Service

type Service struct {
	BundleStore  oci.BundleStore
	PluginRunner PluginRunner
}

Service is the application service container. It holds injected dependencies and provides methods for each CLI command.

func NewService

func NewService(store oci.BundleStore, pluginRunner PluginRunner) *Service

NewService creates a new application service with the given dependencies.

func (*Service) Diff

func (s *Service) Diff(ctx context.Context, opts DiffOptions) (*DiffResult, error)

Diff compares two contracts and produces a classified change set.

func (*Service) Doc added in v0.3.0

func (s *Service) Doc(ctx context.Context, opts DocOptions) (*DocResult, error)

Doc generates Markdown documentation from a contract.

func (*Service) Explain

func (s *Service) Explain(ctx context.Context, opts ExplainOptions) (*ExplainResult, error)

Explain produces a human-readable summary of a contract.

func (*Service) Generate

func (s *Service) Generate(ctx context.Context, opts GenerateOptions) (*GenerateResult, error)

Generate invokes a plugin to produce artifacts from a contract.

func (*Service) Graph

func (s *Service) Graph(ctx context.Context, opts GraphOptions) (*GraphResult, error)

Graph resolves the dependency graph for a contract.

func (*Service) Init

func (s *Service) Init(_ context.Context, opts InitOptions) (*InitResult, error)

Init scaffolds a new pacto project directory with the full bundle structure.

func (*Service) Pack

func (s *Service) Pack(_ context.Context, opts PackOptions) (*PackResult, error)

Pack validates a contract bundle and produces a tar.gz archive.

func (*Service) Pull

func (s *Service) Pull(ctx context.Context, opts PullOptions) (*PullResult, error)

Pull fetches a contract bundle from an OCI registry and extracts it to disk.

func (*Service) Push

func (s *Service) Push(ctx context.Context, opts PushOptions) (*PushResult, error)

Push validates a contract bundle, builds an OCI image, and pushes it to a registry.

func (*Service) Validate

func (s *Service) Validate(ctx context.Context, opts ValidateOptions) (*ValidateResult, error)

Validate loads a contract, runs validation, and returns the result.

type ValidateOptions

type ValidateOptions struct {
	Path      string
	Overrides override.Overrides
}

ValidateOptions holds options for the validate command.

type ValidateResult

type ValidateResult struct {
	Path     string
	Valid    bool
	Errors   []contract.ValidationError
	Warnings []contract.ValidationWarning
}

ValidateResult holds the result of the validate command.

Jump to

Keyboard shortcuts

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