Documentation
¶
Overview ¶
Package project holds the state of an ifc7 managed project and defines command line operations that can be performed on it.
Index ¶
- Variables
- func DetectSpecificationType(data []byte) (client.InterfaceType, error)
- func FormatStatusReport(statuses []InterfaceStatus) string
- type AddParams
- type CheckoutParams
- type CommitParams
- type CompareResult
- type Config
- type FetchParams
- type InterfaceStatus
- type InterfaceStatusKind
- type LintResult
- type Manifest
- type ManifestInterface
- type Option
- type Owned
- type Project
- func (p *Project) Add(ctx context.Context, params AddParams) error
- func (p *Project) Checkout(ctx context.Context, params CheckoutParams) ([]string, error)
- func (p *Project) Commit(ctx context.Context, params CommitParams) error
- func (p *Project) DiffOwned(target string) (string, error)
- func (p *Project) Fetch(ctx context.Context, params FetchParams) error
- func (p *Project) FindUntrackedSpecs(root string) ([]ScanCandidate, error)
- func (p *Project) Initialize() error
- func (p *Project) Push(ctx context.Context, params PushParams) ([]string, error)
- func (p *Project) ResolveComparePath(target string) (string, error)
- func (p *Project) ResolveLintTargets(targets []string) ([]string, error)
- func (p *Project) Scan(ctx context.Context, root string) ([]string, error)
- func (p *Project) Status(ctx context.Context) ([]InterfaceStatus, error)
- func (p *Project) Use(ctx context.Context, params UseParams) error
- func (p *Project) Write() error
- type PushParams
- type ScanCandidate
- type UseParams
- type Used
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidConfig = fmt.Errorf("invalid config") ErrRefExists = fmt.Errorf("reference already exists") ErrRefNotFound = fmt.Errorf("reference not found") ErrNameExists = fmt.Errorf("name already exists") ErrPathExists = fmt.Errorf("path already exists") ErrPathRequired = fmt.Errorf("path is required for owned interfaces") ErrNameRequired = fmt.Errorf("name is required for owned interfaces") ErrNameNotFound = fmt.Errorf("name not found") )
var ( ErrProjectExists = fmt.Errorf("project already exists") ErrInvalidRef = fmt.Errorf("invalid reference") ErrInvalidSpecification = fmt.Errorf("invalid interface specification") )
var (
ErrInvalidManifest = fmt.Errorf("invalid manifest")
)
Functions ¶
func DetectSpecificationType ¶
func DetectSpecificationType(data []byte) (client.InterfaceType, error)
DetectSpecificationType reports whether data is a valid OpenAPI or JSON Schema document. OpenAPI is checked first so OpenAPI documents are not classified as JSON Schema.
func FormatStatusReport ¶
func FormatStatusReport(statuses []InterfaceStatus) string
FormatStatusReport renders a human-readable status report.
Types ¶
type CheckoutParams ¶
type CheckoutParams struct {
// Targets are owned interface names or slugs. Empty means all owned interfaces.
Targets []string
// Force overwrites local files that differ from the manifest latest revision.
Force bool
}
CheckoutParams holds parameters for Checkout.
type CommitParams ¶
type CommitParams struct {
Ref string
}
CommitParams holds parameters that can be passed to the Commit method
type CompareResult ¶
type CompareResult struct {
Before string
After string
PluginID string
Output contract.CompareOutput
}
CompareResult is the outcome of running a compare plugin on two specifications.
func CompareFiles ¶
func CompareFiles(beforePath, afterPath string) (CompareResult, error)
CompareFiles runs the default change detector on two specification files.
type Config ¶
Config represents a project configuration file This file holds references to interfaces that are tracked by the project.
func ReadConfig ¶
ReadConfig reads the project configuration file from disk
type FetchParams ¶
type FetchParams struct {
Ref string
}
FetchParams holds parameters that can be passed to the Fetch method
type InterfaceStatus ¶
type InterfaceStatus struct {
Name string
Slug string
Path string
Ref string
Kind InterfaceStatusKind
Detail string
}
InterfaceStatus is the working-tree status of one owned interface.
type InterfaceStatusKind ¶
type InterfaceStatusKind string
InterfaceStatusKind describes how an owned interface compares to the local manifest.
const ( StatusClean InterfaceStatusKind = "clean" StatusModified InterfaceStatusKind = "modified" StatusNew InterfaceStatusKind = "new" StatusMissing InterfaceStatusKind = "missing" StatusError InterfaceStatusKind = "error" )
type LintResult ¶
type LintResult struct {
Target string
PluginID string
Output contract.LintOutput
}
LintResult is the outcome of running a lint plugin on a local specification.
func LintFile ¶
func LintFile(path string) (LintResult, error)
LintFile runs the default linter for a specification file.
type Manifest ¶
type Manifest struct {
// Interfaces maps canonicalUrl (e.g. "/i/@user/slug") to interface data.
// Before an interface is created on the server it may be temporarily keyed by
// its local name (or interface ID, for legacy manifests).
Interfaces map[string]*ManifestInterface `json:"interfaces"`
}
Manifest is the structure of the local project manifest file (manifest.json) This holds local copies and version history of all the interfaces tracked by the project.
func ReadManifest ¶
ReadManifest reads the manifest from a file
type ManifestInterface ¶
type ManifestInterface struct {
client.Interface
Revisions map[string]*client.InterfaceRevision `json:"revisions"` // map of revision ID to revision data
Releases map[string]*client.InterfaceRelease `json:"releases"` // map of release version to release data
}
ManifestInterface holds the state of a single interface in the project manifest.
type Owned ¶
type Owned struct {
Name string `json:"name" yaml:"name"`
Ref string `json:"ref" yaml:"ref"`
Path string `json:"path" yaml:"path"`
}
Owned holds a reference to a local interface that is managed by the project.
type Project ¶
type Project struct {
// contains filtered or unexported fields
}
Project holds the state of an ifc7 managed project
func (*Project) Checkout ¶
Checkout writes owned interface working-tree files from the latest revision in the local manifest. It does not contact the remote hub.
Missing files are created. Files that already match the manifest are left unchanged. Files with local modifications are skipped unless Force is set.
func (*Project) Commit ¶
func (p *Project) Commit(ctx context.Context, params CommitParams) error
Commit adds local changes to owned interfaces to the manifest
func (*Project) DiffOwned ¶
DiffOwned returns a unified diff of an owned interface's working-tree file against the latest revision stored in the local manifest. An empty string means there are no differences. target may be an owned interface name or its manifest slug. It does not contact the remote hub.
func (*Project) Fetch ¶
func (p *Project) Fetch(ctx context.Context, params FetchParams) error
Fetch fetches remote copies of interfaces tracked by the project
func (*Project) FindUntrackedSpecs ¶
func (p *Project) FindUntrackedSpecs(root string) ([]ScanCandidate, error)
FindUntrackedSpecs walks root for valid OpenAPI / JSON Schema files not already tracked as owned interfaces in ifc.yaml. Returned paths are relative to the current working directory so they can be passed directly to Add.
func (*Project) Initialize ¶
Initialize creates the necessary folders and files for a project if they do not exist in the current folder
func (*Project) Push ¶
Push pushes local changes to the remote server. It returns user-facing status messages.
func (*Project) ResolveComparePath ¶
ResolveComparePath resolves a CLI target (owned name or file path) to a file path.
func (*Project) ResolveLintTargets ¶
ResolveLintTargets resolves CLI targets to file paths. Empty targets means all owned interfaces. Named targets match owned names or file paths.
func (*Project) Scan ¶
Scan recursively searches root for valid OpenAPI / JSON Schema documents that are not already listed in ifc.yaml, presents them in a TUI, and adds selected files using the same logic as Add. root defaults to the current directory.
func (*Project) Status ¶
func (p *Project) Status(ctx context.Context) ([]InterfaceStatus, error)
Status compares each owned interface on disk against the local manifest. It does not contact the remote hub.
type PushParams ¶
type PushParams struct {
Name string
}
PushParams holds parameters that can be passed to the Push method
type ScanCandidate ¶
type ScanCandidate struct {
Path string
Type client.InterfaceType
}
ScanCandidate is an untracked OpenAPI or JSON Schema file discovered by Scan.