Documentation
¶
Index ¶
- Variables
- func EvaluateTaskCompatibility(task coretask.UntypedTask, currentType *InspectionType) (bool, string)
- func InspectRegistry(server *InspectionTaskServer) (*apiv1.GetInspectionTaskRegistryResponse, error)
- func InspectResolution(server *InspectionTaskServer, inspectionTypeID string, ...) (*apiv1.ResolveInspectionTaskGraphResponse, error)
- func InspectRunTaskGraph(server *InspectionTaskServer, inspectionID string) (*apiv1.InspectionRunTaskGraphSnapshot, error)
- type FeatureListItem
- type InspectionDryRunResult
- type InspectionInterceptor
- type InspectionRegistrationFunc
- type InspectionRunResult
- type InspectionTaskRegistry
- type InspectionTaskRunner
- func (i *InspectionTaskRunner) AddInterceptors(interceptors ...InspectionInterceptor)
- func (i *InspectionTaskRunner) Cancel() error
- func (i *InspectionTaskRunner) DryRun(ctx context.Context, req *inspectioncore.InspectionRequest) (*InspectionDryRunResult, error)
- func (i *InspectionTaskRunner) FeatureList() ([]FeatureListItem, error)
- func (i *InspectionTaskRunner) GetCurrentMetadata() (*typedmap.ReadonlyTypedMap, error)
- func (i *InspectionTaskRunner) Metadata() (map[string]any, error)
- func (i *InspectionTaskRunner) ResolveTaskGraph() (*coretask.TaskSet, error)
- func (i *InspectionTaskRunner) Result() (*InspectionRunResult, error)
- func (i *InspectionTaskRunner) Run(ctx context.Context, req *inspectioncore.InspectionRequest) error
- func (i *InspectionTaskRunner) SetFeatureList(featureList []string) error
- func (i *InspectionTaskRunner) SetInspectionType(inspectionType string) error
- func (i *InspectionTaskRunner) Started() bool
- func (i *InspectionTaskRunner) TakeRunTaskGraphSnapshot() (*RunTaskGraphSnapshot, error)
- func (i *InspectionTaskRunner) UpdateFeatureMap(featureMap map[string]bool) error
- func (i *InspectionTaskRunner) Wait() <-chan struct{}
- type InspectionTaskServer
- func (s *InspectionTaskServer) AddInspectionInterceptor(interceptor InspectionInterceptor)
- func (s *InspectionTaskServer) AddInspectionType(newInspectionType InspectionType) error
- func (s *InspectionTaskServer) AddRunContextOption(option RunContextOption)
- func (s *InspectionTaskServer) AddTask(task coretask.UntypedTask) error
- func (s *InspectionTaskServer) CreateInspection(inspectionType string) (string, error)
- func (s *InspectionTaskServer) GetAllInspectionTypes() []*InspectionType
- func (s *InspectionTaskServer) GetAllRegisteredTasks() []coretask.UntypedTask
- func (s *InspectionTaskServer) GetAllRunners() []*InspectionTaskRunner
- func (s *InspectionTaskServer) GetInspection(inspectionID string) *InspectionTaskRunner
- func (s *InspectionTaskServer) GetInspectionType(inspectionTypeId string) *InspectionType
- func (s *InspectionTaskServer) IOConfig() *inspectioncore.IOConfig
- func (s *InspectionTaskServer) RegisterImportedInspection(id string, store inspectioncore.Store, metadata *typedmap.ReadonlyTypedMap) *InspectionTaskRunner
- type InspectionType
- type RunContextOption
- type RunTaskGraphSnapshot
Constants ¶
This section is empty.
Variables ¶
var DefaultFeatureTaskOrder = 1000000
DefaultFeatureTaskOrder is a number used for sorting feature task when the task has no LabelKeyFeatureTaskOrder label.
var ErrInspectionNotFound = errors.New("inspection not found")
ErrInspectionNotFound is returned when the requested inspection ID is not registered on the server.
var ErrInspectionTypeNotFound = errors.New("inspection type not found")
ErrInspectionTypeNotFound indicates that the requested inspection type is not registered on the server.
var ErrRunTaskGraphNotStarted = errors.New("inspection has no observable task graph execution")
ErrRunTaskGraphNotStarted is returned when an inspection has no observable task graph execution yet. Inspections restored from a KHI file also fall into this case because they never execute a task graph.
Functions ¶
func EvaluateTaskCompatibility ¶ added in v0.59.0
func EvaluateTaskCompatibility(task coretask.UntypedTask, currentType *InspectionType) (bool, string)
EvaluateTaskCompatibility checks whether a task is compatible with the given inspection type and returns the compatibility status along with an explanatory diagnosis.
func InspectRegistry ¶ added in v0.59.0
func InspectRegistry(server *InspectionTaskServer) (*apiv1.GetInspectionTaskRegistryResponse, error)
InspectRegistry inspects the given InspectionTaskServer and returns all registered tasks grouped by reference identifier, as well as all registered inspection types.
func InspectResolution ¶ added in v0.59.0
func InspectResolution( server *InspectionTaskServer, inspectionTypeID string, featureOverrides map[string]bool, ) (*apiv1.ResolveInspectionTaskGraphResponse, error)
InspectResolution evaluates task filtering against an inspection type and feature configuration, and resolves the execution DAG.
func InspectRunTaskGraph ¶ added in v0.59.0
func InspectRunTaskGraph(server *InspectionTaskServer, inspectionID string) (*apiv1.InspectionRunTaskGraphSnapshot, error)
InspectRunTaskGraph returns the execution graph of an inspection run together with the current phase of each task, so clients can visualize how far the run has progressed.
Types ¶
type FeatureListItem ¶
type InspectionDryRunResult ¶
type InspectionDryRunResult struct {
Metadata interface{} `json:"metadata"`
}
type InspectionInterceptor ¶ added in v0.50.0
type InspectionInterceptor func(ctx context.Context, req *inspectioncore.InspectionRequest, next func(context.Context) error) error
InspectionInterceptor is a function that can intercept the execution of an inspection task.
func InspectionTaskLogger ¶ added in v0.50.0
type InspectionRegistrationFunc ¶
type InspectionRegistrationFunc = func(registry InspectionTaskRegistry) error
type InspectionRunResult ¶
type InspectionRunResult struct {
Metadata interface{}
ResultStore inspectioncore.Store
}
type InspectionTaskRegistry ¶
type InspectionTaskRegistry interface {
coretask.TaskRegistry
// AddInspectionType adds a new definition of InspectionType.
AddInspectionType(newInspectionType InspectionType) error
}
InspectionTaskRegistry is interface for task packages to register its tasks and inspection types.
func NewScopedRegistry ¶ added in v0.53.0
func NewScopedRegistry(reg InspectionTaskRegistry, opts ...coretask.LabelOpt) InspectionTaskRegistry
NewScopedRegistry Creates a new ScopedTaskRegistry with the given LabelOpts.
type InspectionTaskRunner ¶
type InspectionTaskRunner struct {
ID string
// contains filtered or unexported fields
}
InspectionTaskRunner manages the lifecycle of a single inspection instance. It handles task graph resolution, execution, and result retrieval for a given inspection type and feature set.
func NewImportedInspectionRunner ¶ added in v0.58.2
func NewImportedInspectionRunner(server *InspectionTaskServer, ioConfig *inspectioncore.IOConfig, id string, store inspectioncore.Store, metadata *typedmap.ReadonlyTypedMap, options ...RunContextOption) *InspectionTaskRunner
NewImportedInspectionRunner creates an InspectionTaskRunner initialized in completed state with imported data.
func NewInspectionRunner ¶
func NewInspectionRunner(server *InspectionTaskServer, ioConfig *inspectioncore.IOConfig, id string, options ...RunContextOption) *InspectionTaskRunner
NewInspectionRunner creates a new InspectionTaskRunner.
func (*InspectionTaskRunner) AddInterceptors ¶ added in v0.50.0
func (i *InspectionTaskRunner) AddInterceptors(interceptors ...InspectionInterceptor)
AddInterceptors adds interceptors to the runner.
func (*InspectionTaskRunner) Cancel ¶
func (i *InspectionTaskRunner) Cancel() error
Cancel requests the cancellation of a running inspection.
func (*InspectionTaskRunner) DryRun ¶
func (i *InspectionTaskRunner) DryRun(ctx context.Context, req *inspectioncore.InspectionRequest) (*InspectionDryRunResult, error)
DryRun performs a dry run of the inspection. It resolves the task graph and runs it in dry-run mode to collect metadata without executing tasks.
func (*InspectionTaskRunner) FeatureList ¶
func (i *InspectionTaskRunner) FeatureList() ([]FeatureListItem, error)
FeatureList returns the list of available features for the current inspection type.
func (*InspectionTaskRunner) GetCurrentMetadata ¶
func (i *InspectionTaskRunner) GetCurrentMetadata() (*typedmap.ReadonlyTypedMap, error)
GetCurrentMetadata returns the metadata map for the current inspection run.
func (*InspectionTaskRunner) Metadata ¶
func (i *InspectionTaskRunner) Metadata() (map[string]any, error)
Metadata returns the serializable metadata of the current run.
func (*InspectionTaskRunner) ResolveTaskGraph ¶ added in v0.56.7
func (i *InspectionTaskRunner) ResolveTaskGraph() (*coretask.TaskSet, error)
ResolveTaskGraph resolves the task graph for the current inspection runner and returns the runnable TaskSet.
func (*InspectionTaskRunner) Result ¶
func (i *InspectionTaskRunner) Result() (*InspectionRunResult, error)
Result returns the final result of a completed inspection. It extracts the inspection data store and serializable metadata from the task runner's result.
func (*InspectionTaskRunner) Run ¶
func (i *InspectionTaskRunner) Run(ctx context.Context, req *inspectioncore.InspectionRequest) error
Run executes the inspection. It resolves the task graph, sets up the context and metadata, and starts the task runner asynchronously.
func (*InspectionTaskRunner) SetFeatureList ¶
func (i *InspectionTaskRunner) SetFeatureList(featureList []string) error
SetFeatureList sets the list of enabled features for the inspection.
func (*InspectionTaskRunner) SetInspectionType ¶
func (i *InspectionTaskRunner) SetInspectionType(inspectionType string) error
SetInspectionType sets the type of inspection and initializes the available tasks. It filters the root task set from the server to get tasks relevant to the specified inspectionType.
func (*InspectionTaskRunner) Started ¶
func (i *InspectionTaskRunner) Started() bool
Started returns true if the inspection has been started.
func (*InspectionTaskRunner) TakeRunTaskGraphSnapshot ¶ added in v0.59.0
func (i *InspectionTaskRunner) TakeRunTaskGraphSnapshot() (*RunTaskGraphSnapshot, error)
TakeRunTaskGraphSnapshot returns the task graph being executed along with the latest run status of each task. It returns ErrRunTaskGraphNotStarted when the inspection has no task graph execution to observe.
func (*InspectionTaskRunner) UpdateFeatureMap ¶
func (i *InspectionTaskRunner) UpdateFeatureMap(featureMap map[string]bool) error
UpdateFeatureMap updates the enabled features based on the provided map. The input map contains feature IDs and a boolean indicating if they should be enabled.
func (*InspectionTaskRunner) Wait ¶
func (i *InspectionTaskRunner) Wait() <-chan struct{}
Wait returns a channel that is closed when the inspection finishes.
type InspectionTaskServer ¶
type InspectionTaskServer struct {
// RootTaskSet is the set of the all tasks in KHI.
RootTaskSet *coretask.TaskSet
// contains filtered or unexported fields
}
InspectionTaskServer manages tasks and provides apis to get task related information in JSON convertible type.
func NewServer ¶
func NewServer(ioConfig *inspectioncore.IOConfig) (*InspectionTaskServer, error)
func (*InspectionTaskServer) AddInspectionInterceptor ¶ added in v0.50.0
func (s *InspectionTaskServer) AddInspectionInterceptor(interceptor InspectionInterceptor)
AddInspectionInterceptor adds an interceptor that will be applied to all new inspection runners.
func (*InspectionTaskServer) AddInspectionType ¶
func (s *InspectionTaskServer) AddInspectionType(newInspectionType InspectionType) error
AddInspectionType register a inspection type.
func (*InspectionTaskServer) AddRunContextOption ¶
func (s *InspectionTaskServer) AddRunContextOption(option RunContextOption)
AddRunContextOption adds a RunContextOption that will be applied to all new inspection runners.
func (*InspectionTaskServer) AddTask ¶
func (s *InspectionTaskServer) AddTask(task coretask.UntypedTask) error
AddTask register a task usable for the inspection task graph execution.
func (*InspectionTaskServer) CreateInspection ¶
func (s *InspectionTaskServer) CreateInspection(inspectionType string) (string, error)
CreateInspection generates an inspection and returns inspection ID
func (*InspectionTaskServer) GetAllInspectionTypes ¶
func (s *InspectionTaskServer) GetAllInspectionTypes() []*InspectionType
func (*InspectionTaskServer) GetAllRegisteredTasks ¶
func (s *InspectionTaskServer) GetAllRegisteredTasks() []coretask.UntypedTask
GetAllRegisteredTasks returns a cloned list of all tasks registered in this server.
func (*InspectionTaskServer) GetAllRunners ¶
func (s *InspectionTaskServer) GetAllRunners() []*InspectionTaskRunner
func (*InspectionTaskServer) GetInspection ¶
func (s *InspectionTaskServer) GetInspection(inspectionID string) *InspectionTaskRunner
Inspection returns an instance of an Inspection queried with given inspection ID.
func (*InspectionTaskServer) GetInspectionType ¶
func (s *InspectionTaskServer) GetInspectionType(inspectionTypeId string) *InspectionType
func (*InspectionTaskServer) IOConfig ¶ added in v0.58.2
func (s *InspectionTaskServer) IOConfig() *inspectioncore.IOConfig
IOConfig returns the IOConfig associated with the server.
func (*InspectionTaskServer) RegisterImportedInspection ¶ added in v0.58.2
func (s *InspectionTaskServer) RegisterImportedInspection(id string, store inspectioncore.Store, metadata *typedmap.ReadonlyTypedMap) *InspectionTaskRunner
RegisterImportedInspection registers a completed imported inspection with the given ID, store, and metadata.
type InspectionType ¶
type RunContextOption ¶
type RunContextOption = func(ctx context.Context, mode inspectioncore.InspectionTaskModeType) (context.Context, error)
RunContextOption modify the given context before passing it to the task runner.
func RunContextOptionArrayElementFromValue ¶
func RunContextOptionArrayElementFromValue[T any](key typedmap.TypedKey[*[]T], value T) RunContextOption
RunContextOptionArrayElementFromValue creates a RunContextOption that appends a value to an array stored in the context under the given TypedKey. If the array does not exist, it initializes an array with the element.
func RunContextOptionFromFunc ¶
func RunContextOptionFromFunc[T any](key typedmap.TypedKey[T], f func(ctx context.Context, mode inspectioncore.InspectionTaskModeType) (T, error)) RunContextOption
RunContextOptionFromFunc creates a RunContextOption that adds a dynamically generated value to the context. The function `f` is executed to produce the value, which is then added to the run context using the provided TypedKey. If `f` returns an error, the option propagation stops and the error is returned.
func RunContextOptionFromValue ¶
func RunContextOptionFromValue[T any](key typedmap.TypedKey[T], value T) RunContextOption
RunContextOptionFromValue creates a RunContextOption that adds a static value to the run context. The value is added to the context using the provided TypedKey.
type RunTaskGraphSnapshot ¶ added in v0.59.0
type RunTaskGraphSnapshot struct {
// DAG is the API representation of the task graph passed to the task runner when the run started.
// The topology never changes during a run, so it is built once and shared by every snapshot.
DAG *apiv1.TaskDAGInfo
// TaskRunStatuses holds the execution state of each task keyed by the task implementation ID.
TaskRunStatuses map[string]coretask.TaskRunStatus
// IsRunFinished reports whether the whole inspection run has already completed.
IsRunFinished bool
}
RunTaskGraphSnapshot is a point-in-time view of the task graph executed by an inspection run.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
TODO: move logger feature on task.
|
TODO: move logger feature on task. |
|
Package logutil provides log-related utilities used by multiple log processing tasks, such as parsers for different log string formats and log string converters.
|
Package logutil provides log-related utilities used by multiple log processing tasks, such as parsers for different log string formats and log string converters. |
|
Inventory tasks defined in this file provide a framework for discovering and merging inventory data from various sources.
|
Inventory tasks defined in this file provide a framework for discovering and merging inventory data from various sources. |