Documentation
¶
Index ¶
- Constants
- Variables
- func FullDepDAGResponse(ctx context.Context, clients []ServiceClient) (map[uri.URI][]DepDAGItem, error)
- func FullDepsResponse(ctx context.Context, clients []ServiceClient) (map[uri.URI][]*Dep, error)
- func FullNotifyFileChangesResponse(ctx context.Context, clients []ServiceClient, changes ...FileChange) error
- func FullPrepareResponse(ctx context.Context, clients []ServiceClient, ...) error
- func GetEncodingFromConfig(i InitConfig) string
- func GetExcludedDirsFromConfig(i InitConfig) []string
- func GetIncludedPathsFromConfig(i InitConfig, allowFilePaths bool) []string
- func HasCapability(caps []Capability, name string) bool
- func MultilineGrep(ctx context.Context, window int, path, pattern string) (int, error)
- func NewPrepareProgressReporterAdapter(providerName string, reporter PrepareProgressReporter) progress.ProgressReporter
- func NormalizePathForComparison(path string) string
- type AnalysisMode
- type BaseClient
- type Capability
- type Client
- type CodeSnipProvider
- type ConditionsByCap
- type Config
- type Dep
- type DepDAGItem
- type DependencyCondition
- type DependencyConditionCap
- type DependencyLocationResolver
- type ExternalLinks
- type FileChange
- type FileSearcher
- type IncidentContext
- type IncludeExcludeConstraints
- type InitConfig
- type InternalInit
- type InternalProviderClient
- type Location
- type Position
- type PrepareProgressEvent
- type PrepareProgressReporter
- type PrepareProgressStreamer
- type ProviderCondition
- type ProviderContext
- type ProviderEvaluateResponse
- type Proxy
- type RPCClient
- type SearchCriteria
- type Server
- type ServiceClient
- type Startable
- type UnimplementedDependenciesComponent
Constants ¶
const ( // Dep source label is a label key that any provider can use, to label the dependencies as coming from a particular source. // Examples from java are: open-source and internal. A provider can also have a user provide file that will tell them which // depdendencies to label as this value. This label will be used to filter out these dependencies from a given analysis DepSourceLabel = "konveyor.io/dep-source" DepLanguageLabel = "konveyor.io/language" DepExcludeLabel = "konveyor.io/exclude" // LspServerPath is a provider specific config used to specify path to a LSP server LspServerPathConfigKey = "lspServerPath" IncludedPathsConfigKey = "includedPaths" ExcludedDirsConfigKey = "excludedDirs" EncodingConfigKey = "encoding" )
const (
JWT_SECRET_ENV_VAR = "JWT_SECRET"
)
Variables ¶
var ( SchemaTypeString openapi3.SchemaType = openapi3.SchemaTypeString SchemaTypeArray openapi3.SchemaType = openapi3.SchemaTypeArray SchemaTypeObject openapi3.SchemaType = openapi3.SchemaTypeObject SchemaTypeNumber openapi3.SchemaType = openapi3.SchemaTypeInteger SchemaTypeBool openapi3.SchemaType = openapi3.SchemaTypeBoolean )
We need to make these Vars, because you can not take a pointer of the constant.
Functions ¶
func FullDepDAGResponse ¶
func FullDepDAGResponse(ctx context.Context, clients []ServiceClient) (map[uri.URI][]DepDAGItem, error)
func FullDepsResponse ¶
func FullNotifyFileChangesResponse ¶ added in v0.7.0
func FullNotifyFileChangesResponse(ctx context.Context, clients []ServiceClient, changes ...FileChange) error
func FullPrepareResponse ¶ added in v0.9.0
func FullPrepareResponse(ctx context.Context, clients []ServiceClient, conditionsByCap []ConditionsByCap) error
func GetEncodingFromConfig ¶ added in v0.9.0
func GetEncodingFromConfig(i InitConfig) string
func GetExcludedDirsFromConfig ¶ added in v0.7.0
func GetExcludedDirsFromConfig(i InitConfig) []string
GetExcludedDirsFromConfig returns directories to exclude from analysis. It starts with sensible defaults (node_modules, vendor, .git, dist, build, target, venv) to prevent "argument list too long" errors when analyzing projects with large dependency directories. User-configured excludes are appended to these defaults. An empty array for excludedDirs explicitly clears the defaults (to analyze everything).
func GetIncludedPathsFromConfig ¶ added in v0.5.0
func GetIncludedPathsFromConfig(i InitConfig, allowFilePaths bool) []string
GetIncludedPathsFromConfig returns validated includedPaths from provider settings if allowFilePaths is not set, path to a file is converted into a path to its base dir
func HasCapability ¶
func HasCapability(caps []Capability, name string) bool
func MultilineGrep ¶
MultilineGrep searches for a multi-line pattern in a file and returns line number when matched window determines how many lines to load in mem at a time, uses ctx to abort search on timeout fails when a line in file overflows 64K, returns -1 and error on failure
func NewPrepareProgressReporterAdapter ¶ added in v0.9.0
func NewPrepareProgressReporterAdapter(providerName string, reporter PrepareProgressReporter) progress.ProgressReporter
NewPrepareProgressReporterAdapter creates a progress.ProgressReporter from a PrepareProgressReporter. The adapter converts progress.ProgressEvent to PrepareProgressReporter.ReportProgress calls.
Parameters:
- providerName: Name of the provider (e.g., "java", "nodejs")
- reporter: The underlying PrepareProgressReporter
Example usage:
adapter := provider.NewPrepareProgressReporterAdapter("java", prepareReporter)
throttled := progress.NewThrottledReporter("provider_prepare", adapter)
func NormalizePathForComparison ¶ added in v0.9.0
NormalizePathForComparison normalizes a file path for consistent comparison across platforms. It handles:
- URI schemes (file:///, file:)
- Path separators (converts backslashes to forward slashes)
- Case sensitivity (normalizes to lowercase on Windows)
- Special URI schemes (preserves them as-is, e.g., csharp:)
This function is commonly used when filtering paths or comparing file URIs from LSP servers.
Types ¶
type AnalysisMode ¶
type AnalysisMode string
const ( FullAnalysisMode AnalysisMode = "full" SourceOnlyAnalysisMode AnalysisMode = "source-only" )
type BaseClient ¶
type BaseClient interface {
Capabilities() []Capability
// Init initiates and returns a service client along with additional init config for the builtin provider
Init(context.Context, logr.Logger, InitConfig) (ServiceClient, InitConfig, error)
}
type Capability ¶
type Capability struct {
Name string
Input openapi3.SchemaOrRef
Output openapi3.SchemaOrRef
}
func ToProviderCap ¶ added in v0.4.0
func ToProviderInputOutputCap ¶ added in v0.4.0
type Client ¶
type Client interface {
BaseClient
ServiceClient
}
type CodeSnipProvider ¶
func (CodeSnipProvider) GetCodeSnip ¶
type ConditionsByCap ¶ added in v0.9.0
type Config ¶
type Config struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
BinaryPath string `yaml:"binaryPath,omitempty" json:"binaryPath,omitempty"`
Address string `yaml:"address,omitempty" json:"address,omitempty"`
UseSocket bool `yaml:"useSocket,omitempty" json:"useSocket,omitempty"`
CertPath string `yaml:"certPath,omitempty" json:"certPath,omitempty"`
JWTToken string `yaml:"jwtToken,omitempty" json:"jwtToken,omitempty"`
Proxy *Proxy `yaml:"proxyConfig,omitempty" json:"proxyConfig,omitempty"`
InitConfig []InitConfig `yaml:"initConfig,omitempty" json:"initConfig,omitempty"`
ContextLines int
// PrepareProgressReporter is an optional interface for reporting progress during Prepare() phase.
// Used by GRPC providers to report progress during provider initialization.
PrepareProgressReporter PrepareProgressReporter `yaml:"-" json:"-"`
LogLevel *int `yaml:"logLevel,omitempty" json:"logLevel,omitempty"`
}
type Dep ¶
func ConvertDagItemsToList ¶
func ConvertDagItemsToList(items []DepDAGItem) []*Dep
Convert Dag Item List to flat list.
type DepDAGItem ¶
type DepDAGItem = konveyor.DepDAGItem
type DependencyCondition ¶
type DependencyCondition struct {
DependencyConditionCap
Client Client
}
TODO where should this go
func (DependencyCondition) Evaluate ¶
func (dc DependencyCondition) Evaluate(ctx context.Context, log logr.Logger, condCtx engine.ConditionContext) (engine.ConditionResponse, error)
type DependencyConditionCap ¶ added in v0.4.0
type DependencyConditionCap struct {
Upperbound string `json:"upperbound,omitempty" title:"Upperbound" description:"Match versions lower than or equal to"`
Lowerbound string `json:"lowerbound,omitempty" title:"Lowerbound" description:"Match versions greater than or equal to"`
Name string `json:"name" title:"Name" description:"Name of the dependency"`
// NameRegex will be a valid go regex that will be used to
// search the name of a given dependency.
// Examples include kubernetes* or jakarta-.*-2.2.
NameRegex string `json:"name_regex,omitempty" title:"NameRegex" description:"Regex pattern to match the name"`
}
type ExternalLinks ¶
type FileChange ¶ added in v0.7.0
type FileSearcher ¶ added in v0.7.0
type FileSearcher struct {
BasePath string
// additional search paths can be added e.g. working copy paths
AdditionalPaths []string
ProviderConfigConstraints IncludeExcludeConstraints
RuleScopeConstraints IncludeExcludeConstraints
// fail on first file operation error
FailFast bool
Log logr.Logger
}
FileSearcher takes global include / exclude patterns and base locations for search
func (*FileSearcher) Search ¶ added in v0.7.0
func (f *FileSearcher) Search(s SearchCriteria) ([]string, error)
Search searches files using SearchCriteria defining search constraints filters files by inclusion rules, applies exclusion after inclusion constraints take priority in order of - 1. Search time constraints (highest priority) 2. Rule scope constraints 3. Provider config level constraints
type IncidentContext ¶
type IncidentContext struct {
FileURI uri.URI `yaml:"fileURI"`
Effort *int `yaml:"effort,omitempty"`
LineNumber *int `yaml:"lineNumber,omitempty"`
Variables map[string]interface{} `yaml:"variables,omitempty"`
Links []ExternalLinks `yaml:"externalLink,omitempty"`
CodeLocation *Location `yaml:"location,omitempty"`
IsDependencyIncident bool
}
type IncludeExcludeConstraints ¶ added in v0.7.0
type InitConfig ¶
type InitConfig struct {
// This is the location of the code base that the
// Provider will be responisble for parsing
// TODO: rootUri, which is what this maps to in the LSP spec, is deprecated.
// We should instead use workspaceFolders.
Location string `yaml:"location,omitempty" json:"location,omitempty"`
// This is the path to look for the dependencies for the project.
// It is relative to the Location
// TODO: This only allows for one directory for dependencies. Use DependencyFolders instead
DependencyPath string `yaml:"dependencyPath,omitempty" json:"dependencyPath,omitempty"`
AnalysisMode AnalysisMode `yaml:"analysisMode" json:"analysisMode"`
// This will have to be defined for each provider
ProviderSpecificConfig map[string]interface{} `yaml:"providerSpecificConfig,omitempty" json:"providerSpecificConfig,omitempty"`
Proxy *Proxy `yaml:"proxyConfig,omitempty" json:"proxyConfig,omitempty"`
// This will be unusable connecting over a network but can be used in code.
RPC RPCClient `yaml:"-" json:"-"`
PipeName string `yaml:"pipeName" json:"pipeName"`
// Given a pipe name for the init config, we will use that pipe and connect to an already inited provider.
Initialized bool `yaml:"initialized" json:"initialized"`
// LogLevel for the provider logger verbosity
LogLevel *int `yaml:"logLevel,omitempty" json:"logLevel,omitempty"`
// PrepareProgressReporter is an optional interface for reporting progress during Prepare() phase.
// If provided, the provider will call ReportProgress() as it processes files during symbol cache population.
PrepareProgressReporter PrepareProgressReporter `yaml:"-" json:"-"`
}
type InternalInit ¶
type InternalInit interface {
ProviderInit(context.Context, []InitConfig) ([]InitConfig, error)
}
InternalInit interface is going to be used to init the full config of a provider. used by the engine/analyzer to get a provider ready. It takes additional init configs that may be returned by other providers when they are initialized
type InternalProviderClient ¶
type InternalProviderClient interface {
InternalInit
Client
}
type Position ¶
type Position struct {
/*Line defined:
* Line position in a document (zero-based).
* If a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document.
* If a line number is negative, it defaults to 0.
*/
Line float64 `json:"line"`
/*Character defined:
* Character offset on a line in a document (zero-based). Assuming that the line is
* represented as a string, the `character` value represents the gap between the
* `character` and `character + 1`.
*
* If the character value is greater than the line length it defaults back to the
* line length.
* If a line number is negative, it defaults to 0.
*/
Character float64 `json:"character"`
}
type PrepareProgressEvent ¶ added in v0.9.0
PrepareProgressEvent represents a progress update during Prepare() phase. This struct is used for GRPC streaming between external providers and the main analyzer.
type PrepareProgressReporter ¶ added in v0.9.0
type PrepareProgressReporter interface {
// ReportProgress reports progress for a specific provider.
// providerName: Name of the provider (e.g., "nodejs", "java")
// filesProcessed: Number of files processed so far
// totalFiles: Total number of files to process
ReportProgress(providerName string, filesProcessed, totalFiles int)
}
PrepareProgressReporter is an interface for reporting progress during the Prepare() phase. Implementations should handle concurrent calls safely as progress updates may come from multiple goroutines.
func NewPrepareProgressAdapter ¶ added in v0.9.0
func NewPrepareProgressAdapter(reporter progress.ProgressReporter) PrepareProgressReporter
NewPrepareProgressAdapter creates a PrepareProgressReporter from a progress.ProgressReporter. This adapter converts Prepare() progress updates into ProgressEvents with "provider_prepare" stage.
Example usage:
reporter := progress.NewTextReporter(os.Stderr)
prepareReporter := provider.NewPrepareProgressAdapter(reporter)
initConfig := provider.InitConfig{
Location: "/path/to/code",
PrepareProgressReporter: prepareReporter,
}
type PrepareProgressStreamer ¶ added in v0.9.0
type PrepareProgressStreamer interface {
// StartProgressStream creates and returns a channel for streaming progress events.
// The returned channel will receive progress events during Prepare() phase.
StartProgressStream() <-chan *PrepareProgressEvent
// StopProgressStream stops the progress stream and closes the channel.
StopProgressStream()
}
PrepareProgressStreamer is an optional interface that ServiceClient implementations can provide to support streaming progress events over GRPC.
type ProviderCondition ¶
type ProviderCondition struct {
Client ServiceClient
Capability string
ConditionInfo interface{}
Rule engine.Rule
Ignore bool
DepLabelSelector *labels.LabelSelector[*Dep]
}
func (ProviderCondition) Evaluate ¶
func (p ProviderCondition) Evaluate(ctx context.Context, log logr.Logger, condCtx engine.ConditionContext) (engine.ConditionResponse, error)
func (ProviderCondition) Ignorable ¶
func (p ProviderCondition) Ignorable() bool
type ProviderContext ¶
type ProviderContext struct {
Tags map[string]interface{} `yaml:"tags"`
Template map[string]engine.ChainTemplate `yaml:"template"`
RuleID string `yaml:"ruleID"`
DepLabelSelector string `yaml:"depLabelSelector,omitempty"`
}
func (*ProviderContext) GetScopedFilepaths ¶ added in v0.7.0
func (p *ProviderContext) GetScopedFilepaths() (included []string, excluded []string)
type ProviderEvaluateResponse ¶
type ProviderEvaluateResponse struct {
Matched bool `yaml:"matched"`
Incidents []IncidentContext `yaml:"incidents"`
TemplateContext map[string]interface{} `yaml:"templateContext"`
}
func FullResponseFromServiceClients ¶
func FullResponseFromServiceClients(ctx context.Context, clients []ServiceClient, cap string, conditionInfo []byte) (ProviderEvaluateResponse, error)
type SearchCriteria ¶ added in v0.7.0
SearchCriteria defines a specific search criteria during search time, used for condition specific search this takes the highest priority when searching
type Server ¶
type ServiceClient ¶
type ServiceClient interface {
// Prepare will pass all conditions to the provider before evaluation
// so that the provider can pre-process conditions for faster responses
Prepare(ctx context.Context, conditionsByCap []ConditionsByCap) error
// Evaluate will evaluate a condition and return a response
Evaluate(ctx context.Context, cap string, conditionInfo []byte) (ProviderEvaluateResponse, error)
Stop()
// GetDependencies will get the dependencies
// It is the responsibility of the provider to determine how that is done
GetDependencies(ctx context.Context) (map[uri.URI][]*Dep, error)
// GetDependencies will get the dependencies and return them as a linked list
// Top level items are direct dependencies, the rest are indirect dependencies
GetDependenciesDAG(ctx context.Context) (map[uri.URI][]DepDAGItem, error)
// Used to notify changes to files in the project
NotifyFileChanges(ctx context.Context, changes ...FileChange) error
}
For some period of time during POC this will be in tree, in the future we need to write something that can do this w/ external binaries
type UnimplementedDependenciesComponent ¶
type UnimplementedDependenciesComponent struct{}
func (*UnimplementedDependenciesComponent) GetDependencies ¶
func (p *UnimplementedDependenciesComponent) GetDependencies(ctx context.Context) (map[uri.URI][]*Dep, error)
We don't have dependencies
func (*UnimplementedDependenciesComponent) GetDependenciesDAG ¶
func (p *UnimplementedDependenciesComponent) GetDependenciesDAG(ctx context.Context) (map[uri.URI][]DepDAGItem, error)
We don't have dependencies