provider

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 32 Imported by: 7

Documentation

Index

Constants

View Source
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"
)

Variables

This section is empty.

Functions

func FilterFilePattern

func FilterFilePattern(regex string, filepath string) (bool, error)

func FindFilesMatchingPattern

func FindFilesMatchingPattern(root, pattern string) ([]string, error)

func FullDepDAGResponse

func FullDepDAGResponse(ctx context.Context, clients []ServiceClient) (map[uri.URI][]DepDAGItem, error)

func FullDepsResponse

func FullDepsResponse(ctx context.Context, clients []ServiceClient) (map[uri.URI][]*Dep, error)

func GetFiles

func GetFiles(configLocation string, filepaths []string, patterns ...string) ([]string, error)

func HasCapability

func HasCapability(caps []Capability, name string) bool

func MultilineGrep

func MultilineGrep(ctx context.Context, window int, path, pattern string) (int, error)

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

Types

type AnalysisMode

type AnalysisMode string
const (
	FullAnalysisMode       AnalysisMode = "full"
	SourceOnlyAnalysisMode AnalysisMode = "source-only"
)

type BaseClient

type BaseClient interface {
	Capabilities() []Capability
	Init(context.Context, logr.Logger, InitConfig) (ServiceClient, error)
}

type Capability

type Capability struct {
	Name            string
	TemplateContext openapi3.SchemaRef
}

type Client

type Client interface {
	BaseClient
	ServiceClient
}

type CodeSnipProvider

type CodeSnipProvider struct {
	Providers []engine.CodeSnip
}

func (CodeSnipProvider) GetCodeSnip

func (p CodeSnipProvider) GetCodeSnip(u uri.URI, l engine.Location) (string, error)

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"`
	Proxy        *Proxy       `yaml:"proxyConfig,omitempty" json:"proxyConfig,omitempty"`
	InitConfig   []InitConfig `yaml:"initConfig,omitempty" json:"initConfig,omitempty"`
	ContextLines int
}

func GetConfig

func GetConfig(filepath string) ([]Config, error)

type Dep

type Dep = konveyor.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 {
	Upperbound string
	Lowerbound string
	Name       string
	// 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

	Client Client
}

TODO where should this go

func (DependencyCondition) Evaluate

type DependencyLocationResolver

type DependencyLocationResolver interface {
	GetLocation(ctx context.Context, dep konveyor.Dep) (engine.Location, error)
}
type ExternalLinks struct {
	URL   string `yaml:"url"`
	Title string `yaml:"title"`
}

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 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"`
}

type InternalInit

type InternalInit interface {
	ProviderInit(context.Context) 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.

type InternalProviderClient

type InternalProviderClient interface {
	InternalInit
	Client
}

type Location

type Location struct {
	StartPosition Position
	EndPosition   Position
}

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 ProviderCondition

type ProviderCondition struct {
	Client           ServiceClient
	Capability       string
	ConditionInfo    interface{}
	Rule             engine.Rule
	Ignore           bool
	DepLabelSelector *labels.LabelSelector[*Dep]
}

func (ProviderCondition) Evaluate

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"`
}

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 Proxy

type Proxy httpproxy.Config

func (Proxy) ToEnvVars

func (p Proxy) ToEnvVars() map[string]string

type Server

type Server interface {
	// This will start the GRPC server and will wait until the context is cancelled.
	Start(context.Context) error
}

func NewServer

func NewServer(client BaseClient, port int, logger logr.Logger) Server

Provider GRPC Service TOOD: HANDLE INIT CONFIG CHANGES

type ServiceClient

type ServiceClient interface {
	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)
}

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 Startable

type Startable interface {
	Start(context.Context) error
}

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

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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