dogeboxd

package
v0.0.0-...-706fd46 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATE_INSTALLING   string = "installing"
	STATE_READY        string = "ready"
	STATE_UNREADY      string = "unready"
	STATE_UNINSTALLING string = "uninstalling"
	STATE_UNINSTALLED  string = "uninstalled"
	STATE_PURGING      string = "purging"
	STATE_BROKEN       string = "broken"
	STATE_STOPPED      string = "stopped"
	STATE_STARTING     string = "starting"
	STATE_RUNNING      string = "running"
	STATE_STOPPING     string = "stopping"
)

Pup states

View Source
const (
	BROKEN_REASON_STATE_UPDATE_FAILED          string = "state_update_failed"
	BROKEN_REASON_DOWNLOAD_FAILED              string = "download_failed"
	BROKEN_REASON_NIX_FILE_MISSING             string = "nix_file_missing"
	BROKEN_REASON_NIX_HASH_MISMATCH            string = "nix_hash_mismatch"
	BROKEN_REASON_STORAGE_CREATION_FAILED      string = "storage_creation_failed"
	BROKEN_REASON_DELEGATE_KEY_CREATION_FAILED string = "delegate_key_creation_failed"
	BROKEN_REASON_DELEGATE_KEY_WRITE_FAILED    string = "delegate_key_write_failed"
	BROKEN_REASON_ENABLE_FAILED                string = "enable_failed"
	BROKEN_REASON_NIX_APPLY_FAILED             string = "nix_apply_failed"
)

Pup broken reasons

View Source
const (
	PUP_CHANGED_INSTALLATION int = iota
	PUP_ADOPTED                  = iota
)

Variables

View Source
var (
	ErrPupNotFound      = errors.New("pup not found")
	ErrPupAlreadyExists = errors.New("pup already exists")
)

PupManager Errors

Functions

func GetSystemEnvironmentVariablesForContainer

func GetSystemEnvironmentVariablesForContainer() map[string]string

func NewActionLogger

func NewActionLogger(j Job, pupID string, dbx Dogeboxd) *actionLogger

func PupEnabled

func PupEnabled(b bool) func(*PupState, *[]Pupdate)

func ServeUI

func ServeUI(config ServerConfig) conductor.Service

func SetPupBrokenReason

func SetPupBrokenReason(reason string) func(*PupState, *[]Pupdate)

func SetPupConfig

func SetPupConfig(newFields map[string]string) func(*PupState, *[]Pupdate)

func SetPupHooks

func SetPupHooks(newHooks []PupHook) func(*PupState, *[]Pupdate)

func SetPupInstallation

func SetPupInstallation(state string) func(*PupState, *[]Pupdate)

func SetPupProviders

func SetPupProviders(newProviders map[string]string) func(*PupState, *[]Pupdate)

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 ActionLogger

type ActionLogger interface {
	Progress(p int)
	Step(step string) SubLogger
}

type ActionProgress

type ActionProgress struct {
	ActionID  string        `json:"actionID"`
	PupID     string        `json:pupID`        // optional, only if a pup action
	Progress  int           `json:"progress"`   // 0-100
	Step      string        `json:"step"`       // a unique name for the step we're up to, ie: installing
	Msg       string        `json:"msg"`        // the message line
	Error     bool          `json:"error"`      // if this represents an error or not
	StepTaken time.Duration `json:"step_taken"` // time taken from previous step
}

Represents some information about an action underway

type AddSSHKey

type AddSSHKey struct {
	Key string
}

type BootstrapInstallationMode

type BootstrapInstallationMode string
const (
	BootstrapInstallationModeIsInstalled   BootstrapInstallationMode = "isInstalled"
	BootstrapInstallationModeCanInstalled  BootstrapInstallationMode = "canInstall"
	BootstrapInstallationModeMustInstall   BootstrapInstallationMode = "mustInstall"
	BootstrapInstallationModeCannotInstall BootstrapInstallationMode = "cannotInstall"
)

type Buffer

type Buffer[T any] struct {
	Values []T
	Tail   int
}

func NewBuffer

func NewBuffer[T any](size int) *Buffer[T]

func (*Buffer[T]) Add

func (b *Buffer[T]) Add(value T)

func (*Buffer[T]) GetValues

func (b *Buffer[T]) GetValues() []T

func (*Buffer[T]) MarshalJSON

func (b *Buffer[T]) MarshalJSON() ([]byte, error)

type Change

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

A Change can be the result of a Job (same ID) or represent an internal system change originating from elsewhere.

