recognizer

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 16 Imported by: 5 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package recognizer implements functions that are used by every cobra cli command. Uses the enricher and model packages to return a result.

Index

Constants

View Source
const MinimumAllowedVersion = "2.0.0"

Variables

View Source
var DownloadDevfileTypesFromRegistry = func(url string, filter model.DevfileFilter) ([]model.DevfileType, error) {
	url = adaptUrl(url)
	tmpUrl := appendIndexPath(url)
	url, err := GetUrlWithVersions(tmpUrl, filter.MinSchemaVersion, filter.MaxSchemaVersion)
	if err != nil {
		return nil, err
	}

	resp, err := http.Get(url)
	if err != nil {
		return []model.DevfileType{}, err
	}

	defer utils.CloseHttpResponseBody(resp)

	if resp.StatusCode != http.StatusOK {
		return []model.DevfileType{}, errors.New("unable to fetch devfiles from the registry")
	}

	body, err2 := io.ReadAll(resp.Body)
	if err2 != nil {
		return []model.DevfileType{}, errors.New("unable to fetch devfiles from the registry")
	}

	var devfileTypes []model.DevfileType
	err = json.Unmarshal(body, &devfileTypes)
	if err != nil {
		return []model.DevfileType{}, errors.New("unable to fetch devfiles from the registry")
	}

	return devfileTypes, nil
}

DownloadDevfileTypesFromRegistry is exposed as a global variable for the purpose of running mock tests

Functions

func Analyze

func Analyze(path string) ([]model.Language, error)

func AnalyzeFile

func AnalyzeFile(configFile string, targetLanguage string) (model.Language, error)

func DetectComponents

func DetectComponents(path string) ([]model.Component, error)

func DetectComponentsFromFilesList

func DetectComponentsFromFilesList(files []string, settings model.DetectionSettings, ctx *context.Context) []model.Component

DetectComponentsFromFilesList detect components by analyzing all files. Uses the settings to perform component detection on files.

func DetectComponentsInRoot

func DetectComponentsInRoot(path string) ([]model.Component, error)

func DetectComponentsInRootWithPathAndPortStartegy

func DetectComponentsInRootWithPathAndPortStartegy(path string, portDetectionStrategy []model.PortDetectionAlgorithm) ([]model.Component, error)

func DetectComponentsInRootWithSettings

func DetectComponentsInRootWithSettings(settings model.DetectionSettings) ([]model.Component, error)

func DetectComponentsWithPathAndPortStartegy

func DetectComponentsWithPathAndPortStartegy(path string, portDetectionStrategy []model.PortDetectionAlgorithm) ([]model.Component, error)

func DetectComponentsWithSettings

func DetectComponentsWithSettings(settings model.DetectionSettings) ([]model.Component, error)

func DetectComponentsWithoutPortDetection added in v1.1.3

func DetectComponentsWithoutPortDetection(path string) ([]model.Component, error)

func GetUrlWithVersions added in v1.0.1

func GetUrlWithVersions(url, minSchemaVersion, maxSchemaVersion string) (string, error)

func MatchDevfiles added in v1.0.1

func MatchDevfiles(path string, url string, filter model.DevfileFilter) ([]model.DevfileType, error)

func SelectDevFileFromTypes

func SelectDevFileFromTypes(path string, devfileTypes []model.DevfileType) (int, error)

DEPRECATION WARNING: This function is deprecated, please use devfile_recognizer.MatchDevfiles instead. func SelectDevFileFromTypes: Returns the first devfile from the list of devfiles returned from SelectDevFilesFromTypes func. It also returns an error if exists.

func SelectDevFilesFromTypes

func SelectDevFilesFromTypes(path string, devfileTypes []model.DevfileType) ([]int, error)

DEPRECATION WARNING: This function is deprecated, please use devfile_recognizer.MatchDevfiles instead. func SelectDevFilesFromTypes: Returns a list of devfiles matched for the given application

func SelectDevfileFromRegistry added in v1.1.2

func SelectDevfileFromRegistry(path string, url string) (model.DevfileType, error)

func SelectDevfileUsingLanguagesFromTypes added in v1.1.2

func SelectDevfileUsingLanguagesFromTypes(languages []model.Language, devfileTypes []model.DevfileType) (int, error)

func SelectDevfilesFromRegistry added in v1.1.2

func SelectDevfilesFromRegistry(path string, url string) ([]model.DevfileType, error)

func SelectDevfilesUsingLanguagesFromTypes added in v1.1.2

func SelectDevfilesUsingLanguagesFromTypes(languages []model.Language, devfileTypes []model.DevfileType) ([]int, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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