manifestchecker

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUnsupportedInputRawVersionError

func IsUnsupportedInputRawVersionError(err error) bool

IsUnsupportedInputRawVersionError checks if the given error is of type UnsupportedInputRawVersionError

func ManifestFrom

func ManifestFrom(toolName string, checks map[string]string) model.Manifest

func ManifestFromWithFlavor

func ManifestFromWithFlavor(toolName string, flavor string, checks map[string]string) model.Manifest

func NewUnsupportedInputRawVersionError

func NewUnsupportedInputRawVersionError(msg string) error

NewUnsupportedInputRawVersionError creates a new UnsupportedInputRawVersionError

Types

type CheckVersionRequest

type CheckVersionRequest struct {
	VersionCheckerSpec   VersionCheckerSpec
	VersionCommandOutput string
	ManifestTool         model.ManifestTool
}

type CheckVersionResult

type CheckVersionResult struct {
	IsVersionValid           bool
	VersionsFound            map[string]string
	CheckVersionErrorMessage string
}

type ExactMatchFieldVersionValidator

type ExactMatchFieldVersionValidator struct {
}

func (ExactMatchFieldVersionValidator) Validate

func (validator ExactMatchFieldVersionValidator) Validate(fieldValue string, expectedVersion string) (bool, error)

type FieldSpec

type FieldSpec struct {
	Name     string `yaml:"name"`
	Type     string `yaml:"type"`
	Required bool   `yaml:"required"`
}

type FieldValidationResult

type FieldValidationResult struct {
	FieldName         string
	ValueFound        string
	IsValid           bool
	ResultDescription string
}

type FieldVersionValidator

type FieldVersionValidator interface {
	Validate(version string, expectedVersion string) (bool, error)
}

type FieldVersionValidatorManager

type FieldVersionValidatorManager struct {
	// contains filtered or unexported fields
}

func NewFieldVersionValidatorManager

func NewFieldVersionValidatorManager(versionValidators map[string]FieldVersionValidator) FieldVersionValidatorManager

func (FieldVersionValidatorManager) FieldVersionValidator

func (versionValidatorManager FieldVersionValidatorManager) FieldVersionValidator(fieldSpec FieldSpec) (FieldVersionValidator, bool)

type FlavorSpec

type FlavorSpec struct {
	Name               string              `yaml:"name"`
	VersionCommandArgs []string            `yaml:"version_command_args"`
	VersionChecker     *VersionCheckerSpec `yaml:"version_checker"`
}

type RegexpVersionParser

type RegexpVersionParser struct {
	// contains filtered or unexported fields
}

func NewRegexVersionParser

func NewRegexVersionParser(regexpPattern string, keys []string) *RegexpVersionParser

func (*RegexpVersionParser) Parse

func (parser *RegexpVersionParser) Parse(rawVersion string) (map[string]string, error)

type SemverFieldVersionValidator

type SemverFieldVersionValidator struct {
}

func (SemverFieldVersionValidator) Validate

func (validator SemverFieldVersionValidator) Validate(fieldValue string, expectedVersion string) (bool, error)

type SystemAdapter

type SystemAdapter interface {
	CheckCommandAvailable(command string) (bool, error)
	// Returns true if the directory exists. Returns false if the path does not exist or if it is a file
	CheckDirExist(path string) (bool, error)
	ExecuteCommand(commandName string, params []string) (string, error)
}

type TestSystemAdapter

type TestSystemAdapter struct {
	// contains filtered or unexported fields
}

func (TestSystemAdapter) CheckCommandAvailable

func (t TestSystemAdapter) CheckCommandAvailable(command string) (bool, error)

func (*TestSystemAdapter) CheckDirExist

func (t *TestSystemAdapter) CheckDirExist(path string) (bool, error)

func (*TestSystemAdapter) ClearOutput

func (t *TestSystemAdapter) ClearOutput()

func (*TestSystemAdapter) ExecuteCommand

func (t *TestSystemAdapter) ExecuteCommand(commandName string, params []string) (string, error)

func (*TestSystemAdapter) NextOutput

func (t *TestSystemAdapter) NextOutput(outputFilePath string)

type ToolSpec

type ToolSpec struct {
	Name               string              `yaml:"name"`
	Description        string              `yaml:"description"`
	Command            string              `yaml:"command"`
	VersionCommandArgs []string            `yaml:"version_command_args"`
	VersionChecker     *VersionCheckerSpec `yaml:"version_checker"`
	Flavors            []FlavorSpec        `yaml:"flavors"`
}

