dogeboxd

package
v0.0.0-...-29ea39b Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureSkel

func EnsureSkel(path string)

func RESTAPI

func RESTAPI(config ServerConfig, dbx Dogeboxd, ws WSRelay) conductor.Service

func Server

func Server(config ServerConfig) server

func WriteContainerConfig

func WriteContainerConfig()

Types

type Action

type Action any

Actions are passed to the dogeboxd service via its * AddAction method, and represent tasks that need to * be done such as installing a package, starting or * stopping a service etc.

type Change

type Change struct {
	ID     string `json:"id"`
	Error  string `json:"error"`
	Type   string `json:"type"`
	Update any    `json:"update"`
}

type CommandManifest

type CommandManifest struct {
	Path        string            `json:"path"`
	Args        string            `json:"args"`
	CWD         string            `json:"cwd"`
	ENV         map[string]string `json:"env"`
	Config      ConfigFields      `json:"config"`
	ConfigFiles []ConfigFile      `json:"configFiles"`
}

Represents the command to run inside this PUP * Container.

type ConfigFields

type ConfigFields struct {
	Sections []struct {
		Name   string                   `json:"name"`
		Label  string                   `json:"label"`
		Fields []map[string]interface{} `json:"fields"`
	} `json:"sections"`
}

Represents fields that are user settable, which provide the values * for templates (Args, ENV, ConfigFiles), we only care about Name

type ConfigFile

type ConfigFile struct {
	Template string
	Path     string
}

Represents a Config file that needs to be written * inside the DRE filesystem at Path, Template is a * text/template string which will be filled with * values provided by CommandManifest.Config.

type Dogeboxd

type Dogeboxd struct {
	Manifests map[string]ManifestSource
	Pups      map[string]PupStatus
	Internal  *InternalState

	Changes chan Change
	// contains filtered or unexported fields
}

func NewDogeboxd

func NewDogeboxd(pupDir string) Dogeboxd

func (Dogeboxd) AddAction

func (t Dogeboxd) AddAction(a Action) string

Add an Action to the Action queue, returns a unique ID which can be used to match the outcome in the Event queue

func (Dogeboxd) GetManifests

func (t Dogeboxd) GetManifests() map[string]ManifestSource

func (Dogeboxd) GetPupStats

func (t Dogeboxd) GetPupStats() map[string]PupStatus

func (Dogeboxd) Run

func (t Dogeboxd) Run(started, stopped chan bool, stop chan context.Context) error

type InstallPup

type InstallPup struct {
	PupID string
}

type InternalState

type InternalState struct {
	ActionCounter int
	InstalledPups []string
}

InternalState is stored in dogeboxd.gob and contains various details about what's installed, what condition we're in overall etc.

type Job

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

type LoadLocalPup

type LoadLocalPup struct {
	Path string
}

Instruct dogeboxd to load/reload a local (dev) PUP presumably because there have been changes to the manifest.

type ManifestSource

type ManifestSource struct {
	ID          string        `json:"id"`
	Label       string        `json:"label"`
	URL         string        `json:"url"`
	LastUpdated time.Time     `json:"lastUpdated"`
	Available   []PupManifest `json:"available"`
}

A ManifestSource is a .. well, it's a source of manifests, derp.

func (ManifestSource) UpdateAvailable

func (t ManifestSource) UpdateAvailable(sourceID string, l []PupManifest)

Append or replace available pups

type PupManifest

type PupManifest struct {
	ID      string          `json:"id"`
	Package string          `json:"package"` // ie:  dogecoin-core
	Hash    string          `json:"hash"`    // package checksum
	Command CommandManifest `json:"command"`
	// contains filtered or unexported fields
}

PupManifest represents a Nix installed process * running inside the Dogebox Runtime Environment. * These are defined in pup.json files.

func FindLocalPups

func FindLocalPups(path string) (pups []PupManifest)

func (*PupManifest) Hydrate

func (t *PupManifest) Hydrate(sourceID string)

This is called when a Pup is loaded from storage, JSON/GOB etc.

type PupStatus

type PupStatus struct {
	ID           string               `json:"id"`
	Stats        map[string][]float32 `json:"stats"`
	Config       map[string]string    `json:"config"`
	Installation string               `json:"installation"`
	Status       string               `json:"status"`
	// contains filtered or unexported fields
}

PupStatus is persisted to disk

func NewPUPStatus

func NewPUPStatus(pupDir string, m PupManifest) PupStatus

func (*PupStatus) Read

func (t *PupStatus) Read() error

Read state from a gob file

func (PupStatus) Write

func (t PupStatus) Write() error

write state to a gob file

type RestartPup

type RestartPup struct {
	PupID string
}

type ServerConfig

type ServerConfig struct {
	PupDir  string
	Bind    string
	Port    int
	Verbose bool
}

type StartPup

type StartPup struct {
	PupID string
}

type StopPup

type StopPup struct {
	PupID string
}

type SystemJobber

type SystemJobber interface {
	AddJob(Job)
	GetUpdateChannel() chan Job
}

type UninstallPup

type UninstallPup struct {
	PupID string
}

type UpdatePupConfig

type UpdatePupConfig struct {
	PupID   string
	Payload map[string]string
}

type WSCONN

type WSCONN struct {
	WS   *websocket.Conn
	Stop chan bool
	// contains filtered or unexported fields
}

func (*WSCONN) Close

func (t *WSCONN) Close()

type WSRelay

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

func NewWSRelay

func NewWSRelay(relay chan Change) WSRelay

func (*WSRelay) AddSock

func (t *WSRelay) AddSock(ws WSCONN)

func (*WSRelay) Broadcast

func (t *WSRelay) Broadcast(v any)

func (WSRelay) GetWSHandler

func (t WSRelay) GetWSHandler(initialPayloader func() any) *websocket.Server

func (WSRelay) Run

func (t WSRelay) Run(started, stopped chan bool, stop chan context.Context) error

type Watcher

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

Watcher Service monitors important files and updates State as needed

func NewWatcher

func NewWatcher(pupDir string) Watcher

func (Watcher) Run

func (t Watcher) Run(started, stopped chan bool, stop chan context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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