Documentation ¶
Overview ¶
Package db provides the FERRYUIDDatabase struct which provides an interface to a SQLite3 database that is used by the managed tokens utilities to store username-UID mappings, as provided from FERRY.
Index ¶
- Constants
- type FerryUIDDatum
- type ManagedTokensDatabase
- func (m *ManagedTokensDatabase) Close() error
- func (m *ManagedTokensDatabase) ConfirmUIDsInTable(ctx context.Context) ([]FerryUIDDatum, error)
- func (m *ManagedTokensDatabase) GetAllNodes(ctx context.Context) ([]string, error)
- func (m *ManagedTokensDatabase) GetAllServices(ctx context.Context) ([]string, error)
- func (m *ManagedTokensDatabase) GetPushErrorsInfo(ctx context.Context) ([]PushErrorCount, error)
- func (m *ManagedTokensDatabase) GetPushErrorsInfoByService(ctx context.Context, service string) ([]PushErrorCount, error)
- func (m *ManagedTokensDatabase) GetSetupErrorsInfo(ctx context.Context) ([]SetupErrorCount, error)
- func (m *ManagedTokensDatabase) GetSetupErrorsInfoByService(ctx context.Context, service string) (SetupErrorCount, error)
- func (m *ManagedTokensDatabase) GetUIDByUsername(ctx context.Context, username string) (int, error)
- func (m *ManagedTokensDatabase) InsertUidsIntoTableFromFERRY(ctx context.Context, ferryData []FerryUIDDatum) error
- func (m *ManagedTokensDatabase) Location() string
- func (m *ManagedTokensDatabase) UpdateNodes(ctx context.Context, nodes []string) error
- func (m *ManagedTokensDatabase) UpdatePushErrorsTable(ctx context.Context, pushErrorsByServiceAndNode []PushErrorCount) error
- func (m *ManagedTokensDatabase) UpdateServices(ctx context.Context, serviceNames []string) error
- func (m *ManagedTokensDatabase) UpdateSetupErrorsTable(ctx context.Context, setupErrorsByService []SetupErrorCount) error
- type PushErrorCount
- type SetupErrorCount
Constants ¶
const (
// ApplicationId is used to uniquely identify a sqlite database as belonging to an application, rather than being a simple DB
ApplicationId = 0x5da82553
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FerryUIDDatum ¶
FerryUIDDatum represents a piece of data from FERRY that encompasses username to UID mapping
type ManagedTokensDatabase ¶
type ManagedTokensDatabase struct {
// contains filtered or unexported fields
}
ManagedTokensDatabase is a database in which FERRY username to uid mappings are stored. It is the main type that external packages will use to interact with the database.
func OpenOrCreateDatabase ¶
func OpenOrCreateDatabase(filename string) (*ManagedTokensDatabase, error)
OpenOrCreateDatabase opens a sqlite3 database for reading or writing, and returns a *FERRYUIDDatabase object. If the database already exists at the filename provided, it will open that database as long as the ApplicationId matches OpenOrCreateDatabase opens a sqlite3 database for reading or writing, and returns a *FERRYUIDDatabase object. If the database already exists at the filename provided, it will open that database as long as the ApplicationId matches
func (*ManagedTokensDatabase) Close ¶
func (m *ManagedTokensDatabase) Close() error
Close closes the FERRYUIDDatabase
func (*ManagedTokensDatabase) ConfirmUIDsInTable ¶
func (m *ManagedTokensDatabase) ConfirmUIDsInTable(ctx context.Context) ([]FerryUIDDatum, error)
ConfirmUIDsInTable returns all the user to UID mapping information in the ManagedTokensDatabase in the form of a FERRYUIDDatum slice
func (*ManagedTokensDatabase) GetAllNodes ¶
func (m *ManagedTokensDatabase) GetAllNodes(ctx context.Context) ([]string, error)
GetAllNodes queries the ManagedTokensDatabase for the registered nodes and returns a slice of strings with their names
func (*ManagedTokensDatabase) GetAllServices ¶
func (m *ManagedTokensDatabase) GetAllServices(ctx context.Context) ([]string, error)
GetAllServices queries the ManagedTokensDatabase for the registered services and returns a slice of strings with their names
func (*ManagedTokensDatabase) GetPushErrorsInfo ¶
func (m *ManagedTokensDatabase) GetPushErrorsInfo(ctx context.Context) ([]PushErrorCount, error)
GetPushErrorsInfo queries the ManagedTokensDatabase for push error counts. It returns the data in the form of a slice of PushErrorCounts that the caller can unpack using the interface methods Service(), Node(), and Count()
func (*ManagedTokensDatabase) GetPushErrorsInfoByService ¶
func (m *ManagedTokensDatabase) GetPushErrorsInfoByService(ctx context.Context, service string) ([]PushErrorCount, error)
GetPushErrorsInfoByService queries the database for the push errors for a specific service. It returns the data as a slice of PushErrorCounts that the caller can unpack using the Service(), Node(), and Count() interface methods.
func (*ManagedTokensDatabase) GetSetupErrorsInfo ¶
func (m *ManagedTokensDatabase) GetSetupErrorsInfo(ctx context.Context) ([]SetupErrorCount, error)
GetSetupErrorsInfo queries the ManagedTokensDatabase for setup error counts. It returns the data in the form of a slice of SetupErrorCounts that the caller can unpack using the interface methods Service() and Count()
func (*ManagedTokensDatabase) GetSetupErrorsInfoByService ¶
func (m *ManagedTokensDatabase) GetSetupErrorsInfoByService(ctx context.Context, service string) (SetupErrorCount, error)
GetSetupErrorsInfoByService queries the ManagedTokensDatabase for the setup errors for a specific service. It returns the data as a SetupErrorCount that calling functions can unpack using the Service() or Count() functions.
func (*ManagedTokensDatabase) GetUIDByUsername ¶
GetUIDByUsername queries the ManagedTokensDatabase for a UID, given a username
func (*ManagedTokensDatabase) InsertUidsIntoTableFromFERRY ¶
func (m *ManagedTokensDatabase) InsertUidsIntoTableFromFERRY(ctx context.Context, ferryData []FerryUIDDatum) error
InsertUidsIntoTableFromFERRY takes a slice of FERRYUIDDatum and inserts the data it represents into the FERRYUIDDatabase. If the username in a FERRYUIDDatum object already exists in the database, this method will overwrite the database record with the information in the FERRYUIDDatum
func (*ManagedTokensDatabase) Location ¶
func (m *ManagedTokensDatabase) Location() string
Location returns the location of the ManagedTokensDatabase file
func (*ManagedTokensDatabase) UpdateNodes ¶
func (m *ManagedTokensDatabase) UpdateNodes(ctx context.Context, nodes []string) error
UpdateNodes updates the nodes table in the ManagedTokensDatabase. It takes a slice of strings for the node names, and inserts them if they don't already exist in the database
func (*ManagedTokensDatabase) UpdatePushErrorsTable ¶
func (m *ManagedTokensDatabase) UpdatePushErrorsTable(ctx context.Context, pushErrorsByServiceAndNode []PushErrorCount) error
UpdatePushErrorsTable updates the push errors table of the ManagedTokens database. The information to be modified in the database should be given as a slice of PushErrorCount (pushErrorsByServiceAndNode)
func (*ManagedTokensDatabase) UpdateServices ¶
func (m *ManagedTokensDatabase) UpdateServices(ctx context.Context, serviceNames []string) error
UpdateServices updates the services table in the ManagedTokensDatabase. It takes a slice of strings for the service names, and inserts them if they don't already exist in the database
func (*ManagedTokensDatabase) UpdateSetupErrorsTable ¶
func (m *ManagedTokensDatabase) UpdateSetupErrorsTable(ctx context.Context, setupErrorsByService []SetupErrorCount) error
UpdateSetupErrorsTable updates the setup errors table of the ManagedTokens database. The information to be modified in the database should be given as a slice of SetupErrorCount (setupErrorsByService)
type PushErrorCount ¶
PushErrorCount is an interface that wraps the Service, Node, and Count methods. It is meant to be used both by this package and importing packages to retrieve service, node, and count information about pushErrors.
type SetupErrorCount ¶
SetupErrorCount is an interface that wraps the Service and Count methods. It is meant to be used both by this package and importing packages to retrieve service and count information about setupErrors.