A Change encodes an 'update' (see below) A Change as the result of an Action may carry an 'error' to the frontend for the same Job ID

type ConsoleSubLogger

type ConsoleSubLogger struct {
	PupID string
	// contains filtered or unexported fields
}

func NewConsoleSubLogger

func NewConsoleSubLogger(pupID string, step string) *ConsoleSubLogger

func (*ConsoleSubLogger) Err

func (t *ConsoleSubLogger) Err(msg string)

func (*ConsoleSubLogger) Errf

func (t *ConsoleSubLogger) Errf(msg string, a ...any)

func (*ConsoleSubLogger) Log

func (t *ConsoleSubLogger) Log(msg string)

func (*ConsoleSubLogger) LogCmd

func (t *ConsoleSubLogger) LogCmd(cmd *exec.Cmd)

func (*ConsoleSubLogger) Logf

func (t *ConsoleSubLogger) Logf(msg string, a ...any)

func (*ConsoleSubLogger) Progress

func (t *ConsoleSubLogger) Progress(p int) SubLogger

type DKMErrorResponse

type DKMErrorResponse struct {
	Error  string `json:"error"`
	Reason string `json:"reason"`
}

type DKMErrorResponseMakeDelegate

type DKMErrorResponseMakeDelegate struct {
	Error  string `json:"error"`
	Reason string `json:"reason"`
}

type DKMManager

type DKMManager interface {
	CreateKey(password string) ([]string, error)
	// Returns "" as a token if the password supplied is invalid.
	Authenticate(password string) (string, error, error)
	RefreshToken(old string) (string, bool, error)
	InvalidateToken(token string) (bool, error)
	MakeDelegate(id string, token string) (DKMResponseMakeDelegate, error)
}

func NewDKMManager

func NewDKMManager() DKMManager

type DKMRequestMakeDelegate

type DKMRequestMakeDelegate struct {
	ID    string `json:"id"`
	Token string `json:"token"`
}

type DKMResponseAuthenticate

type DKMResponseAuthenticate struct {
	AuthenticationToken string `json:"token"`
	ValidFor            int    `json:"valid_for"`
}

type DKMResponseCreateKey

type DKMResponseCreateKey struct {
	SeedPhrase []string `json:"seedphrase"`
}

type DKMResponseInvalidateToken

type DKMResponseInvalidateToken struct{}

type DKMResponseMakeDelegate

type DKMResponseMakeDelegate struct {
	Pub  string `json:"pub"`
	Priv string `json:"priv"`
	Wif  string `json:"wif"`
}

type DisablePup

type DisablePup struct {
	PupID string
}

Disable (stop) a running pup

type DisableSSH

type DisableSSH struct{}

type DogeboxState

type DogeboxState struct {
	InitialState  DogeboxStateInitialSetup
	Hostname      string
	KeyMap        string
	SSH           DogeboxStateSSHConfig
	StorageDevice string
}

type DogeboxStateInitialSetup

type DogeboxStateInitialSetup struct {
	HasGeneratedKey    bool `json:"hasGeneratedKey"`
	HasSetNetwork      bool `json:"hasSetNetwork"`
	HasFullyConfigured bool `json:"hasFullyConfigured"`
}

type DogeboxStateSSHConfig

type DogeboxStateSSHConfig struct {
	Enabled bool                 `json:"enabled"`
	Keys    []DogeboxStateSSHKey `json:"keys"`
}

type DogeboxStateSSHKey

type DogeboxStateSSHKey struct {
	ID  string `json:"id"`
	Key string `json:"key"`
}

type Dogeboxd

type Dogeboxd struct {
	Pups           PupManager
	SystemUpdater  SystemUpdater
	SystemMonitor  SystemMonitor
	JournalReader  JournalReader
	NetworkManager NetworkManager

	Changes chan Change
	// contains filtered or unexported fields
}

func NewDogeboxd

func NewDogeboxd(
	stateManager StateManager,
	pups PupManager,
	updater SystemUpdater,
	monitor SystemMonitor,
	journal JournalReader,
	networkManager NetworkManager,
	sourceManager SourceManager,
	nixManager NixManager,
	logtailer LogTailer,
) 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) GetLogChannel

func (t Dogeboxd) GetLogChannel(PupID string) (context.CancelFunc, chan string, error)

func (Dogeboxd) Run

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

Main Dogeboxd goroutine, handles routing messages in and out of the system via job and change channels, handles messages from subsystems ie: SystemUpdater, SysteMonitor etc.

