db

package
v0.0.1-alpha4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteCluster

func DeleteCluster(db *sql.DB, id string) error

DeleteCluster deletes a cluster from the database

func DeleteNode

func DeleteNode(db *sql.DB, id string) error

DeleteNode deletes a node from the database

func GenerateID

func GenerateID() string

GenerateID generates a new ID for a cluster or node

func GetDB

func GetDB() *sql.DB

GetDB returns the database connection

func InitializeDB

func InitializeDB() error

InitializeDB initializes the database

func InsertCluster

func InsertCluster(db *sql.DB, cluster K3sCluster) error

InsertCluster inserts a new cluster into the database

func InsertNode

func InsertNode(db *sql.DB, node K3sNode) error

InsertNode inserts a new node into the database

func UpdateCluster

func UpdateCluster(db *sql.DB, cluster K3sCluster) error

UpdateCluster updates a cluster in the database

func UpdateNode

func UpdateNode(db *sql.DB, node K3sNode) error

UpdateNode updates a node in the database

Types

type K3sCluster

type K3sCluster struct {
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	ID        string    `json:"id"` // Last 12 characters of UUID
	Status    string    `json:"status"`
	Version   string    `json:"version"`
	Apiserver string    `json:"apiserver"`
	IsHA      bool      `json:"is_ha"` // Indicates high availability
}

K3sCluster represents a K3s cluster

func SelectCluster

func SelectCluster(db *sql.DB, id string) (*K3sCluster, error)

SelectCluster selects a cluster from the database by ID

func SelectClusters

func SelectClusters(db *sql.DB) ([]K3sCluster, error)

SelectClusters selects all clusters from the database

type K3sNode

type K3sNode struct {
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	ID        string    `json:"id"`
	ClusterID string    `json:"cluster_id"`
	IP        string    `json:"ip"`
	Role      string    `json:"role"` // Can be "server" or "agent"
	Status    string    `json:"status"`
}

K3sNode represents a K3s node

func SelectNode

func SelectNode(db *sql.DB, id string) (*K3sNode, error)

SelectNode selects a node from the database by ID

func SelectNodeByIP

func SelectNodeByIP(db *sql.DB, ip string) (K3sNode, error)

SelectNodeByIP selects a node from the database by IP

func SelectNodes

func SelectNodes(db *sql.DB) ([]K3sNode, error)

SelectNodes selects all nodes from the database

func SelectNodesByCluster

func SelectNodesByCluster(db *sql.DB, clusterID string) ([]K3sNode, error)

SelectNodesByCluster selects all nodes from the database by cluster ID

Jump to

Keyboard shortcuts

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