pluginkit

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var USER_CONFIG *config.Config

After we get to StockArmory, the pluginkit will have a pointer to the runtime user config

Functions

This section is empty.

Types

type Armory

type Armory struct {
	PluginName    string               `json:"pluginName"`    // PluginName is the name of the plugin
	ServiceTarget string               `json:"serviceTarget"` // ServiceTarget is the name of the service the plugin is running on
	Config        *config.Config       `json:"config"`        // Config is the global configuration for the plugin
	Logger        hclog.Logger         `json:"logger"`        // Logger is the global logger for the plugin
	TestSuites    map[string][]TestSet `json:"testSuites"`    // TestSuites is a map of testSuite names to their testSets
	StartupFunc   func() error         `json:"startupFunc"`   // StartupFunc is a function to run before the testSets
	CleanupFunc   func() error         `json:"cleanupFunc"`   // CleanupFunc is a function to run after the testSets
}

type Change

type Change struct {
	TargetName   string      `json:"targetName"`   // TargetName is the name of the resource or configuration that was changed
	TargetObject interface{} `json:"targetObject"` // TargetObject is the object that was changed
	Applied      bool        `json:"applied"`      // Applied is true if the change was successfully applied at least once
	Reverted     bool        `json:"reverted"`     // Reverted is true if the change was successfully reverted and not applied again
	Error        error       `json:"error"`        // Error is used if an error occurred during the change
	// contains filtered or unexported fields
}

Change is a struct that contains the data and functions associated with a single change

func NewChange

func NewChange(targetName string, targetObject interface{}, applyFunc func() (interface{}, error), revertFunc func() error) *Change

NewChange creates a new Change struct with the provided data

func (*Change) Apply

func (c *Change) Apply()

Apply executes the Apply function for the change

func (*Change) Revert

func (c *Change) Revert()

Revert executes the Revert function for the change

type Test

type Test func() *TestResult

type TestResult

type TestResult struct {
	Passed      bool               `json:"passed"`      // Passed is true if the test passed
	Description string             `json:"description"` // Description is a human-readable description of the test
	Message     string             `json:"message"`     // Message is a human-readable description of the test result
	Function    string             `json:"function"`    // Function is the name of the code that was executed
	Value       interface{}        `json:"value"`       // Value is the object that was returned during the test
	Changes     map[string]*Change `json:"changes"`     // Changes is a slice of changes that were made during the test
}

TestResult is a struct that contains the results of a single step within a testSet

func (*TestResult) Fail

func (t *TestResult) Fail(message string, value interface{})

func (*TestResult) Pass

func (t *TestResult) Pass(message string, value interface{})

type TestSet

type TestSet func() (testSetName string, result TestSetResult)

type TestSetResult

type TestSetResult struct {
	Passed        bool                  `json:"passed"`        // Passed is true if the test passed
	Description   string                `json:"description"`   // Description is a human-readable description of the test
	Message       string                `json:"message"`       // Message is a human-readable description of the test result
	DocsURL       string                `json:"docsURL"`       // DocsURL is a link to the documentation for the test
	ControlID     string                `json:"controlID"`     // ControlID is the ID of the control that the test is validating
	Tests         map[string]TestResult `json:"tests"`         // Tests is a list of functions that were executed during the test
	BadStateAlert bool                  `json:"badStateAlert"` // BadStateAlert is true if any change failed to revert at the end of the testSet
}

TestSetResult is a struct that contains the results of a check for a single control

func (*TestSetResult) ExecuteInvasiveTest

func (s *TestSetResult) ExecuteInvasiveTest(testFunc func() TestResult)

ExecuteInvasiveTest is a helper function to run a test function and update the result

func (*TestSetResult) ExecuteTest

func (s *TestSetResult) ExecuteTest(testFunc func() TestResult)

ExecuteTest is a helper function to run a test function and update the result

type TestSuite

type TestSuite struct {
	TestSuiteName  string                   `json:"testSuiteName"`  // TestSuiteName is the name of the TestSuite
	StartTime      string                   `json:"startTime"`      // StartTime is the time the plugin started
	EndTime        string                   `json:"endTime"`        // EndTime is the time the plugin ended
	TestSetResults map[string]TestSetResult `json:"testSetResults"` // TestSetResults is a map of testSet names to their results
	Passed         bool                     `json:"passed"`         // Passed is true if all testSets in the testSuite passed
	BadStateAlert  bool                     `json:"badStateAlert"`  // BadState is true if any testSet failed to revert at the end of the testSuite
	// contains filtered or unexported fields
}

TestSuite is a struct that contains the results of all testSets, orgainzed by name

func (*TestSuite) AddTestSetResult

func (t *TestSuite) AddTestSetResult(name string, result TestSetResult)

AddTestSetResult adds a TestSetResult to the TestSuite

func (*TestSuite) Execute

func (t *TestSuite) Execute() error

ExecuteTestSuite is used to execute a list of testSets provided by a Plugin and customized by user config

func (*TestSuite) WriteTestSetResults

func (t *TestSuite) WriteTestSetResults(serviceName string, output string) error

type Vessel

type Vessel struct {
	ServiceName  string                     `json:"serviceName"`
	PluginName   string                     `json:"pluginName"`
	RequiredVars []string                   `json:"requiredVars"`
	Armory       *Armory                    `json:"armory"`
	TestSuites   []TestSuite                `json:"testSuites"`
	Initializer  func(*config.Config) error `json:"initializer"`
	// contains filtered or unexported fields
}

The vessel gets the armory in position to execute the testSets specified in the testSuites

func NewVessel

func NewVessel(
	name string,
	armory *Armory,
	initializer func(*config.Config) error,
	requiredVars []string) Vessel

func (*Vessel) Mobilize

func (v *Vessel) Mobilize() (err error)

Mobilize executes the testSets specified in the testSuites

func (*Vessel) StockArmory

func (v *Vessel) StockArmory() error

StockArmory sets up the armory for the vessel to use

Jump to

Keyboard shortcuts

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