type EnablePup

type EnablePup struct {
	PupID string
}

Enable a previously disabled pup

type EnableSSH

type EnableSSH struct{}

type EnvEntry

type EnvEntry struct {
	KEY string
	VAL string
}

type InstallPup

type InstallPup struct {
	PupName      string
	PupVersion   string
	SourceId     string
	SessionToken string
}

Install a pup on the system

type Job

type Job struct {
	A       Action
	ID      string
	Err     string
	Success any
	Start   time.Time // set when the job is first created, for calculating duration
	Logger  *actionLogger
	State   *PupState // nilable, check before use!
}

A Job is created when an Action is recieved by the system. Jobs are passed through the Dogeboxd service and result in a Change being send to the client via websockets.

type JournalReader

type JournalReader interface {
	GetJournalChan(string) (context.CancelFunc, chan string, error)
}

actively listen for systemd journal entries for a given systemd service, close channel when done

type LifecycleManager

type LifecycleManager interface {
	Shutdown()
	Reboot()
}

type LineWriter

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

func NewLineWriter

func NewLineWriter(receiver func(string)) *LineWriter

implements io.Writer and calls a function for each line

func (*LineWriter) Write

func (t *LineWriter) Write(p []byte) (int, error)

type LogTailer

type LogTailer interface {
	GetChan(string) (context.CancelFunc, chan string, error)
}

type ManifestSource

type ManifestSource interface {
	ValidateFromLocation(location string) (ManifestSourceConfiguration, error)
	Config() ManifestSourceConfiguration
	List(ignoreCache bool) (ManifestSourceList, error)
	Download(diskPath string, remoteLocation map[string]string) error
}

type ManifestSourceConfiguration

type ManifestSourceConfiguration struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Location    string `json:"location"`
	Type        string `json:"type"`
}

type ManifestSourceList

type ManifestSourceList struct {
	Config      ManifestSourceConfiguration
	LastChecked time.Time
	Pups        []ManifestSourcePup
}

type ManifestSourcePup

type ManifestSourcePup struct {
	Name       string
	Location   map[string]string
	Version    string
	Manifest   PupManifest
	LogoBase64 string
}

type NetworkConnection

type NetworkConnection interface {
	// contains filtered or unexported methods
}

type NetworkConnector

type NetworkConnector interface {
	Connect(network SelectedNetwork) error
}

type NetworkEthernet

type NetworkEthernet struct {
	Type      string `json:"type"`
	Interface string `json:"interface"`
}

type NetworkManager

type NetworkManager interface {
	GetAvailableNetworks() []NetworkConnection
	SetPendingNetwork(selectedNetwork SelectedNetwork, j Job) error
	TryConnect(nixPatch NixPatch) error
	GetLocalIP() (net.IP, error)
}

type NetworkPersistor

type NetworkPersistor interface {
	Persist(nixPatch NixPatch, network SelectedNetwork)
}

type NetworkState

type NetworkState struct {
	CurrentNetwork SelectedNetwork
	PendingNetwork SelectedNetwork
}

type NetworkWifi

type NetworkWifi struct {
	Type      string            `json:"type"`
	Interface string            `json:"interface"`
	Ssids     []NetworkWifiSSID `json:"ssids"`
}

type NetworkWifiSSID

type NetworkWifiSSID struct {
	Ssid       string `json:"ssid"`
	Bssid      string `json:"bssid"` // TODO: this should probably not be a string?
	Encryption string `json:"encryption,omitempty"`
}

type NixFirewallTemplateValues

type NixFirewallTemplateValues struct {
	SSH_ENABLED bool
	PUP_PORTS   []struct {
		PORT   int
		PUBLIC bool
		PUP_ID string
	}
}

type NixIncludesFileTemplateValues

type NixIncludesFileTemplateValues struct {
	NIX_DIR string
	PUP_IDS []string
}

type NixManager

type NixManager interface {
	// NixPatch passthrough helpers.
	InitSystem(patch NixPatch, dbxState DogeboxState)
	UpdateIncludesFile(patch NixPatch, pups PupManager)
	WritePupFile(patch NixPatch, state PupState, dbxState DogeboxState)
	RemovePupFile(patch NixPatch, pupId string)
	UpdateSystemContainerConfiguration(patch NixPatch)
	UpdateFirewallRules(patch NixPatch, dbxState DogeboxState)
	UpdateNetwork(patch NixPatch, values NixNetworkTemplateValues)
	UpdateSystem(patch NixPatch, values NixSystemTemplateValues)
	UpdateStorageOverlay(patch NixPatch, partitionName string)

	RebuildBoot(log SubLogger) error
	Rebuild(log SubLogger) error

	NewPatch(log SubLogger) NixPatch
}

