polis

package
v0.0.0-...-def9c51 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Success = 0
	Failure = 1
	Changed = 2
)

Variables

This section is empty.

Functions

func ExecuteCommand

func ExecuteCommand(cmdString string) (int, error)

Generic function that can be used to execute bash commands

Types

type File

type File struct {
	Path     string      `yaml:"Path"`
	Contents string      `yaml:"Contents"`
	Owner    string      `yaml:"Owner"`
	Group    string      `yaml:"Group"`
	Perm     fs.FileMode `yaml:"Perm"`
}

func (File) Apply

func (f File) Apply() (Status, error)

*

  • This creates a file if the file does not exist with given permissions, contents, owner and group

func (File) Check

func (f File) Check() bool

*

  • This checks if the file exists with given permissions, contents, owner and group

func (File) TriggerExec

func (f File) TriggerExec(Trigger string) (Status, error)

*

  • This is not implemented since there does not seem to be usecase to trigger a file module

func (File) UnApply

func (f File) UnApply() (Status, error)

*

  • This will delete the file

type Module

type Module interface {
	Apply() (Status, error)
	Check() bool
	TriggerExec(string) (Status, error)
	UnApply() (Status, error)
}

type Package

type Package struct {
	Name   string `yaml:"Name"`
	Ensure bool   `yaml:"Ensure"`
}

func (Package) Apply

func (p Package) Apply() (Status, error)

*

  • This will ensure to install the package if its not installed

func (Package) Check

func (p Package) Check() bool

*

  • This will check if the package is already installed

func (Package) TriggerExec

func (p Package) TriggerExec(Trigger string) (Status, error)

*

  • This is not implemented since there does not seem to be usecase to trigger a package module

func (Package) UnApply

func (p Package) UnApply() (Status, error)

*

  • This will remove and purge the package

type Polis

type Polis struct {
	ModuleType    string `yaml:"ModuleType"`    // Type of module: File, Service, Package
	Ensure        bool   `yaml:"Ensure"`        // Ensure to be present or absent
	Triggers      string `yaml:"Triggers"`      // ID of the module to be triggered
	TriggerAction string `yaml:"TriggerAction"` // If this module is triggered, what should be the action to be taken
	Module        Module `yaml:"Module"`        // Module spec File, Service or Package
}

Base polis struct which is the generic state

func (Polis) Execute

func (p Polis) Execute() (string, error)

Execute a specific module

type Service

type Service struct {
	Name string `yaml:"Name"`
}

func (Service) Apply

func (s Service) Apply() (Status, error)

*

  • This applies the service module by starting the service if the service is not up and running

func (Service) Check

func (s Service) Check() bool

*

  • This checks if the service is running

func (Service) TriggerExec

func (s Service) TriggerExec(Trigger string) (Status, error)

*

  • This triggers the execution of the service module which essentially restarts the service

func (Service) UnApply

func (s Service) UnApply() (Status, error)

*

  • This unapplies the service module which essentially stops the service

type Status

type Status int

Jump to

Keyboard shortcuts

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