runner

package
v0.0.0-...-ebc5297 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CatalogDestination   = "CATALOG_DESTINATION"
	TrentoCallbacksUrl   = "TRENTO_CALLBACKS_URL"
	TrentoExecutionID    = "TRENTO_EXECUTION_ID"
	AnsibleConfigFileEnv = "ANSIBLE_CONFIG"
)
View Source
const (
	AnsibleMain        = "ansible/check.yml"
	AnsibleMeta        = "ansible/meta.yml"
	AnsibleConfigFile  = "ansible/ansible.cfg"
	AnsibleInventories = "ansible/inventories/%s/ansible_hosts"
)
View Source
const (
	CatalogDestinationFile = "ansible/catalog.json"
)

Variables

This section is empty.

Functions

func CatalogHandler

func CatalogHandler(runnerService RunnerService) gin.HandlerFunc

func CreateInventory

func CreateInventory(destination string, content *InventoryContent) error

func ExecutionHandler

func ExecutionHandler(runnerService RunnerService) gin.HandlerFunc

func HealthHandler

func HealthHandler(c *gin.Context)

func NewCallbacksClient

func NewCallbacksClient(callbacksUrl string) *callbacksClient

func NewRunnerService

func NewRunnerService(config *Config) (*runnerService, error)

func ReadyHandler

func ReadyHandler(runnerService RunnerService) gin.HandlerFunc

Types

type AnsibleRunner

type AnsibleRunner struct {
	Playbook  string
	Inventory string
	Envs      map[string]string
	Check     bool
}

func DefaultAnsibleRunner

func DefaultAnsibleRunner() *AnsibleRunner

func NewAnsibleCheckRunner

func NewAnsibleCheckRunner(config *Config, executionEvent *ExecutionEvent) (*AnsibleRunner, error)

func NewAnsibleMetaRunner

func NewAnsibleMetaRunner(config *Config) (*AnsibleRunner, error)

func (*AnsibleRunner) RunPlaybook

func (a *AnsibleRunner) RunPlaybook() error

func (*AnsibleRunner) SetCatalogDestination

func (a *AnsibleRunner) SetCatalogDestination(destination string)

func (*AnsibleRunner) SetConfigFile

func (a *AnsibleRunner) SetConfigFile(confFile string)

func (*AnsibleRunner) SetInventory

func (a *AnsibleRunner) SetInventory(inventory string) error

func (*AnsibleRunner) SetPlaybook

func (a *AnsibleRunner) SetPlaybook(playbook string) error

func (*AnsibleRunner) SetTrentoCallbacksUrl

func (a *AnsibleRunner) SetTrentoCallbacksUrl(callbacksUrl string)

func (*AnsibleRunner) SetTrentoExecutionID

func (a *AnsibleRunner) SetTrentoExecutionID(executionID string)

type App

type App struct {
	Dependencies
	// contains filtered or unexported fields
}

func NewApp

func NewApp(config *Config) (*App, error)

func NewAppWithDeps

func NewAppWithDeps(config *Config, deps Dependencies) (*App, error)

func (*App) Start

func (a *App) Start(ctx context.Context) error

type CallbacksClient

type CallbacksClient interface {
	Callback(executionID uuid.UUID, event string, payload interface{}) error
}

type Catalog

type Catalog []*CatalogCheck

type CatalogCheck

type CatalogCheck struct {
	ID             string `json:"id,omitempty" binding:"required"`
	Name           string `json:"name,omitempty" binding:"required"`
	Group          string `json:"group" binding:"required"`
	Provider       string `json:"provider" binding:"required"`
	Description    string `json:"description,omitempty"`
	Remediation    string `json:"remediation,omitempty"`
	Implementation string `json:"implementation,omitempty"`
	Labels         string `json:"labels,omitempty"`
	Premium        bool   `json:"premium,omitempty"`
}

type Config

type Config struct {
	Host          string
	Port          int
	CallbacksUrl  string
	AnsibleFolder string
}

type CustomCommand

type CustomCommand func(name string, arg ...string) *exec.Cmd

type Dependencies

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

func DefaultDependencies

func DefaultDependencies(config *Config) Dependencies

type ExecutionEvent

type ExecutionEvent struct {
	ExecutionID uuid.UUID `json:"execution_id" binding:"required"`
	ClusterID   uuid.UUID `json:"cluster_id" binding:"required"`
	Provider    string    `json:"provider" binding:"required"`
	Checks      []string  `json:"checks" binding:"required"`
	Hosts       []*Host   `json:"hosts" binding:"required"`
}

type ExecutionWorkerPool

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

func NewExecutionWorkerPool

func NewExecutionWorkerPool(runnerService RunnerService) *ExecutionWorkerPool

func (*ExecutionWorkerPool) Run

func (e *ExecutionWorkerPool) Run(ctx context.Context)

Run runs a pool of workers to process the execution requests

type Group

type Group struct {
	Name  string
	Nodes []*Node
}

type Host

type Host struct {
	HostID  uuid.UUID `json:"host_id" binding:"required"`
	Address string    `json:"address" binding:"required"`
	User    string    `json:"user" binding:"required"`
}

type InventoryContent

type InventoryContent struct {
	Groups []*Group
	Nodes  []*Node // this seems unused
}

func NewClusterInventoryContent

func NewClusterInventoryContent(e *ExecutionEvent) (*InventoryContent, error)

type MockRunnerService

type MockRunnerService struct {
	mock.Mock
}

MockRunnerService is an autogenerated mock type for the RunnerService type

func (*MockRunnerService) BuildCatalog

func (_m *MockRunnerService) BuildCatalog() error

BuildCatalog provides a mock function with given fields:

func (*MockRunnerService) Execute

func (_m *MockRunnerService) Execute(e *ExecutionEvent) error

Execute provides a mock function with given fields: e

func (*MockRunnerService) GetCatalog

func (_m *MockRunnerService) GetCatalog() *Catalog

GetCatalog provides a mock function with given fields:

func (*MockRunnerService) GetChannel

func (_m *MockRunnerService) GetChannel() chan *ExecutionEvent

GetChannel provides a mock function with given fields:

func (*MockRunnerService) IsCatalogReady

func (_m *MockRunnerService) IsCatalogReady() bool

IsCatalogReady provides a mock function with given fields:

func (*MockRunnerService) ScheduleExecution

func (_m *MockRunnerService) ScheduleExecution(e *ExecutionEvent) error

ScheduleExecution provides a mock function with given fields: e

type Node

type Node struct {
	Name        string
	AnsibleHost string
	AnsibleUser string
	Variables   map[string]interface{}
}

type RunnerService

type RunnerService interface {
	IsCatalogReady() bool
	BuildCatalog() error
	GetCatalog() *Catalog
	GetChannel() chan *ExecutionEvent
	ScheduleExecution(e *ExecutionEvent) error
	Execute(e *ExecutionEvent) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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