optic

package
v4.27.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package optic supports linting OpenAPI specs with Optic CI and Sweater Comb.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// ChangeDate is when the proposed change would occur.
	ChangeDate string `json:"changeDate"`

	// ChangeResource is the proposed change resource name.
	ChangeResource string `json:"changeResource"`

	// ChangeVersion is the proposed change version.
	ChangeVersion Version `json:"changeVersion"`

	// ResourceVersions describes other resource version releases.
	ResourceVersions ResourceVersionReleases `json:"resourceVersions,omitempty"`
}

Context provides Optic with external information needed in order to process API versioning lifecycle rules. For example, lifecycle rules need to know when a change is occurring, and what other versions have deprecated the OpenAPI spec version being evaluated.

type Optic

type Optic struct {
	// contains filtered or unexported fields
}

Optic runs a Docker image containing Optic CI and built-in rules.

func New

func New(ctx context.Context, cfg *config.OpticCILinter) (*Optic, error)

New returns a new Optic instance configured to run the given OCI image and file sources. File sources may be a Git "treeish" (commit hash or anything that resolves to one such as a branch or tag) where the current working directory is a cloned git repository. If `from` is empty string, comparison assumes all changes are new "from scratch" additions. If `to` is empty string, spec files are assumed to be relative to the current working directory.

Temporary resources may be created by the linter, which are reclaimed when the context cancels.

func (*Optic) Match

func (o *Optic) Match(rcConfig *config.ResourceSet) ([]string, error)

Match implements linter.Linter.

func (*Optic) Run

func (o *Optic) Run(ctx context.Context, root string, paths ...string) error

Run runs Optic CI on the given paths. Linting output is written to standard output by Optic CI. Returns an error when lint fails configured rules.

func (*Optic) WithOverride

func (*Optic) WithOverride(ctx context.Context, override *config.Linter) (linter.Linter, error)

WithOverride implements linter.Linter.

type Release

type Release struct {
	// DeprecatedBy indicates the other release version that deprecates this
	// release.
	DeprecatedBy Version `json:"deprecatedBy"`
}

Release describes a single resource-version-stability release.

type ResourceVersionReleases

type ResourceVersionReleases map[string]VersionStabilityReleases

ResourceVersionReleases describes resource version releases.

type StabilityReleases

type StabilityReleases map[string]Release

StabilityReleases describes stability releases.

type Version

type Version struct {
	Date      string `json:"date"`
	Stability string `json:"stability,omitempty"`
}

Version describes an API resource version, a date and a stability. Stability is assumed to be GA if not specified.

type VersionStabilityReleases

type VersionStabilityReleases map[string]StabilityReleases

VersionStabilityReleases describes version releases.

Jump to

Keyboard shortcuts

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