engine

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main().

Types

type AnsibleTarget

type AnsibleTarget struct {
	// Where in the git repository to fetch a file or directory (to fetch all files in directory)
	TargetPath string `mapstructure:"targetPath"`
	// Schedule is how often to check for git updates with the target files
	// Must be valid cron expression
	Schedule string `mapstructure:"schedule"`
	// Number of seconds to skew the schedule by
	Skew *int `mapstructure:"skew"`
	// SshDirectory for ansible to connect to host
	SshDirectory string `mapstructure:"sshDirectory"`
	// contains filtered or unexported fields
}

AnsibleTarget to place and run ansible playbooks

type CleanTarget

type CleanTarget struct {
	// Schedule is how often to check for git updates and/or restart the fetchit service
	// Must be valid cron expression
	// With ConfigFileTarget, fetchit will be restarted with each scheduled run
	Schedule string `mapstructure:"schedule"`
	// Number of seconds to skew the schedule by
	Skew *int `mapstructure:"skew"`
	// URL location of config file, such as a raw github URL
	Volumes bool `mapstructure:"volumes"`
	// initialRun is set by fetchit
	All bool `mapstructure:"all"`
}

Clean configures targets to run a system prune periodically

type ConfigFileTarget

type ConfigFileTarget struct {
	// Schedule is how often to check for git updates and/or restart the fetchit service
	// Must be valid cron expression
	// With ConfigFileTarget, fetchit will be restarted with each scheduled run
	Schedule string `mapstructure:"schedule"`
	// Number of seconds to skew the schedule by
	Skew *int `mapstructure:"skew"`
	// URL location of config file, such as a raw github URL
	ConfigUrl string `mapstructure:"configUrl"`
	// contains filtered or unexported fields
}

type FetchitConfig

type FetchitConfig struct {
	Targets []*Target `mapstructure:"targets"`
	PAT     string    `mapstructure:"pat"`
	// contains filtered or unexported fields
}

FetchitConfig requires necessary objects to process targets

func NewFetchitConfig

func NewFetchitConfig() *FetchitConfig

func (*FetchitConfig) Apply

func (fc *FetchitConfig) Apply(
	ctx context.Context,
	mo *SingleMethodObj,
	currentState plumbing.Hash,
	desiredState plumbing.Hash,
	targetPath string,
	tags *[]string,
) error

Side effects are running/applying changes concurrently and on success moving old "current" tag

func (*FetchitConfig) CheckForConfigUpdates

func (hc *FetchitConfig) CheckForConfigUpdates(envURL string, existsAlready bool, initial bool) bool

CheckForConfigUpdates, downloads, & places config file in defaultConfigPath in fetchit container (/opt/mount/config.yaml). This runs with the initial startup as well as with scheduled ConfigTarget runs, if $FETCHIT_CONFIG_URL is set.

func (*FetchitConfig) EngineMethod

func (hc *FetchitConfig) EngineMethod(ctx context.Context, mo *SingleMethodObj, path string, change *object.Change) error

Each engineMethod call now owns the prev and dest variables instead of being shared in mo

func (*FetchitConfig) GetCurrent

func (fc *FetchitConfig) GetCurrent(target *Target, method string) (plumbing.Hash, error)

func (*FetchitConfig) GetLatest

func (fc *FetchitConfig) GetLatest(target *Target) (plumbing.Hash, error)

For any given target, will get the head of the branch in the repository specified by the target's url

func (*FetchitConfig) GetTargets

func (hc *FetchitConfig) GetTargets()

GetTargets returns map of repoName to map of method:Schedule

func (*FetchitConfig) InitConfig

func (hc *FetchitConfig) InitConfig(initial bool)

Initconfig reads in config file and env variables if set.

func (*FetchitConfig) Restart

func (hc *FetchitConfig) Restart()

restart fetches new targets from an updated config new targets will be added, stale removed, and existing will set last commit as last known.

func (*FetchitConfig) RunTargets

func (hc *FetchitConfig) RunTargets()

This assumes each Target has no more than 1 each of Raw, Systemd, FileTransfer

func (*FetchitConfig) UpdateCurrent

func (fc *FetchitConfig) UpdateCurrent(ctx context.Context, target *Target, method string, newCurrent plumbing.Hash) error

type FileTransferTarget

type FileTransferTarget struct {
	// Where in the git repository to fetch a file or directory (to fetch all files in directory)
	TargetPath string `mapstructure:"targetPath"`
	// Directory path on the host system in which the target files should be placed
	DestinationDirectory string `mapstructure:"destinationDirectory"`
	// Schedule is how often to check for git updates to the target files
	// Must be valid cron expression
	Schedule string `mapstructure:"schedule"`
	// Number of seconds to skew the schedule by
	Skew *int `mapstructure:"skew"`
	// contains filtered or unexported fields
}

