recognizer

package
v1.1.1-1.18 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 16 Imported by: 3

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 func() error {
		if err := resp.Body.Close(); err != nil {
			return fmt.Errorf("error closing file: %s", err)
		}
		return nil
	}()

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

	body, err2 := ioutil.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 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 SelectDevFileFromRegistry

func SelectDevFileFromRegistry(path string, url string) (model.DevFileType, error)

func SelectDevFileFromTypes

func SelectDevFileFromTypes(path string, devFileTypes []model.DevFileType) (int, error)

func SelectDevFileUsingLanguagesFromTypes

func SelectDevFileUsingLanguagesFromTypes(languages []model.Language, devFileTypes []model.DevFileType) (int, error)

func SelectDevFilesFromRegistry

func SelectDevFilesFromRegistry(path string, url string) ([]model.DevFileType, error)

func SelectDevFilesFromTypes

func SelectDevFilesFromTypes(path string, devFileTypes []model.DevFileType) ([]int, error)

func SelectDevFilesUsingLanguagesFromTypes

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