db

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ETCD_TIMEOUT = 5 * time.Second

Variables

This section is empty.

Functions

func HashPassword

func HashPassword(password string) (string, error)

Types

type Container

type Container struct {
	ContainerName string `json:"container_name"`
	Image         string `json:"image"`
}

type DaemonDB

type DaemonDB struct {
	DeploymentsRepository common.DeploymentsRepository
	NodesRepository       common.NodesRepository
	// contains filtered or unexported fields
}

func GetDB

func GetDB() *DaemonDB

func (*DaemonDB) AddNetConfig

func (db *DaemonDB) AddNetConfig(network string, container string, config []byte, cniResult []byte, guest_ifname string, host_ifname string) error

We store guest and host ifnames because we are storing only bridge configs

func (*DaemonDB) Close

func (db *DaemonDB) Close()

func (*DaemonDB) CreateContainer

func (db *DaemonDB) CreateContainer(containerName string, image string, state dto.ContainerStatus) (Container, error)

func (*DaemonDB) CreateLease

func (db *DaemonDB) CreateLease(ttl int64) (clientv3.LeaseID, error)

func (*DaemonDB) CreateUser

func (db *DaemonDB) CreateUser(username string, password string, role int32) error

func (*DaemonDB) DeleteAllNetConfigs

func (db *DaemonDB) DeleteAllNetConfigs(container string) error

Delete all network configs for a container

func (*DaemonDB) DeleteContainer

func (db *DaemonDB) DeleteContainer(containerName string) error

func (*DaemonDB) DeleteDNSRecord

func (db *DaemonDB) DeleteDNSRecord(key string) error

func (*DaemonDB) DeleteHealthStatus

func (db *DaemonDB) DeleteHealthStatus(hostname string) error

func (*DaemonDB) DeleteSubnetOffset

func (db *DaemonDB) DeleteSubnetOffset(network string) error

DeleteSubnetOffset removes the subnet assignment for a network

func (*DaemonDB) GetAllContainers

func (db *DaemonDB) GetAllContainers() ([]Container, error)

func (*DaemonDB) GetAllHealthStatuses

func (db *DaemonDB) GetAllHealthStatuses() ([]HealthStatus, error)

func (*DaemonDB) GetContainer

func (db *DaemonDB) GetContainer(containerName string) (Container, error)

func (*DaemonDB) GetDNSRecord

func (db *DaemonDB) GetDNSRecord(key string) (string, error)

func (*DaemonDB) GetHealthStatus

func (db *DaemonDB) GetHealthStatus(hostname string) (HealthStatus, error)

func (*DaemonDB) GetNetConfigs

func (db *DaemonDB) GetNetConfigs(container string) ([]NetConfig, error)

func (*DaemonDB) GetNetworkContainerCount

func (db *DaemonDB) GetNetworkContainerCount(network string) (int, error)

GetNetworkContainerCount returns the number of containers using a network

func (*DaemonDB) GetVerifiedUser

func (db *DaemonDB) GetVerifiedUser(username string, password string) (int32, error)

func (*DaemonDB) IsHostIfaceUsedExceptForContainer

func (db *DaemonDB) IsHostIfaceUsedExceptForContainer(hostIface string, container string) (bool, error)

func (*DaemonDB) KeepAlive

func (db *DaemonDB) KeepAlive(leaseID clientv3.LeaseID) (<-chan *clientv3.LeaseKeepAliveResponse, error)

func (*DaemonDB) NewOrRetrieveSubnetOffset

func (db *DaemonDB) NewOrRetrieveSubnetOffset(network string) (int32, error)

func (*DaemonDB) OptimisticUpdate

func (db *DaemonDB) OptimisticUpdate(key string, updateFn func(currentValue []byte) ([]byte, error)) error

OptimisticUpdate performs an optimistic lock update on a key. The updateFn receives the current value and should return the updated value. Returns an error if the key doesn't exist or if there's an etcd error.

func (*DaemonDB) PublishHealthStatus

func (db *DaemonDB) PublishHealthStatus(hostname string, leaseId clientv3.LeaseID, status string, metadata map[string]any) error

func (*DaemonDB) PurgeDB

func (db *DaemonDB) PurgeDB() error

PurgeDB deletes all data for the current daemon from the database

func (*DaemonDB) PutWithLease

func (db *DaemonDB) PutWithLease(key, value string, leaseID clientv3.LeaseID) error

func (*DaemonDB) ReleaseSubnet

func (db *DaemonDB) ReleaseSubnet(network string) error

ReleaseSubnet releases the subnet assignment for a network

func (*DaemonDB) SetDNSRecord

func (db *DaemonDB) SetDNSRecord(key, ip string) error

func (*DaemonDB) UpdateContainerImage

func (db *DaemonDB) UpdateContainerImage(containerName string, image string) (string, error)

type DeploymentValue

type DeploymentValue struct {
	ID               common.DeploymentID     `json:"id"`
	LoadName         string                  `json:"load_name"`
	LoadDriverConfig common.LoadDriverConfig `json:"load_driver_config"`
	Status           common.DeploymentStatus `json:"status"`
	Metadata         any                     `json:"metadata"`
}

