reconcile

package
v0.0.0-...-c2b5c71 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package reconcile contains code to run Integrations and Validations

Index

Constants

This section is empty.

Variables

View Source
var ContextIngetrationNameKey integrationNameKey = "integrationName"

ContextIngetrationNameKey is the key used to store the integration name in the context

Functions

This section is empty.

Types

type Integration

type Integration interface {
	CurrentState(context.Context, *ResourceInventory) error
	DesiredState(context.Context, *ResourceInventory) error
	Reconcile(context.Context, *ResourceInventory) error
	LogDiff(*ResourceInventory)
	Setup(context.Context) error
}

Integration describes the set of methods Integrations must implement

type IntegrationRunner

type IntegrationRunner struct {
	Runnable Integration
	Name     string
	// contains filtered or unexported fields
}

IntegrationRunner is an implementation of Runner

func NewIntegrationRunner

func NewIntegrationRunner(runnable Integration, name string) *IntegrationRunner

NewIntegrationRunner creates a IntegrationRunner for a given Integration

func (*IntegrationRunner) Exiter

func (i *IntegrationRunner) Exiter(exitCode int)

Exiter exits the integration

func (*IntegrationRunner) Run

func (i *IntegrationRunner) Run()

Run runs the integration

type ResourceInventory

type ResourceInventory struct {
	State map[string]*ResourceState
}

ResourceInventory must be used to describe the diff an integration found

func NewResourceInventory

func NewResourceInventory() *ResourceInventory

NewResourceInventory creates a new ResourceInventory

func (*ResourceInventory) AddResourceState

func (ri *ResourceInventory) AddResourceState(target string, rs *ResourceState)

AddResourceState adds a ResourceState to the ResourceInventory

func (*ResourceInventory) GetResourceState

func (ri *ResourceInventory) GetResourceState(target string) *ResourceState

GetResourceState returns a ResourceState from the ResourceInventory

type ResourceState

type ResourceState struct {
	// Config is the configuration of the resource, usually the GraphQL response object
	Config interface{}
	// Current state of the resource
	Current interface{}
	// Desired state of the resource
	Desired interface{}
}

ResourceState describes the state of a resource

type Runner

type Runner interface {
	Run()
	Exiter(int)
}

Runner can be used to actually run Validations or Integrations

type Validation

type Validation interface {
	// Setup method is used to fetch secrets, setup clients or prepare state...
	Setup(context.Context) error
	// Validate is doing the actual validation
	Validate(context.Context) ([]ValidationError, error)
}

Validation describes the methods an Validation must implement

type ValidationError

type ValidationError struct {
	Path       string
	Validation string
	Error      error
}

ValidationError contains errors, that are discovered during Validate()

func ConcatValidationErrors

func ConcatValidationErrors(a, b []ValidationError) []ValidationError

ConcatValidationErrors can be used to merge two list of ValiudationErros

type ValidationRunner

type ValidationRunner struct {
	Runnable Validation
	Name     string
	Exiter   exitFunc
	// contains filtered or unexported fields
}

ValidationRunner is an implementation of Runner

func NewValidationRunner

func NewValidationRunner(runnable Validation, name string) *ValidationRunner

NewValidationRunner creates a ValidationRunner for a given Validation

func (*ValidationRunner) Run

func (v *ValidationRunner) Run()

Run executes the validation configured as target

Jump to

Keyboard shortcuts

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