type NixNetworkTemplateValues

type NixNetworkTemplateValues struct {
	USE_ETHERNET  bool
	USE_WIRELESS  bool
	INTERFACE     string
	WIFI_SSID     string
	WIFI_PASSWORD string
}

type NixPatch

type NixPatch interface {
	State() string
	Apply() error
	ApplyCustom(options NixPatchApplyOptions) error

	Cancel() error

	UpdateSystemContainerConfiguration(values NixSystemContainerConfigTemplateValues)
	UpdateFirewall(values NixFirewallTemplateValues)
	UpdateSystem(values NixSystemTemplateValues)
	UpdateNetwork(values NixNetworkTemplateValues)
	UpdateIncludesFile(values NixIncludesFileTemplateValues)
	WritePupFile(pupId string, values NixPupContainerTemplateValues)
	RemovePupFile(pupId string)
	UpdateStorageOverlay(values NixStorageOverlayTemplateValues)
}

type NixPatchApplyOptions

type NixPatchApplyOptions struct {
	RebuildBoot        bool
	DangerousNoRebuild bool
}

type NixPupContainerServiceValues

type NixPupContainerServiceValues struct {
	NAME string
	EXEC string
	CWD  string
	ENV  []EnvEntry
}

type NixPupContainerTemplateValues

type NixPupContainerTemplateValues struct {
	DATA_DIR          string
	CONTAINER_LOG_DIR string
	PUP_ID            string
	PUP_ENABLED       bool
	INTERNAL_IP       string
	PUP_PORTS         []struct {
		PORT   int
		PUBLIC bool
	}
	STORAGE_PATH string
	PUP_PATH     string
	NIX_FILE     string
	SERVICES     []NixPupContainerServiceValues
	PUP_ENV      []EnvEntry
	GLOBAL_ENV   []EnvEntry
}

type NixStorageOverlayTemplateValues

type NixStorageOverlayTemplateValues struct {
	STORAGE_DEVICE string
	DATA_DIR       string
	DBX_UID        string
}

type NixSystemContainerConfigTemplatePupRequiresInternet

type NixSystemContainerConfigTemplatePupRequiresInternet struct {
	PUP_ID string
	PUP_IP string
}

type NixSystemContainerConfigTemplatePupTcpConnection

type NixSystemContainerConfigTemplatePupTcpConnection struct {
	NAME       string
	ID         string
	IP         string
	OTHER_PUPS []NixSystemContainerConfigTemplatePupTcpConnectionOtherPup
}

type NixSystemContainerConfigTemplatePupTcpConnectionOtherPup

type NixSystemContainerConfigTemplatePupTcpConnectionOtherPup struct {
	NAME  string
	ID    string
	IP    string
	PORTS []struct {
		PORT int
	}
}

type NixSystemContainerConfigTemplateValues

type NixSystemContainerConfigTemplateValues struct {
	DOGEBOX_HOST_IP         string
	DOGEBOX_CONTAINER_CIDR  string
	PUPS_REQUIRING_INTERNET []NixSystemContainerConfigTemplatePupRequiresInternet
	PUPS_TCP_CONNECTIONS    []NixSystemContainerConfigTemplatePupTcpConnection
}

type NixSystemTemplateValues

type NixSystemTemplateValues struct {
	SYSTEM_HOSTNAME string
	KEYMAP          string
	SSH_ENABLED     bool
	SSH_KEYS        []DogeboxStateSSHKey
}

type ProcStatus

type ProcStatus struct {
	CPUPercent float64
	MEMPercent float64
	MEMMb      float64
	Running    bool
}

SystemMonitor issues these for monitored PUPs

type PupAsset

type PupAsset struct {
	Logos PupLogos `json:"logos"`
}

type PupDependencyReport

type PupDependencyReport struct {
	Interface             string                        `json:"interface"`
	Version               string                        `json:"version"`
	Optional              bool                          `json:"optional"`
	CurrentProvider       string                        `json:"currentProvider"`
	InstalledProviders    []string                      `json:"installedProviders"`
	InstallableProviders  []PupManifestDependencySource `json:"InstallableProviders"`
	DefaultSourceProvider PupManifestDependencySource   `json:"DefaultProvider"`
}