func (ToolSpec) HasFlavors

func (t ToolSpec) HasFlavors() bool

type ToolValidationResult

type ToolValidationResult struct {
	Tool                            model.ManifestTool
	IsToolAvailable                 bool
	FieldValidations                map[string]FieldValidationResult
	IsVersionValid                  bool
	IsCommandVersionOutputParseable bool
	ResultDescription               string
}

func ToolValidationResultFor

func ToolValidationResultFor(tool model.ManifestTool) *ToolValidationResult

func (*ToolValidationResult) InvalidField

func (result *ToolValidationResult) InvalidField(field string, valueFound string, resultDescription string) *ToolValidationResult

func (*ToolValidationResult) IsValid

func (result *ToolValidationResult) IsValid() bool

func (*ToolValidationResult) NotParseableVersionOutputCommand

func (result *ToolValidationResult) NotParseableVersionOutputCommand(msg string) *ToolValidationResult

func (*ToolValidationResult) ToolNotAvailable

func (result *ToolValidationResult) ToolNotAvailable() *ToolValidationResult

func (*ToolValidationResult) ValidField

func (result *ToolValidationResult) ValidField(field string, valueFound string) *ToolValidationResult

func (*ToolValidationResult) WithToolAvailable

func (result *ToolValidationResult) WithToolAvailable(available bool) *ToolValidationResult

type ToolsManager

type ToolsManager struct {
	// contains filtered or unexported fields
}

func NewToolsManager

func NewToolsManager(toolsStorageAdapter ToolsStorageAdapter,
	systemAdapter SystemAdapter,
	versionCheckerManager VersionCheckerManager) ToolsManager

func (ToolsManager) IsManifestCompliant

func (tm ToolsManager) IsManifestCompliant(manifest model.Manifest) (bool, error)

func (ToolsManager) ValidateManifest

func (tm ToolsManager) ValidateManifest(manifest model.Manifest) ([]ToolValidationResult, error)

func (ToolsManager) ValidateManifestAndNotify

func (tm ToolsManager) ValidateManifestAndNotify(manifest model.Manifest, notifyFunc func(toolValidationResult []ToolValidationResult)) ([]ToolValidationResult, error)

func (ToolsManager) ValidateTool

func (tm ToolsManager) ValidateTool(manifestTool model.ManifestTool) ([]ToolValidationResult, error)

* Manifest has flavor configured ** Tool has flavor configured? *** yes: Check version *** no: Error not configured error * Manifest DOESN'T have flavor configured ** Has the tool flavors *** no: use main tool version checker to Check version *** yes: Iterate all flavors **** if flavor Version Checker match return **** Version checker that matches not found: Return not match result with all the checks done

type ToolsStorageAdapter

type ToolsStorageAdapter interface {
	Find(toolName string) (*ToolSpec, error)
}

type VersionCheckerManager

type VersionCheckerManager struct {
	// contains filtered or unexported fields
}

func NewVersionCheckerManager

func NewVersionCheckerManager(fieldVersionValidatorManager FieldVersionValidatorManager) VersionCheckerManager

func (VersionCheckerManager) CheckVersion

func (versionCheckerManager VersionCheckerManager) CheckVersion(checkVersionRequest CheckVersionRequest) (*ToolValidationResult, error)

type VersionCheckerSpec

type VersionCheckerSpec struct {
	VersionParserArr []VersionParserSpec `yaml:"parsers"`
	Fields           []FieldSpec         `yaml:"fields"`
}

func (VersionCheckerSpec) FieldNames

func (v VersionCheckerSpec) FieldNames() []string

func (VersionCheckerSpec) GetFieldSpecBy

func (v VersionCheckerSpec) GetFieldSpecBy(name string) (FieldSpec, bool)

type VersionParser

type VersionParser interface {
	Parse(rawVersion string) (map[string]string, error)
}

VersionParser interface wraps the Parse method

Parse parses the rawVersion string typically obtained by executing the version flag of a command and returns a map of key values obtained as result of parsing the input or error When the parser does not match the input a UnsupportedInputRawVersionError error must be returned

type VersionParserSpec

type VersionParserSpec struct {
	Type   string `yaml:"type"`
	Regexp string `yaml:"regexp"`
}

Jump to

Keyboard shortcuts

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