db

package
v0.11.1 Latest Latest
Warning

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

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

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

View Source
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

type FerryUIDDatum interface {
	Username() string
	Uid() int
	String() string
}

FerryUIDDatum represents a piece of data from FERRY that encompasses username to UID mapping

type ManagedTokensDatabase added in v0.9.1

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 added in v0.9.1

func (m *ManagedTokensDatabase) Close() error

Close closes the FERRYUIDDatabase

func (*ManagedTokensDatabase) ConfirmUIDsInTable added in v0.9.1

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 added in v0.9.1

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 added in v0.9.1

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 added in v0.9.1

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 added in v0.9.1

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 added in v0.9.1

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 added in v0.9.1

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 added in v0.9.1

func (m *ManagedTokensDatabase) GetUIDByUsername(ctx context.Context, username string) (int, error)

GetUIDByUsername queries the ManagedTokensDatabase for a UID, given a username

func (*ManagedTokensDatabase) InsertUidsIntoTableFromFERRY added in v0.9.1

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) UpdateNodes added in v0.9.1

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 added in v0.9.1

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 added in v0.9.1

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 added in v0.9.1

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 added in v0.9.1

type PushErrorCount interface {
	Service() string
	Node() string
	Count() int
}

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 added in v0.9.1

type SetupErrorCount interface {
	Service() string
	Count() int
}

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.

Jump to

Keyboard shortcuts

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