type PupHealthStateReport

type PupHealthStateReport struct {
	Issues    PupIssues
	NeedsConf bool
	NeedsDeps bool
}

type PupHook

type PupHook struct {
	Port int    `json:"port"`
	Path string `json:"path"`
	ID   string `json:"id"`
}

type PupIssues

type PupIssues struct {
	DepsNotRunning   []string `json:"depsNotRunning"`
	HealthWarnings   []string `json:"healthWarnings"`
	UpgradeAvaialble bool     `json:"upgradeAvailable"`
}

type PupLogos

type PupLogos struct {
	MainLogoBase64 string `json:"mainLogoBase64"`
}

type PupManager

type PupManager interface {
	// Run starts the PupManager as a service.
	Run(started, stopped chan bool, stop chan context.Context) error

	// GetUpdateChannel returns a channel for receiving pup updates.
	GetUpdateChannel() chan Pupdate

	// GetStatsChannel returns a channel for receiving pup stats.
	GetStatsChannel() chan []PupStats

	// GetStateMap returns a map of all pup states.
	GetStateMap() map[string]PupState

	// GetStatsMap returns a map of all pup stats.
	GetStatsMap() map[string]PupStats

	// GetAssetsMap returns a map of pup assets like logos.
	GetAssetsMap() map[string]PupAsset

	// AdoptPup adds a new pup from a manifest. It returns the PupID and an error if any.
	AdoptPup(m PupManifest, source ManifestSource) (string, error)

	// UpdatePup updates the state of a pup with provided update functions.
	UpdatePup(id string, updates ...func(*PupState, *[]Pupdate)) (PupState, error)

	// PurgePup removes a pup and its state from the manager.
	PurgePup(pupId string) error

	// GetPup retrieves the state and stats for a specific pup by ID.
	GetPup(id string) (PupState, PupStats, error)

	// FindPupByIP retrieves a pup by its assigned IP address.
	FindPupByIP(ip string) (PupState, PupStats, error)

	// GetAllFromSource retrieves all pups from a specific source.
	GetAllFromSource(source ManifestSourceConfiguration) []*PupState

	// GetPupFromSource retrieves a specific pup by name from a source.
	GetPupFromSource(name string, source ManifestSourceConfiguration) *PupState

	// GetMetrics retrieves the metrics for a specific pup.
	GetMetrics(pupId string) map[string]interface{}

	// UpdateMetrics updates the metrics for a pup based on provided data.
	UpdateMetrics(u UpdateMetrics)

	// CanPupStart checks if a pup can start based on its current state and dependencies.
	CanPupStart(pupId string) (bool, error)

	// CalculateDeps calculates the dependencies for a pup.
	CalculateDeps(pupID string) ([]PupDependencyReport, error)

	// SetSourceManager sets the SourceManager for the PupManager.
	SetSourceManager(sourceManager SourceManager)

	// FastPollPup initiates a rapid polling of a specific pup for debugging or immediate updates.
	FastPollPup(pupId string)

	GetPupSpecificEnvironmentVariablesForContainer(pupID string) map[string]string
}

The PupManager is responsible for all aspects of the pup lifecycle * see pkg/pup/manager.go

type PupManifest

type PupManifest struct {
	// The version of the actual manifest. This differs from the "version"
	// of the pup, and the version of the deployed software for this pup.
	// Valid values: 1
	ManifestVersion int                     `json:"manifestVersion"`
	Meta            PupManifestMeta         `json:"meta"`
	Config          PupManifestConfigFields `json:"config"`
	Container       PupManifestContainer    `json:"container"`
	Interfaces      []PupManifestInterface  `json:"interfaces"`
	Dependencies    []PupManifestDependency `json:"dependencies"`
	Metrics         []PupManifestMetric     `json:"metrics"`
}

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

func (*PupManifest) Validate

func (m *PupManifest) Validate() error

type PupManifestBuild

type PupManifestBuild struct {
	// The location of the nix file used for building this pups environment.
	NixFile string `json:"nixFile"`
	// The SHA256 hash of the nix file.
	NixFileSha256 string `json:"nixFileSha256"`
}

PupManifestBuild holds information about the target nix * package that is to be built for this pup.

type PupManifestCommand

type PupManifestCommand struct {
	// Required. The whole executable string, including any arguments that need to be passed.
	Exec string `json:"exec"`
	// Optional. The working directory specified for a systemd service.
	CWD string `json:"cwd"`
	// Optional. Any environment variables that need to be set.
	ENV map[string]string `json:"env"`
}

