Documentation
¶
Index ¶
- Constants
- Variables
- type BundlePuller
- type DependencyDiff
- type DiffOptions
- type DiffResult
- type DocOptions
- type DocResult
- type ExplainDependency
- type ExplainInterface
- type ExplainOptions
- type ExplainResult
- type ExplainRuntime
- type GenerateOptions
- type GenerateResult
- type GraphOptions
- type GraphResult
- type InitOptions
- type InitResult
- type PackOptions
- type PackResult
- type PluginRunner
- type PullOptions
- type PullResult
- type PushOptions
- type PushResult
- type Service
- func (s *Service) Diff(ctx context.Context, opts DiffOptions) (*DiffResult, error)
- func (s *Service) Doc(ctx context.Context, opts DocOptions) (*DocResult, error)
- func (s *Service) Explain(ctx context.Context, opts ExplainOptions) (*ExplainResult, error)
- func (s *Service) Generate(ctx context.Context, opts GenerateOptions) (*GenerateResult, error)
- func (s *Service) Graph(ctx context.Context, opts GraphOptions) (*GraphResult, error)
- func (s *Service) Init(_ context.Context, opts InitOptions) (*InitResult, error)
- func (s *Service) Pack(_ context.Context, opts PackOptions) (*PackResult, error)
- func (s *Service) Pull(ctx context.Context, opts PullOptions) (*PullResult, error)
- func (s *Service) Push(ctx context.Context, opts PushOptions) (*PushResult, error)
- func (s *Service) Validate(ctx context.Context, opts ValidateOptions) (*ValidateResult, error)
- type ValidateOptions
- type ValidateResult
Constants ¶
const DefaultContractPath = "pacto.yaml"
DefaultContractPath is the default filename looked up when no path is given.
Variables ¶
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
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 ¶
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 InitOptions ¶
type InitOptions struct {
Name string
}
InitOptions holds options for the init command.
type InitResult ¶
InitResult holds the result of the init command.
type PackOptions ¶
PackOptions holds options for the pack command.
type PackResult ¶
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 ¶
PullOptions holds options for the pull command.
type PullResult ¶
PullResult holds the result of the pull command.
type PushOptions ¶
PushOptions holds options for the push command.
type PushResult ¶
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) 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 ¶
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.