Documentation ¶
Index ¶
- Constants
- Variables
- func CloseDB()
- func CreateTable(tableName string) error
- func DeleteAllRecords(tableName string) error
- func DeleteRecord(tableName string, key string) error
- func FetchRecord(tableName string, key string) (string, error)
- func FetchRecords(tableName string) (map[string]string, error)
- func GetPeers(networkName string) (map[string]string, error)
- func InitializeDatabase() error
- func Insert(key string, value string, tableName string) error
- func InsertPeer(key string, value string) error
- func IsConnected() bool
- func IsEmptyRecord(err error) bool
- func IsJSONString(value string) bool
- func PeersAreEqual(toCompare map[string]string, networkName string) bool
- func SetPeers(newPeers map[string]string, networkName string) bool
Constants ¶
View Source
const ( // == Table Names == // NETWORKS_TABLE_NAME - networks table NETWORKS_TABLE_NAME = "networks" // NODES_TABLE_NAME - nodes table NODES_TABLE_NAME = "nodes" // DELETED_NODES_TABLE_NAME - deleted nodes table DELETED_NODES_TABLE_NAME = "deletednodes" // USERS_TABLE_NAME - users table USERS_TABLE_NAME = "users" // USER_PERMISSIONS_TABLE_NAME - user permissions table USER_PERMISSIONS_TABLE_NAME = "user_permissions" // CERTS_TABLE_NAME - certificates table CERTS_TABLE_NAME = "certs" // DNS_TABLE_NAME - dns table DNS_TABLE_NAME = "dns" // EXT_CLIENT_TABLE_NAME - ext client table EXT_CLIENT_TABLE_NAME = "extclients" // PEERS_TABLE_NAME - peers table PEERS_TABLE_NAME = "peers" // SERVERCONF_TABLE_NAME - stores server conf SERVERCONF_TABLE_NAME = "serverconf" // SERVER_UUID_TABLE_NAME - stores unique netmaker server data SERVER_UUID_TABLE_NAME = "serveruuid" // SERVER_UUID_RECORD_KEY - telemetry thing SERVER_UUID_RECORD_KEY = "serveruuid" // DATABASE_FILENAME - database file name DATABASE_FILENAME = "netmaker.db" // GENERATED_TABLE_NAME - stores server generated k/v GENERATED_TABLE_NAME = "generated" // NODE_ACLS_TABLE_NAME - stores the node ACL rules NODE_ACLS_TABLE_NAME = "nodeacls" // ACLS_TABLE_NAME - table for acls v2 ACLS_TABLE_NAME = "acls" // SSO_STATE_CACHE - holds sso session information for OAuth2 sign-ins SSO_STATE_CACHE = "ssostatecache" // METRICS_TABLE_NAME - stores network metrics METRICS_TABLE_NAME = "metrics" // NETWORK_USER_TABLE_NAME - network user table tracks stats for a network user per network NETWORK_USER_TABLE_NAME = "networkusers" // USER_GROUPS_TABLE_NAME - table for storing usergroups USER_GROUPS_TABLE_NAME = "usergroups" // CACHE_TABLE_NAME - caching table CACHE_TABLE_NAME = "cache" // HOSTS_TABLE_NAME - the table name for hosts HOSTS_TABLE_NAME = "hosts" // ENROLLMENT_KEYS_TABLE_NAME - table name for enrollmentkeys ENROLLMENT_KEYS_TABLE_NAME = "enrollmentkeys" // HOST_ACTIONS_TABLE_NAME - table name for enrollmentkeys HOST_ACTIONS_TABLE_NAME = "hostactions" // PENDING_USERS_TABLE_NAME - table name for pending users PENDING_USERS_TABLE_NAME = "pending_users" // USER_INVITES - table for user invites USER_INVITES_TABLE_NAME = "user_invites" // TAG_TABLE_NAME - table for tags TAG_TABLE_NAME = "tags" // == ERROR CONSTS == // NO_RECORD - no singular result found NO_RECORD = "no result found" // NO_RECORDS - no results found NO_RECORDS = "could not find any records" // == DB Constants == // INIT_DB - initialize db INIT_DB = "init" // CREATE_TABLE - create table const CREATE_TABLE = "createtable" // INSERT - insert into db const INSERT = "insert" // INSERT_PEER - insert peer into db const INSERT_PEER = "insertpeer" // DELETE - delete db record const DELETE = "delete" // DELETE_ALL - delete a table const DELETE_ALL = "deleteall" // FETCH_ALL - fetch table contents const FETCH_ALL = "fetchall" // CLOSE_DB - graceful close of db const CLOSE_DB = "closedb" )
Variables ¶
View Source
var PGDB *sql.DB
PGDB - database object for PostGreSQL
View Source
var PG_FUNCTIONS = map[string]interface{}{ INIT_DB: initPGDB, CREATE_TABLE: pgCreateTable, INSERT: pgInsert, INSERT_PEER: pgInsertPeer, DELETE: pgDeleteRecord, DELETE_ALL: pgDeleteAllRecords, FETCH_ALL: pgFetchRecords, CLOSE_DB: pgCloseDB, // contains filtered or unexported fields }
PG_FUNCTIONS - map of db functions for PostGreSQL
View Source
var RQLITE_FUNCTIONS = map[string]interface{}{ INIT_DB: initRqliteDatabase, CREATE_TABLE: rqliteCreateTable, INSERT: rqliteInsert, INSERT_PEER: rqliteInsertPeer, DELETE: rqliteDeleteRecord, DELETE_ALL: rqliteDeleteAllRecords, FETCH_ALL: rqliteFetchRecords, CLOSE_DB: rqliteCloseDB, // contains filtered or unexported fields }
RQLITE_FUNCTIONS - all the functions to run with rqlite
View Source
var RQliteDatabase gorqlite.Connection
RQliteDatabase - the rqlite db connection
View Source
var SQLITE_FUNCTIONS = map[string]interface{}{ INIT_DB: initSqliteDB, CREATE_TABLE: sqliteCreateTable, INSERT: sqliteInsert, INSERT_PEER: sqliteInsertPeer, DELETE: sqliteDeleteRecord, DELETE_ALL: sqliteDeleteAllRecords, FETCH_ALL: sqliteFetchRecords, CLOSE_DB: sqliteCloseDB, // contains filtered or unexported fields }
SQLITE_FUNCTIONS - contains a map of the functions for sqlite
View Source
var SqliteDB *sql.DB
SqliteDB is the db object for sqlite database connections
Functions ¶
func CreateTable ¶ added in v0.23.0
func DeleteAllRecords ¶
DeleteAllRecords - removes a table and remakes
func DeleteRecord ¶
DeleteRecord - deletes a record from db
func FetchRecord ¶
FetchRecord - fetches a record
func FetchRecords ¶
FetchRecords - fetches all records in given table
func IsEmptyRecord ¶
IsEmptyRecord - checks for if it's an empty record error or not
func PeersAreEqual ¶
PeersAreEqual - checks if peers are the same
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.