Represents the command to run inside this PUP * Container.

type PupManifestConfigFields

type PupManifestConfigFields struct {
	Sections []struct {
		Name  string `json:"name"`
		Label string `json:"label"`
		// TODO: we probably need a list of valid field types
		// Fields []map[string]interface{} `json:"fields"`
		Fields []struct {
			Label    string `json:"label"`
			Name     string `json:"name"`
			Type     string `json:"type"`
			Required bool   `json:"required"`
			Options  []struct {
				Label string `json:"label"`
				Value string `json:"value"`
			} `json:"options,omitempty"`
			Min  int `json:"min,omitempty"`
			Max  int `json:"max,omitempty"`
			Step int `json:"step,omitempty"`
		} `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 PupManifestContainer

type PupManifestContainer struct {
	Build PupManifestBuild `json:"build"`
	// A single nix build file can provide multiple services, which all
	// may need to be started separately. Each "service" should be provided
	// as an artifact here with the correct execution configuration.
	Services []PupManifestService      `json:"services"`
	Exposes  []PupManifestExposeConfig `json:"exposes"`
	// This pup requires internet access to function.
	RequiresInternet bool `json:"requiresInternet"`
}

PupManfiestV1Container contains information about the * execution environment of the pup, including both build * and runtime details of whatever is to be executed.

type PupManifestDependency

type PupManifestDependency struct {
	InterfaceName    string                      `json:"interfaceName"`    // interface that we depend on
	InterfaceVersion string                      `json:"interfaceVersion"` // semver expression
	PermissionGroups []string                    `json:"permissionGroups"` // list of permission groups from that interface we want
	DefaultSource    PupManifestDependencySource `json:"source"`           // optional, default package that provides this interface
	Optional         bool                        `json:"optional"`
}

Dependency specifies that this pup requires * another pup to be running, and what permission * groups from that pup need to be available.

type PupManifestDependencySource

type PupManifestDependencySource struct {
	SourceLocation string `json:"sourceLocation"`
	PupName        string `json:"pupName"`
	PupVersion     string `json:"pupVersion"`
	PupLogoBase64  string `json:"pupLogoBase64"`
}

A DependencySource specifies the location of a * dependency that needs to be installed. We list it in the manifest * so that if a user doesn't already have this source set up we * can still resolve this dependency tree.

type PupManifestExposeConfig

type PupManifestExposeConfig struct {
	Name         string   `json:"name"`         // Freeform field used to refer to this port in the frontend.
	Type         string   `json:"type"`         // Must be one of: http, tcp
	Port         int      `json:"port"`         // The port that is being listened on inside the container.
	Interfaces   []string `json:"interfaces"`   // Designates that certain interfaces can be accessed on this port
	ListenOnHost bool     `json:"listenOnHost"` // If true, the port will be accessible on the host network, otherwise it will listen on a private internal network interface.
	WebUI        bool     `json:"webUI"`        // If true, will be proxied from an available port to the dPanel user
}

Allow the user to expose certain ports in their container.

type PupManifestInterface

type PupManifestInterface struct {
	Name             string                       `json:"name"`             // the globally unique name for this interface
	Version          string                       `json:"version"`          // Semver ie: 0.1.1
	PermissionGroups []PupManifestPermissionGroup `json:"permissionGroups"` // The permission groups that make up this interface
}

type PupManifestMeta

type PupManifestMeta struct {
	Name string `json:"name"`
	// The version of the pup.
	// nb. This can differ from the version of the software deployed
	//     by this pup, as we may change this pup manifest to expose
	//     additional configuration options for the same software version.
	Version string `json:"version"`
	// Optional. A path to a logo for this pup.
	LogoPath string `json:"logoPath"`
	// A short description, single line.
	ShortDescription string `json:"shortDescription"`
	// Optional, longer description. Used for store listings.
	LongDescription string `json:"longDescription"`
	// A key value pair of upstream versions that this pup ships with.
	UpstreamVersions map[string]string `json:"upstreamVersions"`
}

PupManifestMeta holds meta information about this pup * such as its name, version, any imagery that needs to be shown.

type PupManifestMetric

type PupManifestMetric struct {
	Name        string `json:"name"`
	Label       string `json:"label"`
	Type        string `json:"type"` // string, int, float
	HistorySize int    `json:"history"`
}

type PupManifestPermissionGroup

type PupManifestPermissionGroup struct {
	Name        string   `json:"name"`        // ie:  admin, wallet-read-only, etc.
	Description string   `json:"description"` // What does this permission group do (shown to user)
	Severity    int      `json:"severity"`    // 1-3, 1: critical/danger, 2: makes changes, 3: read only stuff
	Routes      []string `json:"routes"`      // http routes accessible for this group
	Port        int      `json:"port"`        // port accessible for this group
}

PermissionGroups define how other * pups can request access to this pup's * APIs and resources, via their Dependencies

type PupManifestService

type PupManifestService struct {
	Name    string             `json:"name"`
	Command PupManifestCommand `json:"command"`
}

type PupMetric

type PupMetric struct {
	Value any `json:"value"`
}

type PupMetrics

type PupMetrics[T any] struct {
	Name   string     `json:"name"`
	Label  string     `json:"label"`
	Type   string     `json:"type"`
	Values *Buffer[T] `json:"values"`
}

type PupState

type PupState struct {
	ID           string                      `json:"id"`
	LogoBase64   string                      `json:"logoBase64"`
	Source       ManifestSourceConfiguration `json:"source"`
	Manifest     PupManifest                 `json:"manifest"`
	Config       map[string]string           `json:"config"`
	Providers    map[string]string           `json:"providers"`    // providers of interface dependencies
	Hooks        []PupHook                   `json:"hooks"`        // webhooks
	Installation string                      `json:"installation"` // see table above and constants
	BrokenReason string                      `json:"brokenReason"` // reason for being in a broken state
	Enabled      bool                        `json:"enabled"`      // Is this pup supposed to be running?
	NeedsConf    bool                        `json:"needsConf"`    // Has all required config been provided?
	NeedsDeps    bool                        `json:"needsDeps"`    // Have all dependencies been met?
	IP           string                      `json:"ip"`           // Internal IP for this pup
	Version      string                      `json:"version"`
	WebUIs       []PupWebUI                  `json:"webUIs"`
}

PupState is persisted to disk

type PupStats

type PupStats struct {
	ID            string            `json:"id"`
	Status        string            `json:"status"`
	SystemMetrics []PupMetrics[any] `json:"systemMetrics"`
	Metrics       []PupMetrics[any] `json:"metrics"`
	Issues        PupIssues         `json:"issues"`
}

PupStats is not persisted to disk, and holds the running stats for the pup process, ie: disk, CPU, etc.

type PupWebUI

type PupWebUI struct {
	Name     string `json:"name"`
	Internal int    `json:"-"`
	Port     int    `json:"port"`
}

Represents a Web UI exposed port from the manifest

type Pupdate

type Pupdate struct {
	ID    string
	Event int // see consts above ^
	State PupState
}

Represents a change to pup state

type PurgePup

type PurgePup struct {
	PupID string
}

Purging a pup will remove the container storage.

type RemoveSSHKey

type RemoveSSHKey struct {
	ID string
}

type SelectedNetwork

type SelectedNetwork interface {
	// contains filtered or unexported methods
}

type SelectedNetworkEthernet

type SelectedNetworkEthernet struct {
	SelectedNetwork
	Interface string `json:"interface"`
}

type SelectedNetworkWifi

type SelectedNetworkWifi struct {
	SelectedNetwork
	Interface  string `json:"interface"`
	Ssid       string `json:"ssid"`
	Password   string `json:"password"`
	Encryption string `json:"encryption"`
	IsHidden   bool   `json:"isHidden"`
}

type ServerConfig

type ServerConfig struct {
	DataDir          string
	TmpDir           string
	NixDir           string
	ContainerLogDir  string
	Bind             string
	Port             int
	InternalPort     int
	Verbose          bool
	Recovery         bool
	UiDir            string
	UiPort           int
	DevMode          bool
	DisableReflector bool
}

type SourceDetails

type SourceDetails struct {
	ID          string             `json:"id"`
	Name        string             `json:"name"`
	Description string             `json:"description"`
	Pups        []SourceDetailsPup `json:"pups"`
}

type SourceDetailsPup

type SourceDetailsPup struct {
	Location string `json:"location"`
}

type SourceManager

type SourceManager interface {
	GetAll(ignoreCache bool) (map[string]ManifestSourceList, error)
	GetSourceManifest(sourceId, pupName, pupVersion string) (PupManifest, ManifestSource, error)
	GetSourcePup(sourceId, pupName, pupVersion string) (ManifestSourcePup, error)
	GetSource(name string) (ManifestSource, error)
	AddSource(location string) (ManifestSource, error)
	RemoveSource(id string) error
	DownloadPup(diskPath, sourceId, pupName, pupVersion string) error
	GetAllSourceConfigurations() []ManifestSourceConfiguration
}

type SourceState

type SourceState struct {
	SourceConfigs []ManifestSourceConfiguration
}

type State

type State struct {
	Network NetworkState
	Dogebox DogeboxState
	Sources SourceState
}

type StateManager

type StateManager interface {
	Get() State
	SetNetwork(s NetworkState) error
	SetDogebox(s DogeboxState) error
	SetSources(s SourceState) error
}

type StatsUpdate

type StatsUpdate struct {
	Stats []PupStats `json:"stats"`
}

StatsUpdate represents one or more PupStats updates

type StoreManager

type StoreManager struct {
	DB      *sql.DB
	WriteMu sync.Mutex
}

func NewStoreManager

func NewStoreManager(dbPath string) (*StoreManager, error)

func (*StoreManager) Run

func (sm *StoreManager) Run(started, stopped chan bool, stop chan context.Context) error

type SubLogger

type SubLogger interface {
	Log(msg string)
	Logf(msg string, a ...any)
	Err(msg string)
	Errf(msg string, a ...any)
	Progress(p int) SubLogger
	LogCmd(cmd *exec.Cmd)
}

type SystemDisk

type SystemDisk struct {
	Name        string                `json:"name"`
	Size        int64                 `json:"size"`
	SizePretty  string                `json:"sizePretty"`
	Suitability SystemDiskSuitability `json:"suitability"`
	BootMedia   bool                  `json:"bootMedia"`
}

type SystemDiskSuitability

type SystemDiskSuitability struct {
	Install SystemDiskSuitabilityEntry `json:"install"`
	Storage SystemDiskSuitabilityEntry `json:"storage"`
}

type SystemDiskSuitabilityEntry

type SystemDiskSuitabilityEntry struct {
	Usable bool `json:"usable"`
	SizeOK bool `json:"sizeOK"`
}

type SystemMonitor

type SystemMonitor interface {
	GetMonChannel() chan []string
	GetStatChannel() chan map[string]ProcStatus
	GetFastMonChannel() chan string
	GetFastStatChannel() chan map[string]ProcStatus
}

monitors systemd services and returns stats

type SystemUpdater

type SystemUpdater interface {
	AddJob(Job)
	GetUpdateChannel() chan Job

	// These ideally should not be on here, but we currently don't
	// have a way to wait for a SystemUpdater event to finish.
	AddSSHKey(key string, l SubLogger) error
	EnableSSH(l SubLogger) error
	ListSSHKeys() ([]DogeboxStateSSHKey, error)
}

handle jobs on behalf of Dogeboxd and return them via it's own update channel.

type TypeStore

type TypeStore[T any] struct {
	DB *sql.DB

	Table string
	// contains filtered or unexported fields
}

func GetTypeStore

func GetTypeStore[T any](sm *StoreManager) *TypeStore[T]

func (*TypeStore[T]) Del

func (ts *TypeStore[T]) Del(key string) error

func (*TypeStore[T]) Exec

func (ts *TypeStore[T]) Exec(query string, args ...interface{}) ([]T, error)

This should not be used to update/insert, it doesn't lock

func (*TypeStore[T]) Get

func (ts *TypeStore[T]) Get(key string) (T, error)

func (*TypeStore[T]) Set

func (ts *TypeStore[T]) Set(key string, value T) error

type UIServer

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

func (UIServer) Run

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

type UninstallPup

type UninstallPup struct {
	PupID string
}

Uninstalling a pup will remove container configuration, but keep storage.

type Update

type Update any
Updates are responses to Actions or simply

* internal state changes that the frontend needs, * these are wrapped in a 'change' and sent via * websocket to the client. * * Updates need to be json-marshalable types

type UpdateMetrics

type UpdateMetrics struct {
	PupID   string
	Payload map[string]PupMetric
}

updates the custom metrics for a pup

type UpdatePendingSystemNetwork

type UpdatePendingSystemNetwork struct {
	Network SelectedNetwork
}

type UpdatePupConfig

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

Updates the config values in a PUPState object

type UpdatePupHooks

type UpdatePupHooks struct {
	PupID   string
	Payload []PupHook
}

Updates hooks for this pup

type UpdatePupProviders

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

Updates the providers of dependant interfaces for this pup

Jump to

Keyboard shortcuts

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