checker

package
v0.0.0-...-53c35de Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package checker provides a framework for running a set of checks against an OpenStack cloud.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckManager

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

CheckManager runs a set of checks against an OpenStack cloud

func New

func New(cloud string, opts CloudOptions, factories []CheckerFactory) (*CheckManager, error)

New creates a new CheckManager instance

func (*CheckManager) GetCloud

func (cm *CheckManager) GetCloud() string

GetCloud returns the cloud that this manager has been configured for

func (*CheckManager) Run

func (cm *CheckManager) Run(ctx context.Context, callback CheckResultCallback, checks ...string) error

Run runs all registered checks in parallel and calls the callback function for each result

type CheckOptions

type CheckOptions map[string]any

CheckOptions is a map of options for a single check

type CheckResult

type CheckResult struct {
	Cloud    string
	Name     string
	Error    error
	Start    time.Time
	Duration time.Duration
	Output   string
}

CheckResult stores the result from Checker.Check. It is used to produce metrics or display results.

type CheckResultCallback

type CheckResultCallback func(r CheckResult) bool

CheckResultCallback is a callback function that is called for each CheckResult. If true is returned, then additional checks should be stopped.

type Checker

type Checker interface {
	GetName() string
	Check(ctx context.Context, providerClient *gophercloud.ProviderClient, region string, output *bytes.Buffer) error
}

Checker is a single check that can be run against an OpenStack cloud. E.g. create a network, create a server, etc.

type CheckerFactory

type CheckerFactory func(authOpts *gophercloud.AuthOptions, opts CloudOptions) (Checker, error) //nolint:revive // checker.CheckerFactory is fine

CheckerFactory creates a new `Checker` instance

type CloudOptions

type CloudOptions map[string]CheckOptions

CloudOptions is a map of check names to CheckOptions

func (CloudOptions) Bool

func (opts CloudOptions) Bool(checkname, key string, value *bool) (bool, error)

Bool returns the bool value of the given option key for the given checkname in this Openstack cloud.

  • If the option is not set, the value is not changed and false is returned.
  • If the option is set, the value is set and true is returned.
  • If the option is set but the value is not a string, an error is returned.

func (CloudOptions) Dump

func (opts CloudOptions) Dump()

Dump prints the settings to stdout

func (CloudOptions) Int

func (opts CloudOptions) Int(checkname, key string, value *int) (bool, error)

Int returns the int value of the given option key for the given checkname in this Openstack cloud.

  • If the option is not set, the value is not changed and false is returned.
  • If the option is set, the value is set and true is returned.
  • If the option is set but the value is not a string, an error is returned.

func (CloudOptions) String

func (opts CloudOptions) String(checkname, key string, value *string) (bool, error)

String returns the string value of the given option key for the given checkname in this Openstack cloud.

  • If the option is not set, the value is not changed and false is returned.
  • If the option is set, the value is set and true is returned.
  • If the option is set but the value is not a string, an error is returned.

type LogRoundTripper

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

LogRoundTripper satisfies the http.RoundTripper interface and is used to customize the default Gophercloud RoundTripper to allow for logging.

func (*LogRoundTripper) RoundTrip

func (lrt *LogRoundTripper) RoundTrip(request *http.Request) (*http.Response, error)

RoundTrip performs a round-trip HTTP request and logs relevant information about it.

type Settings

type Settings struct {
	Default CloudOptions            `yaml:"default"`
	Clouds  map[string]CloudOptions `yaml:"clouds"`
}

Settings is the top-level configuration structure used for settings.yaml

func LoadSettingsFromFile

func LoadSettingsFromFile(path string) (*Settings, error)

LoadSettingsFromFile loads a settings.yaml file from the given path and returns a Settings struct

func (*Settings) GetCloudOptions

func (s *Settings) GetCloudOptions(cloud string) CloudOptions

GetCloudOptions returns a CloudOptions struct for the given cloud name

Jump to

Keyboard shortcuts

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