core

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package core Module file

This file contains everything directly related to handling a Module model.

Package core Systems file

This file contains structs relative to the operating system that we are setting up. As well as functions to validate and set the target system.

Index

Constants

View Source
const ModuleNotFoundError string = "no module found"

Variables

View Source
var CurrentState = coreConfig{
	Config: Config{ModuleRegistry: ModuleRegistry},
	System: System{
		Name:   runtime.GOOS,
		Runner: NormalRunner{},
	},
}

CurrentState The state of the app.

View Source
var ModuleRegistry = &Registry{
	make(map[string]Module),
}

ModuleRegistry This is the ModuleRegistry for the running application.

Functions

This section is empty.

Types

type Config

type Config struct {
	ModuleRegistry *Registry
}

Config The entire Config YAML.

func (*Config) ReadConfigFromFile

func (conf *Config) ReadConfigFromFile(filePath string) (err error)

ReadConfigFromFile Attempts to read the file at filePath and set the settings for each module using the file and yaml.Unmarshal.

func (*Config) WriteConfigToFile

func (conf *Config) WriteConfigToFile() (err error)

WriteConfigToFile will generate a YAML file using the defaults we outline.

type Module

type Module interface {
	ParseSettings(map[string]interface{}) error
	Config() ModuleConfig
	Setup() error
	TearDown() error
	Update() error
}

Module Any struct that implements these methods can be considered a module.

type ModuleConfig

type ModuleConfig struct {
	Priority int
	Enabled  bool
	Settings interface{}
}

ModuleConfig General items we may need to track for each module.

type NormalRunner added in v0.1.1

type NormalRunner struct{}

NormalRunner cmdRunner implementation that doesn't use sudo.

func (NormalRunner) Command added in v0.1.1

func (r NormalRunner) Command(name string, arg ...string) *exec.Cmd

Command Uses sudo to run command name with args arg.

type Registry

type Registry struct {
	Modules map[string]Module
}

Registry This registry contains Modules. The Modules take a string and map it to a Module.

func NewModuleRegistry

func NewModuleRegistry() *Registry

func (*Registry) Get

func (mr *Registry) Get(mod string) (Module, error)

Get This gets a module from an existing registry.

func (*Registry) Register

func (mr *Registry) Register(name string, mod Module)

Register This adds a new module to an existing registry.

func (*Registry) RunSetup

func (mr *Registry) RunSetup() (err error)

RunSetup Runs the Setup method on each Registry.Modules

func (*Registry) RunTeardown

func (mr *Registry) RunTeardown() (err error)

RunTeardown Runs the Setup method on each Registry.Modules

func (*Registry) RunUpdate

func (mr *Registry) RunUpdate() (err error)

RunUpdate Runs the Setup method on each Registry.Modules

type SudoRunner

type SudoRunner struct{}

SudoRunner cmdRunner implementation that uses sudo.

func (SudoRunner) Command

func (r SudoRunner) Command(name string, arg ...string) *exec.Cmd

Command Uses sudo to run command name with args arg.

type System

type System struct {
	Name   string
	Runner cmdRunner
}

System contains the name of the operating system and the configs we want to configure for said OS.

func (System) Exec

func (os System) Exec(command string, args []string) ([]byte, error)

Exec executes the command string.

Jump to

Keyboard shortcuts

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