FileTransferTarget to place files on host system

type KubeTarget

type KubeTarget struct {
	// Where in the git repository to fetch a file or directory (to fetch all files in directory)
	TargetPath string `mapstructure:"targetPath"`
	// Schedule is how often to check for git updates with the target files
	// Must be valid cron expression
	Schedule string `mapstructure:"schedule"`
	// Number of seconds to skew the schedule by
	Skew *int `mapstructure:"skew"`
	// contains filtered or unexported fields
}

KubeTarget to launch pods using podman kube-play

type Methods

type Methods struct {
	Raw          *RawTarget          `mapstructure:"raw"`
	Systemd      *SystemdTarget      `mapstructure:"systemd"`
	Kube         *KubeTarget         `mapstructure:"kube"`
	Ansible      *AnsibleTarget      `mapstructure:"ansible"`
	FileTransfer *FileTransferTarget `mapstructure:"fileTransfer"`
	Clean        *CleanTarget        `mapstructure:"clean"`
	ConfigTarget *ConfigFileTarget   `mapstructure:"configTarget"`
}

Only 1 of each Method per Methods

type RawPod

type RawPod struct {
	Image   string            `json:"Image" yaml:"Image"`
	Name    string            `json:"Name" yaml:"Name"`
	Env     map[string]string `json:"Env" yaml:"Env"`
	Ports   []port            `json:"Ports" yaml:"Ports"`
	Mounts  []mount           `json:"Mounts" yaml:"Mounts"`
	Volumes []namedVolume     `json:"Volumes" yaml:"Volumes"`
	CapAdd  []string          `json:"CapAdd" yaml:"CapAdd"`
	CapDrop []string          `json:"CapDrop" yaml:"CapDrop"`
}

type RawTarget

type RawTarget struct {
	// Where in the git repository to fetch a file or directory (to fetch all files in directory)
	TargetPath string `mapstructure:"targetPath"`
	// Schedule is how often to check for git updates to the unit file
	// Must be valid cron expression
	Schedule string `mapstructure:"schedule"`
	// Number of seconds to skew the schedule by
	Skew *int `mapstructure:"skew"`
	// Pull images configured in target files each time regardless of if it already exists
	PullImage bool `mapstructure:"pullImage"`
	// contains filtered or unexported fields
}

RawTarget to deploy pods from json or yaml files

type SingleMethodObj

type SingleMethodObj struct {
	// Conn holds the podman client
	Conn   context.Context
	Method string
	Target *Target
}

type SystemdTarget

type SystemdTarget struct {
	// AutoUpdateAll will start podman-auto-update.service, podman-auto-update.timer
	// on the host. With this field true, all other fields are ignored. To place unit files
	// on host and/or enable individual services, create a separate Target.Methods.Systemd
	// 'podman auto-update' updates all services running podman with the autoupdate label
	// see https://docs.podman.io/en/latest/markdown/podman-auto-update.1.html#systemd-unit-and-timer
	// TODO: update /etc/systemd/system/podman-auto-update.timer.d/override.conf with schedule
	// By default, podman will auto-update at midnight daily when this service is running
	AutoUpdateAll bool `mapstructure:"autoUpdateAll"`
	// Where in the git repository to fetch a systemd unit file
	// All '*.service' files will be placed in appropriate systemd path
	// TargetPath must be a single exact file
	TargetPath string `mapstructure:"targetPath"`
	// If true, will place unit file in /etc/systemd/system/
	// If false (default) will place unit file in ~/.config/systemd/user/
	Root bool `mapstructure:"root"`
	// If true, will enable and start all systemd services from fetched unit files
	// If true, will reload and restart the services with every scheduled run
	// Implies Enable=true, will override Enable=false
	Restart bool `mapstructure:"restart"`
	// If true, will enable and start systemd services from fetched unit files
	// If false (default), will place unit file(s) in appropriate systemd path
	Enable bool `mapstructure:"enable"`
	// Schedule is how often to check for git updates to the unit file
	// and/or how often to restart services.
	// Must be valid cron expression
	Schedule string `mapstructure:"schedule"`
	// Number of seconds to skew the schedule by
	Skew *int `mapstructure:"skew"`
	// contains filtered or unexported fields
}

SystemdTarget to place and/or enable systemd unit files on host

type Target

type Target struct {
	Name    string  `mapstructure:"name"`
	Url     string  `mapstructure:"url"`
	Branch  string  `mapstructure:"branch"`
	Methods Methods `mapstructure:"methods"`
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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