Documentation
¶
Overview ¶
Package usecase holds Sauron's use cases and the actions they compose.
Index ¶
- func NewFxOptions() fx.Option
- type Action
- type AddRegistryRequest
- type AddRegistryUseCase
- type AddRegistryUseCaseParams
- type CatalogueKind
- type DeleteArtifactsByRegistryResponse
- type DeleteRegistryRequest
- type DeleteRegistryUseCase
- type DeleteRegistryUseCaseParams
- type DescribeRegistryRequest
- type DescribeRegistryUseCase
- type DescribeRegistryUseCaseParams
- type Error
- type ListCatalogueRequest
- type ListCatalogueUseCase
- type ListCatalogueUseCaseParams
- type ListRegistriesRequest
- type ListRegistriesUseCase
- type ListRegistriesUseCaseParams
- type MockBasedOpenRegistry
- type OpenRegistry
- type OpenRegistryAction
- type OpenRegistryActionParams
- type Request
- type Type
- type UninstallByRegistryAction
- type UninstallByRegistryActionParams
- type UseCase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
Action is a stateless, composable step a use case runs: executed with a context and an input R, it returns a *P product or a classified *Error.
type AddRegistryRequest ¶
type AddRegistryRequest struct {
Name string
URI string
Transport string
Ref string
Username string
Password string
SSHKey string
SkipTLSVerify bool
CACert string
ClientCert string
ClientKey string
Timeout time.Duration
// contains filtered or unexported fields
}
AddRegistryRequest is the per-invocation input for registering a source.
func NewAddRegistryRequest ¶
func NewAddRegistryRequest(ctx context.Context, out io.Writer) *AddRegistryRequest
NewAddRegistryRequest builds a request bound to ctx and writing to out.
type AddRegistryUseCase ¶
type AddRegistryUseCase struct {
// contains filtered or unexported fields
}
AddRegistryUseCase registers a validated, reachable source.
func NewAddRegistryUseCase ¶
func NewAddRegistryUseCase(params AddRegistryUseCaseParams) *AddRegistryUseCase
NewAddRegistryUseCase builds the use case from the injected adapters and collaborators.
func (*AddRegistryUseCase) Execute ¶
func (uc *AddRegistryUseCase) Execute(request *AddRegistryRequest) error
Execute runs the ordered registration pipeline, returning a *Error on the first failing step.
type AddRegistryUseCaseParams ¶
type AddRegistryUseCaseParams struct {
fx.In
Filesystem extension.Registry `name:"registry.filesystem"`
Git extension.Registry `name:"registry.git"`
HTTP extension.Registry `name:"registry.http"`
Open OpenRegistry
Registries storage.RegistriesStore
Logger *zap.Logger
}
AddRegistryUseCaseParams injects the adapters and collaborators the use case composes.
type CatalogueKind ¶
type CatalogueKind string
CatalogueKind is the kind of artifact a catalogue listing browses; it fixes the source root listed and the projection applied.
const ( // CatalogueSkill browses the skills a registry offers under .skills. CatalogueSkill CatalogueKind = "skill" // CatalogueAgent browses the agents a registry offers under .agents. CatalogueAgent CatalogueKind = "agent" // CataloguePersona browses the personas a registry offers under .personas. CataloguePersona CatalogueKind = "persona" )
The kinds a catalogue listing can browse.
type DeleteArtifactsByRegistryResponse ¶
DeleteArtifactsByRegistryResponse is the set of artifacts a cascade uninstall removes, grouped by kind. It is the value both delete-registry and uninstall report.
func (DeleteArtifactsByRegistryResponse) Total ¶
func (p DeleteArtifactsByRegistryResponse) Total() int
Total is the number of artifacts the plan removes across every kind.
type DeleteRegistryRequest ¶
type DeleteRegistryRequest struct {
Name string
DryRun bool
// contains filtered or unexported fields
}
DeleteRegistryRequest is the per-invocation input for deleting a source.
func NewDeleteRegistryRequest ¶
func NewDeleteRegistryRequest(ctx context.Context, out io.Writer) *DeleteRegistryRequest
NewDeleteRegistryRequest builds a request bound to ctx and writing to out.
type DeleteRegistryUseCase ¶
type DeleteRegistryUseCase struct {
// contains filtered or unexported fields
}
DeleteRegistryUseCase unregisters a source and cascade-uninstalls its artifacts.
func NewDeleteRegistryUseCase ¶
func NewDeleteRegistryUseCase(params DeleteRegistryUseCaseParams) *DeleteRegistryUseCase
NewDeleteRegistryUseCase builds the use case from the injected collaborators.
func (*DeleteRegistryUseCase) Execute ¶
func (uc *DeleteRegistryUseCase) Execute(request *DeleteRegistryRequest) error
Execute runs the find → cascade → dry-run → remove → report pipeline, returning a *Error on the first failing step. A registry that does not exist is a success.
type DeleteRegistryUseCaseParams ¶
type DeleteRegistryUseCaseParams struct {
fx.In
Registries storage.RegistriesStore
Cascade *UninstallByRegistryAction
Logger *zap.Logger
}
DeleteRegistryUseCaseParams injects the collaborators the use case composes.
type DescribeRegistryRequest ¶
type DescribeRegistryRequest struct {
Name string
Fields []string
// contains filtered or unexported fields
}
DescribeRegistryRequest is the per-invocation input for describing a registry.
func NewDescribeRegistryRequest ¶
func NewDescribeRegistryRequest(ctx context.Context, out io.Writer) *DescribeRegistryRequest
NewDescribeRegistryRequest builds a request bound to ctx and writing to out.
type DescribeRegistryUseCase ¶
type DescribeRegistryUseCase struct {
// contains filtered or unexported fields
}
DescribeRegistryUseCase reads one registry and renders its full detail.
func NewDescribeRegistryUseCase ¶
func NewDescribeRegistryUseCase(params DescribeRegistryUseCaseParams) *DescribeRegistryUseCase
NewDescribeRegistryUseCase builds the use case from the injected collaborators.
func (*DescribeRegistryUseCase) Execute ¶
func (uc *DescribeRegistryUseCase) Execute(request *DescribeRegistryRequest) error
Execute runs the find → not-found → project → render pipeline, returning a *Error on the first failing step.
type DescribeRegistryUseCaseParams ¶
type DescribeRegistryUseCaseParams struct {
fx.In
Registries storage.RegistriesStore
Logger *zap.Logger
}
DescribeRegistryUseCaseParams injects the collaborators the use case composes.
type Error ¶
Error is a classified use-case failure: Type buckets it, Reason explains it.
func NewConflictError ¶
NewConflictError reports a collision with existing state.
func NewIOError ¶
NewIOError reports a failure of the underlying storage.
func NewNotFoundError ¶
NewNotFoundError reports a named resource that does not exist.
func NewUnreachableError ¶
NewUnreachableError reports a source that could not be reached or read.
func NewUsageError ¶
NewUsageError reports a correctable caller mistake.
type ListCatalogueRequest ¶
type ListCatalogueRequest struct {
Kind CatalogueKind
Registry string
Search string
Sort string
Order string
Page int64
Limit int64
// contains filtered or unexported fields
}
ListCatalogueRequest is the per-invocation input for browsing a registry's catalogue of one kind.
func NewListCatalogueRequest ¶
func NewListCatalogueRequest(ctx context.Context, out io.Writer) *ListCatalogueRequest
NewListCatalogueRequest builds a request bound to ctx and writing to out.
type ListCatalogueUseCase ¶
type ListCatalogueUseCase struct {
// contains filtered or unexported fields
}
ListCatalogueUseCase resolves a registry, opens its source live, and renders the artifacts of the selected kind followed by a paging line.
func NewListCatalogueUseCase ¶
func NewListCatalogueUseCase(params ListCatalogueUseCaseParams) *ListCatalogueUseCase
NewListCatalogueUseCase builds the use case from the injected collaborators.
func (*ListCatalogueUseCase) Execute ¶
func (uc *ListCatalogueUseCase) Execute(request *ListCatalogueRequest) error
Execute runs the validate → find → open → list → project → render pipeline, returning a classified *Error on the first failing step.
type ListCatalogueUseCaseParams ¶
type ListCatalogueUseCaseParams struct {
fx.In
Registries storage.RegistriesStore
Open OpenRegistry
Logger *zap.Logger
}
ListCatalogueUseCaseParams injects the collaborators the use case composes.
type ListRegistriesRequest ¶
type ListRegistriesRequest struct {
Search string
Fields []string
Sort string
Order string
// contains filtered or unexported fields
}
ListRegistriesRequest is the per-invocation input for the registry listing.
func NewListRegistriesRequest ¶
func NewListRegistriesRequest(ctx context.Context, out io.Writer) *ListRegistriesRequest
NewListRegistriesRequest builds a request bound to ctx and writing to out.
type ListRegistriesUseCase ¶
type ListRegistriesUseCase struct {
// contains filtered or unexported fields
}
ListRegistriesUseCase reads, filters, sorts, and renders the registry listing.
func NewListRegistriesUseCase ¶
func NewListRegistriesUseCase(params ListRegistriesUseCaseParams) *ListRegistriesUseCase
NewListRegistriesUseCase builds the use case from the injected collaborators.
func (*ListRegistriesUseCase) Execute ¶
func (uc *ListRegistriesUseCase) Execute(request *ListRegistriesRequest) error
Execute runs the read → filter → sort → project → render pipeline, returning a *Error on the first failing step.
type ListRegistriesUseCaseParams ¶
type ListRegistriesUseCaseParams struct {
fx.In
Registries storage.RegistriesStore
Logger *zap.Logger
}
ListRegistriesUseCaseParams injects the collaborators the use case composes.
type MockBasedOpenRegistry ¶
MockBasedOpenRegistry is a testify mock implementing OpenRegistry.
func (*MockBasedOpenRegistry) Execute ¶
func (m *MockBasedOpenRegistry) Execute(ctx context.Context, registry types.Registry) (source.FileSystem, error)
Execute records the call and returns the configured values.
type OpenRegistry ¶
type OpenRegistry interface {
// Execute opens registry's source over its transport, returning the
// read-only file system, or a classified *Error.
Execute(ctx context.Context, registry types.Registry) (source.FileSystem, error)
}
OpenRegistry opens a stored registry's source. It is the seam downstream use cases compose and tests mock.
type OpenRegistryAction ¶
type OpenRegistryAction struct {
// contains filtered or unexported fields
}
OpenRegistryAction opens a stored registry's source: it selects the transport adapter, resolves ${env:VAR} credential references, builds the extension option set from the registry spec, and opens the source. It is the shared open-a-stored-registry step the catalogue, install, and listing use cases compose. An open failure classifies as unreachable.
func NewOpenRegistryAction ¶
func NewOpenRegistryAction(params OpenRegistryActionParams) *OpenRegistryAction
NewOpenRegistryAction builds the action from the injected adapters and collaborators.
func (*OpenRegistryAction) Execute ¶
func (a *OpenRegistryAction) Execute(ctx context.Context, registry types.Registry) (source.FileSystem, error)
Execute opens registry's source over its transport, returning the read-only file system. It returns a usage *Error for an unknown transport, an unreachable *Error for an unset credential reference or a failed open.
type OpenRegistryActionParams ¶
type OpenRegistryActionParams struct {
fx.In
Filesystem extension.Registry `name:"registry.filesystem"`
Git extension.Registry `name:"registry.git"`
HTTP extension.Registry `name:"registry.http"`
Logger *zap.Logger
}
OpenRegistryActionParams injects the named transport adapters and collaborators the action composes.
type Request ¶
type Request interface {
context.Context
// Out returns the writer the command's output goes to.
Out() io.Writer
}
Request is the per-invocation context object: a context.Context that also exposes the command's output writer.
type Type ¶
type Type string
Type classifies a use-case failure so callers can map it to an exit code or presentation without inspecting the reason text.
const ( // TypeUsage marks a caller mistake that can be corrected by changing input. TypeUsage Type = "usage" // TypeConflict marks a request that collides with existing state. TypeConflict Type = "conflict" // TypeUnreachable marks a source that could not be reached or read. TypeUnreachable Type = "unreachable" // TypeIO marks a failure of the underlying storage. TypeIO Type = "io" // TypeNotFound marks a named resource that does not exist. TypeNotFound Type = "not_found" )
The classes a use case attaches to a failure.
type UninstallByRegistryAction ¶
type UninstallByRegistryAction struct {
// contains filtered or unexported fields
}
UninstallByRegistryAction removes every tracked artifact sourced from a registry. It is the shared cleaning step both delete-registry and uninstall compose.
func NewUninstallByRegistryAction ¶
func NewUninstallByRegistryAction(params UninstallByRegistryActionParams) *UninstallByRegistryAction
NewUninstallByRegistryAction builds the action from the injected collaborators.
func (*UninstallByRegistryAction) Execute ¶
func (a *UninstallByRegistryAction) Execute(_ context.Context, _ string) (*DeleteArtifactsByRegistryResponse, error)
Execute returns the plan of artifacts removed for the registry.
0007 owns the real body: the track store read, the per-artifact provider removal, and the track.yaml rewrite. Until then this is a no-op — it removes nothing and returns an empty plan, so an applied delete reports zero artifacts removed.
type UninstallByRegistryActionParams ¶
UninstallByRegistryActionParams injects the collaborators the action composes.