type EtcdDeploymentsRepository

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

func (*EtcdDeploymentsRepository) Create

func (r *EtcdDeploymentsRepository) Create(loadName string, driver common.LoadDriver, status common.DeploymentStatus, metadata any) (common.DeploymentID, error)

func (*EtcdDeploymentsRepository) DeleteByLoad

func (r *EtcdDeploymentsRepository) DeleteByLoad(loadName string) error

func (*EtcdDeploymentsRepository) DeleteDeployment

func (r *EtcdDeploymentsRepository) DeleteDeployment(deploymentID uuid.UUID) error

func (*EtcdDeploymentsRepository) GetAll

func (*EtcdDeploymentsRepository) GetByLoad

func (r *EtcdDeploymentsRepository) GetByLoad(loadName string) ([]common.Deployment, error)

func (*EtcdDeploymentsRepository) GetByLoadAndStatus

func (r *EtcdDeploymentsRepository) GetByLoadAndStatus(loadName string, statusCode common.DeploymentStatusCode) ([]common.Deployment, error)

func (*EtcdDeploymentsRepository) GetDeployment

func (r *EtcdDeploymentsRepository) GetDeployment(deploymentID common.DeploymentID) (*common.Deployment, error)

func (*EtcdDeploymentsRepository) UpdateMetadata

func (r *EtcdDeploymentsRepository) UpdateMetadata(deploymentID common.DeploymentID, updateFn func(metadataPtr any) error) error

func (*EtcdDeploymentsRepository) UpdateStatus

func (r *EtcdDeploymentsRepository) UpdateStatus(deploymentID common.DeploymentID, status common.DeploymentStatus) error

type EtcdNodesRepository

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

func (*EtcdNodesRepository) DeleteGuestNode added in v0.1.2

func (r *EtcdNodesRepository) DeleteGuestNode(guestNodeName string, guestDriver common.NodeDriver, metadata any) error

func (*EtcdNodesRepository) DeleteSelf added in v0.1.2

func (r *EtcdNodesRepository) DeleteSelf() error

func (*EtcdNodesRepository) GetAllGuestNodes added in v0.1.8

func (r *EtcdNodesRepository) GetAllGuestNodes() ([]common.NodeEntry, error)

func (*EtcdNodesRepository) GetByDaemonId

func (r *EtcdNodesRepository) GetByDaemonId(daemonId string) (common.NodeEntry, error)

func (*EtcdNodesRepository) GetGuestNode added in v0.1.2

func (r *EtcdNodesRepository) GetGuestNode(guestNodeName string) (common.NodeEntry, error)

func (*EtcdNodesRepository) GetSelf

func (r *EtcdNodesRepository) GetSelf() (common.NodeEntry, error)

func (*EtcdNodesRepository) SetGuestNode added in v0.1.2

func (r *EtcdNodesRepository) SetGuestNode(guestNodeName string, guestDriver common.NodeDriver, cloudInit *cloudinit.CloudInit, metadata any) error

func (*EtcdNodesRepository) SetSelf added in v0.1.2

func (r *EtcdNodesRepository) SetSelf(nodeName string, driver common.NodeDriver, cloudInit *cloudinit.CloudInit, metadata any) error

func (*EtcdNodesRepository) UpdateGuestMetadata added in v0.1.8

func (r *EtcdNodesRepository) UpdateGuestMetadata(guestNodeName string, updateFn func(metadataPtr any) error) error

func (*EtcdNodesRepository) UpdateSelfMetadata added in v0.1.8

func (r *EtcdNodesRepository) UpdateSelfMetadata(updateFn func(metadataPtr any) error) error

type HealthStatus

type HealthStatus struct {
	Hostname  string         `json:"hostname"`
	Status    string         `json:"status"`
	Timestamp time.Time      `json:"timestamp"`
	Metadata  map[string]any `json:"metadata,omitempty"`
}

type NetConfig

type NetConfig struct {
	Network        string `json:"network"`
	Config         string `json:"config"`
	CniResult      string `json:"cni_result"`
	GuestIfaceName string `json:"guest_ifname"`
	HostIfaceName  string `json:"host_ifname"`
}

TODO replace usage with NetworkConfig type if possible

type NetworkConfig

type NetworkConfig struct {
	Network        string `json:"network"`
	Container      string `json:"container"`
	Config         string `json:"config"`
	CniResult      string `json:"cni_result"`
	GuestIfaceName string `json:"guest_ifname"`
	HostIfaceName  string `json:"host_ifname"`
}

type NodeValue

type NodeValue struct {
	NodeName         string                  `json:"node_name"`
	NodeDriverConfig common.NodeDriverConfig `json:"node_driver_config"`
	CloudInit        *cloudinit.CloudInit    `json:"cloud_init,omitempty"`
	Metadata         any                     `json:"metadata"`
}

type User

type User struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Role     int32  `json:"role"`
}

Jump to

Keyboard shortcuts

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