common

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllError

func AllError(results []ValidationResult) error

func GetMap

func GetMap(raw interface{}, ids ...string) (map[string]interface{}, bool)

func GetSlice

func GetSlice(raw interface{}, id ...string) (interface{}, bool)

The returned interface{} will be a slice or an array

func GetSliceOfMaps

func GetSliceOfMaps(raw interface{}, id ...string) ([]map[string]interface{}, bool)

Returns a list of maps

func GetSliceOfStrings

func GetSliceOfStrings(raw interface{}, id ...string) ([]string, bool)

func GetString

func GetString(raw interface{}, ids ...string) (string, bool)

func ToInt

func ToInt(raw interface{}) (int64, bool)

Types

type Checker

type Checker interface {
	Validate(results *ValidationResults)
}

type NetworkChecker

type NetworkChecker interface {
	Add(network *sls_client.Network)
	Validate(results *ValidationResults)
}

type NetworkExtraPropertiesChecker

type NetworkExtraPropertiesChecker interface {
	Add(properties *sls_client.NetworkExtraProperties)
	Validate(results *ValidationResults)
}

type Result

type Result string
const (
	Fail    Result = "fail"
	Warning Result = "warning"
	Pass    Result = "pass"
)

type SlsStateExtended

type SlsStateExtended struct {
	SlsState       *sls_client.SlsState
	TypeToHardware map[string][]*sls_client.Hardware

	// This contains all the xnames that are specified as parents in the hardware entries.
	// This is currently treated as a set (a map with no meaningful value)
	// If something needs to look up hardware by parent, then change this to a map
	// for example change to: ParentToChildren map[string][]*sls_client.Hardware
	ParentHasChildren map[string]struct{}

	// todo remove these if they are not used
	AliasToHardware             map[string]*sls_client.Hardware
	IPReservationNameToNetworks map[string][]*sls_client.Network
	HardwareTypeToAlias         map[string]map[string]*sls_client.Hardware
	NetworkToIPReservations     map[string][]map[string]string
}

func NewSlsStateExtended

func NewSlsStateExtended(slsState *sls_client.SlsState) *SlsStateExtended

type ValidationCheck

type ValidationCheck string
const (
	IPRangeConflictCheck        ValidationCheck = "ip-range-conflict"
	IPRangeConflictWithK8sCheck ValidationCheck = "ip-range-conflict-with-k8s"
	SLSSchemaCheck              ValidationCheck = "sls-schema-validation"
)

type ValidationResult

type ValidationResult struct {
	Result      Result
	CheckID     ValidationCheck
	ComponentID string
	Description string
}

func FailureResult

func FailureResult(id ValidationCheck, componentId string, description string) ValidationResult

func NewValidationResult

func NewValidationResult(result Result, id ValidationCheck, componentId string, description string) ValidationResult

func PassResult

func PassResult(id ValidationCheck, componentId string, description string) ValidationResult

func WarningResult

func WarningResult(id ValidationCheck, componentId string, description string) ValidationResult

type ValidationResults

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

func NewValidationResults

func NewValidationResults() *ValidationResults

func (*ValidationResults) Add

func (*ValidationResults) Fail

func (v *ValidationResults) Fail(id ValidationCheck, componentId string, description string)

func (*ValidationResults) GetResults

func (v *ValidationResults) GetResults() []ValidationResult

func (*ValidationResults) Pass

func (v *ValidationResults) Pass(id ValidationCheck, componentId string, description string)

func (*ValidationResults) ToError

func (v *ValidationResults) ToError() error

func (*ValidationResults) ToString added in v0.2.0

func (v *ValidationResults) ToString() string

func (*ValidationResults) Warning

func (v *ValidationResults) Warning(id ValidationCheck, componentId string, description string)

Jump to

Keyboard shortcuts

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