Documentation ¶
Index ¶
- Constants
- Variables
- func APIKeySave(key, loggedInUser string, dateCreated time.Time) error
- func AddDatabase(loggedInUser, dbOwner, dbFolder, dbName string, createBranch bool, ...) (numBytes int64, newCommitID string, calculatedDbSha string, err error)
- func AddDefaultLicences() (err error)
- func AddDefaultUser() error
- func AddUser(auth0ID, userName, password, email, displayName, avatarURL string) error
- func AuthorizerLive(d interface{}, action sqlite.Action, ...) sqlite.Auth
- func AuthorizerSelect(d interface{}, action sqlite.Action, ...) sqlite.Auth
- func CacheData(cacheKey string, cacheData interface{}, cacheSeconds int) error
- func CheckAPIKey(apiKey string) (err error)
- func CheckDBExists(dbOwner, dbFolder, dbName string) (bool, error)
- func CheckDBID(dbOwner string, dbID int64) (avail bool, dbFolder, dbName string, err error)
- func CheckDBLive(dbOwner, dbFolder, dbName string) (isLive bool, liveNode string, err error)
- func CheckDBPermissions(loggedInUser, dbOwner, dbFolder, dbName string, writeAccess bool) (bool, error)
- func CheckDBStarred(loggedInUser, dbOwner, dbFolder, dbName string) (bool, error)
- func CheckDBWatched(loggedInUser, dbOwner, dbFolder, dbName string) (bool, error)
- func CheckEmailExists(email string) (bool, error)
- func CheckLicenceExists(userName, licenceName string) (exists bool, err error)
- func CheckUnicode(rawInput string) (str string, err error)
- func CheckUserExists(userName string) (bool, error)
- func ClearCache() (err error)
- func CloseMQChannel(channel *amqp.Channel) (err error)
- func CloseMQConnection(connection *amqp.Connection) (err error)
- func CommitLicenceSHA(dbOwner, dbFolder, dbName, commitID string) (licenceSHA string, err error)
- func CommitPublicFlag(loggedInUser, dbOwner, dbFolder, dbName, commitID string) (public bool, err error)
- func ConnectCache() error
- func ConnectMQ() (channel *amqp.Channel, err error)
- func ConnectMinio() (err error)
- func ConnectPostgreSQL() (err error)
- func CreateCommitID(c CommitEntry) string
- func CreateDBTreeID(entries []DBTreeEntry) string
- func CypressSeed(w http.ResponseWriter, r *http.Request)
- func DBDetails(DB *SQLiteDBinfo, loggedInUser, dbOwner, dbFolder, dbName, commitID string) error
- func DBStars(dbOwner, dbFolder, dbName string) (starCount int, err error)
- func DBWatchers(dbOwner, dbFolder, dbName string) (watcherCount int, err error)
- func DataValuesMatch(a []DataValue, b []DataValue) (equal bool)
- func DefaultCommit(dbOwner, dbFolder, dbName string) (string, error)
- func DeleteBranchHistory(dbOwner, dbFolder, dbName, branchName, commitID string) (isolatedTags, isolatedRels []string, err error)
- func DeleteComment(dbOwner, dbFolder, dbName string, discID, comID int) error
- func DeleteDatabase(dbOwner, dbFolder, dbName string) error
- func DeleteLicence(userName, licenceName string) (err error)
- func DisconnectPostgreSQL()
- func DownloadDatabase(w http.ResponseWriter, r *http.Request, ...) (bytesWritten int64, err error)
- func EnvProd(w http.ResponseWriter, r *http.Request)
- func EnvTest(w http.ResponseWriter, r *http.Request)
- func EscapeId(id string) string
- func EscapeIds(ids []string) (escaped []string)
- func EscapeValue(val DataValue) string
- func EscapeValues(vals []DataValue) (escaped []string)
- func FlushViewCount()
- func ForkDatabase(srcOwner, dbFolder, dbName, dstOwner string) (newForkCount int, err error)
- func ForkParent(loggedInUser, dbOwner, dbFolder, dbName string) (parentOwner, parentFolder, parentDBName string, err error)
- func ForkedFrom(dbOwner, dbFolder, dbName string) (forkOwn, forkFol, forkDB string, forkDel bool, err error)
- func GenerateClientCert(userName string) (_ []byte, err error)
- func GetAPIKeyUser(key string) (user string, err error)
- func GetBranches(dbOwner, dbFolder, dbName string) (branches map[string]BranchEntry, err error)
- func GetCachedData(cacheKey string, cacheData interface{}) (bool, error)
- func GetCommitList(dbOwner, dbFolder, dbName string) (map[string]CommitEntry, error)
- func GetCurrentFunctionName() (FuncName string)
- func GetDatabase(r *http.Request, allowGet bool) (dbName string, err error)
- func GetDefaultBranchName(dbOwner, dbFolder, dbName string) (branchName string, err error)
- func GetDefaultTableName(dbOwner, dbFolder, dbName string) (tableName string, err error)
- func GetDiscussionAndMRCount(dbOwner, dbFolder, dbName string) (discCount, mrCount int, err error)
- func GetFolder(r *http.Request, allowGet bool) (folder string, err error)
- func GetFormBranch(r *http.Request) (branch string, err error)
- func GetFormCommit(r *http.Request) (commitID string, err error)
- func GetFormLicence(r *http.Request) (licenceName string, err error)
- func GetFormLive(r *http.Request) (live bool, err error)
- func GetFormODC(r *http.Request) (userName string, dbName string, commitID string, err error)
- func GetFormOwner(r *http.Request, allowGet bool) (dbOwner string, err error)
- func GetFormRelease(r *http.Request) (release string, err error)
- func GetFormSourceURL(r *http.Request) (sourceURL string, err error)
- func GetFormTable(r *http.Request, allowGet bool) (table string, err error)
- func GetFormTag(r *http.Request) (tag string, err error)
- func GetFormUDC(r *http.Request) (userName string, dbName string, commitID string, err error)
- func GetLicence(userName, licenceName string) (txt, format string, err error)
- func GetLicenceInfoFromSha256(userName, sha256 string) (lName, lURL string, err error)
- func GetLicenceSha256FromName(userName, licenceName string) (sha256 string, err error)
- func GetLicences(user string) (map[string]LicenceEntry, error)
- func GetOD(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, err error)
- func GetODC(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, commitID string, err error)
- func GetODT(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, requestedTable string, err error)
- func GetODTC(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, requestedTable string, commitID string, ...)
- func GetPrimaryKeyAndOtherColumns(sdb *sqlite.Conn, schema, table string) (pks []string, implicitPk bool, other []string, err error)
- func GetPub(r *http.Request) (public bool, err error)
- func GetReleases(dbOwner, dbFolder, dbName string) (releases map[string]ReleaseEntry, err error)
- func GetSQLiteRowCount(sdb *sqlite.Conn, dbTable string) (rowCount int, err error)
- func GetShares(dbOwner, dbFolder, dbName string) (shares map[string]ShareDatabasePermissions, err error)
- func GetTable(r *http.Request) (requestedTable string, err error)
- func GetTags(dbOwner, dbFolder, dbName string) (tags map[string]TagEntry, err error)
- func GetUFD(r *http.Request, allowGet bool) (userName string, dbFolder string, dbName string, err error)
- func GetUsername(r *http.Request, allowGet bool) (userName string, err error)
- func GetUsernameFromEmail(email string) (userName, avatarURL string, err error)
- func GetViewCount(dbOwner string, dbFolder string, dbName string) (count int, err error)
- func GetVisualisations(dbOwner, dbFolder, dbName string) (visNames []string, err error)
- func IncrementDownloadCount(dbOwner, dbFolder, dbName string) error
- func IncrementViewCount(dbOwner string, dbFolder string, dbName string) error
- func InvalidateCacheEntry(loggedInUser string, dbOwner string, dbFolder string, dbName string, ...) error
- func IsCommitInBranchHistory(dbOwner, dbFolder, dbName, branchName, commitID string) (bool, error)
- func LiveAddDatabasePG(dbOwner, dbName, liveNode string) (err error)
- func LiveCreateDB(channel *amqp.Channel, dbOwner, dbName string) (err error)
- func LiveDatabasesOnNode(nodeName string) (err error)
- func LiveRetrieveDatabaseMinio(baseDir, dbOwner, dbName string) (dbPath string, err error)
- func LiveStoreDatabaseMinio(db *os.File, dbOwner, dbName string, dbSize int64) (err error)
- func LogDB4SConnect(userAcc, ipAddr, userAgent string, downloadDate time.Time) error
- func LogDownload(dbOwner, dbFolder, dbName, loggedInUser, ipAddr, serverSw, userAgent string, ...) error
- func LogSQLiteQueryAfter(insertID, memUsed, memHighWater int64) (err error)
- func LogSQLiteQueryBefore(...) (int64, error)
- func LogUpload(dbOwner, dbFolder, dbName, loggedInUser, ipAddr, serverSw, userAgent string, ...) error
- func MQColumnsResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, ...) (err error)
- func MQCreateDBQueue(channel *amqp.Channel) (queue amqp.Queue, err error)
- func MQCreateQueryQueue(channel *amqp.Channel, nodeName string) (queue amqp.Queue, err error)
- func MQCreateResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName, result string) (err error)
- func MQDeleteResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, errMsg string) (err error)
- func MQErrorResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, errMsg string) (err error)
- func MQExecResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, errMsg string) (err error)
- func MQIndexesResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, ...) (err error)
- func MQQueryResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, ...) (err error)
- func MQSendRequest(channel *amqp.Channel, ...) (result []byte, err error)
- func MQTablesResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, tables []string, ...) (err error)
- func MQViewsResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, views []string, ...) (err error)
- func MemcacheHandle() *memcache.Client
- func Merge(...) (newCommitID string, err error)
- func MetadataCacheKey(prefix string, loggedInUser string, dbOwner string, dbFolder string, ...) string
- func MinioDeleteDatabase(source, dbOwner, dbName, bucket, id string) (err error)
- func MinioHandle(bucket, id string) (*minio.Object, error)
- func MinioHandleClose(userDB *minio.Object) (err error)
- func MinioLocation(dbOwner, dbFolder, dbName, commitID, loggedInUser string) (minioBucket, minioID string, lastModified time.Time, err error)
- func NewEvent(details EventDetails) (err error)
- func OpenSQLiteDatabase(bucket, id string) (sdb *sqlite.Conn, err error)
- func OpenSQLiteDatabaseDefensive(w http.ResponseWriter, r *http.Request, ...) (sdb *sqlite.Conn, err error)
- func OpenSQLiteDatabaseLive(baseDir, dbOwner, dbName string) (sdb *sqlite.Conn, err error)
- func PrefUserMaxRows(loggedInUser string) int
- func RandomString(length int) string
- func ReadConfig() error
- func ReadSQLiteDBCSV(sdb *sqlite.Conn, dbTable string) ([][]string, error)
- func RenameDatabase(userName, dbFolder, dbName, newName string) error
- func ReservedUsernamesCheck(userName string) error
- func ResetDB() error
- func RetrieveDatabaseFile(bucket, id string) (newDB string, err error)
- func SQLiteExecQueryLive(baseDir, dbOwner, dbName, loggedInUser, query string) (err error)
- func SQLiteGetColumnsLive(baseDir, dbOwner, dbName, table string) (columns []sqlite.Column, err error)
- func SQLiteGetTablesLive(baseDir, dbOwner, dbName string) (tables []string, err error)
- func SQLiteGetViewsLive(baseDir, dbOwner, dbName string) (views []string, err error)
- func SQLiteSanityCheck(fileName string) (tables []string, err error)
- func SQLiteVersionNumber() int32
- func SanitiseLogString(v string) (result string)
- func SaveDBSettings(userName, dbFolder, dbName, oneLineDesc, fullDesc, defaultTable string, ...) error
- func SendEmails()
- func SetClientCert(newCert []byte, userName string) error
- func SetUserPreferences(userName string, maxRows int, displayName, email string) error
- func SetUserStatusUpdates(userName string, numUpdates int) error
- func SocialStats(dbOwner, dbFolder, dbName string) (wa, st, fo int, err error)
- func StatusUpdateCheck(dbOwner, dbFolder, dbName string, thisID int, userName string) (numStatusUpdates int, err error)
- func StatusUpdates(loggedInUser string) (statusUpdates map[string][]StatusUpdateEntry, err error)
- func StatusUpdatesLoop()
- func StoreBranches(dbOwner, dbFolder, dbName string, branches map[string]BranchEntry) error
- func StoreComment(dbOwner, dbFolder, dbName, commenter string, discID int, comText string, ...) error
- func StoreCommits(dbOwner, dbFolder, dbName string, commitList map[string]CommitEntry) error
- func StoreDatabase(dbOwner, dbFolder, dbName string, branches map[string]BranchEntry, ...) error
- func StoreDatabaseFile(db *os.File, sha string, dbSize int64) error
- func StoreDefaultBranchName(dbOwner, folder, dbName, branchName string) error
- func StoreDefaultTableName(dbOwner, folder, dbName, tableName string) error
- func StoreDiscussion(dbOwner, dbFolder, dbName, loggedInUser, title, text string, ...) (newID int, err error)
- func StoreLicence(userName, licenceName string, txt []byte, url string, orderNum int, ...) error
- func StoreReleases(dbOwner, dbFolder, dbName string, releases map[string]ReleaseEntry) error
- func StoreShares(dbOwner, dbFolder, dbName string, shares map[string]ShareDatabasePermissions) (err error)
- func StoreStatusUpdates(userName string, statusUpdates map[string][]StatusUpdateEntry) error
- func StoreTags(dbOwner, dbFolder, dbName string, tags map[string]TagEntry) error
- func SwitchDefault(w http.ResponseWriter, r *http.Request)
- func SwitchFirst(w http.ResponseWriter, r *http.Request)
- func SwitchSecond(w http.ResponseWriter, r *http.Request)
- func SwitchThird(w http.ResponseWriter, r *http.Request)
- func TableRowsCacheKey(prefix string, loggedInUser string, dbOwner string, dbFolder string, ...) string
- func Tables(sdb *sqlite.Conn) (tbl []string, err error)
- func TablesAndViews(sdb *sqlite.Conn, dbName string) (list []string, err error)
- func TestLogout(w http.ResponseWriter, r *http.Request)
- func ToggleDBStar(loggedInUser, dbOwner, dbFolder, dbName string) error
- func ToggleDBWatch(loggedInUser, dbOwner, dbFolder, dbName string) error
- func UpdateAvatarURL(userName, avatarURL string) error
- func UpdateComment(dbOwner, dbFolder, dbName, loggedInUser string, discID, comID int, ...) error
- func UpdateContributorsCount(dbOwner, dbFolder, dbName string) error
- func UpdateDiscussion(dbOwner, dbFolder, dbName, loggedInUser string, discID int, ...) error
- func UpdateMergeRequestCommits(dbOwner, dbFolder, dbName string, discID int, mrCommits []CommitEntry) (err error)
- func UploadResponse(w http.ResponseWriter, r *http.Request, ...) (retMsg map[string]string, httpStatus int, err error)
- func UserNameFromAuth0ID(auth0id string) (string, error)
- func UserStatusUpdates(userName string) (numUpdates int, err error)
- func ValidateBranchName(fieldName string) error
- func ValidateCommitID(fieldName string) error
- func ValidateDB(dbName string) error
- func ValidateDiscussionTitle(fieldName string) error
- func ValidateDisplayName(dbName string) error
- func ValidateEmail(email string) error
- func ValidateFieldName(fieldName string) error
- func ValidateFolder(folder string) error
- func ValidateLicence(licence string) error
- func ValidateLicenceFullName(licence string) error
- func ValidateMarkdown(fieldName string) error
- func ValidatePGTable(table string) error
- func ValidateUser(user string) error
- func ValidateUserDB(user, db string) error
- func ValidateUserDBTable(user, db, table string) error
- func ValidateUserEmail(user, email string) error
- func ViewCount(dbOwner, dbFolder, dbName string) (viewCount int, err error)
- func Views(sdb *sqlite.Conn) (vw []string, err error)
- func VisualisationDeleteParams(dbOwner, dbFolder, dbName, visName string) (err error)
- func VisualisationSaveData(dbOwner, dbFolder, dbName, commitID, hash string, visData []VisRowV1) (err error)
- func VisualisationSaveParams(dbOwner, dbFolder, dbName, visName string, visParams VisParamsV2) (err error)
- func WriteDBtoDisk(loggedInUser, dbOwner, dbFolder, dbName string, newDB io.Reader) (numBytes int64, tempDB *os.File, sha string, sTbls []string, err error)
- type APIJSONColumn
- type APIJSONIndex
- type APIJSONIndexColumn
- type APIKey
- type AccessType
- type ActivityRange
- type ActivityRow
- type ActivityStats
- type ApiInfo
- type Auth0Info
- type Auth0Set
- type BranchEntry
- type BranchListResponseContainer
- type CommitData
- type CommitEntry
- type DB4SInfo
- type DBEntry
- type DBInfo
- type DBTree
- type DBTreeEntry
- type DBTreeEntryType
- type DataDiff
- type DataRow
- type DataValue
- type DiffObjectChangeset
- type DiffType
- type Diffs
- type DiscussionCommentEntry
- type DiscussionCommentType
- type DiscussionEntry
- type DiscussionType
- type DiskCacheInfo
- type EnvInfo
- type EventDetails
- type EventProcessingInfo
- type EventType
- type ForkEntry
- type ForkType
- type JsonError
- type LicenceEntry
- type LicenceInfo
- type LiveDBColumnsResponse
- type LiveDBErrorResponse
- type LiveDBIndexesResponse
- type LiveDBQueryResponse
- type LiveDBRequest
- type LiveDBResponse
- type LiveDBTablesResponse
- type LiveDBViewsResponse
- type LiveDBs
- type LiveInfo
- type MQInfo
- type MemcacheInfo
- type MergeRequestEntry
- type MergeRequestState
- type MergeStrategy
- type MetaInfo
- type MetadataResponseContainer
- type MinioInfo
- type PGInfo
- type QuerySource
- type ReleaseEntry
- type SQLiteDBinfo
- type SQLiteRecordSet
- func LiveQueryDB(channel *amqp.Channel, nodeName, requestingUser, dbOwner, dbName, query string) (rows SQLiteRecordSet, err error)
- func ReadSQLiteDB(sdb *sqlite.Conn, dbTable, sortCol, sortDir string, maxRows, rowOffset int) (SQLiteRecordSet, error)
- func ReadSQLiteDBCols(sdb *sqlite.Conn, dbTable, sortCol, sortDir string, ...) (SQLiteRecordSet, error)
- func SQLiteRunQuery(sdb *sqlite.Conn, querySource QuerySource, dbQuery string, ...) (memUsed, memHighWater int64, dataRows SQLiteRecordSet, err error)
- func SQLiteRunQueryDefensive(w http.ResponseWriter, r *http.Request, querySource QuerySource, ...) (SQLiteRecordSet, error)
- func SQLiteRunQueryLive(baseDir, dbOwner, dbName, loggedInUser, query string) (records SQLiteRecordSet, err error)
- type SchemaDiff
- type SetAccessType
- type SetDBType
- type ShareDatabasePermissions
- type ShareDatabasePermissionsOthers
- type ShareDatabasePermissionsUser
- type SigningInfo
- type StatusResponseContainer
- type StatusUpdateEntry
- type TagEntry
- type TomlConfig
- type UploadResponseContainer
- type UploadRow
- type UserDetails
- type UserInfo
- type UserInfoSlice
- type UserMgmtInfo
- type ValType
- type VisGetFields
- type VisParamsV2
- type VisRowV1
- type WebInfo
- type WebpageResponseContainer
- type WhereClause
Constants ¶
const ( TODAY ActivityRange = "today" THIS_WEEK = "week" THIS_MONTH = "month" ALL_TIME = "all" )
const ( TREE DBTreeEntryType = "tree" DATABASE = "db" LICENCE = "licence" )
const ( TEXT DiscussionCommentType = "txt" CLOSE = "cls" REOPEN = "rop" )
const ( EVENT_NEW_DISCUSSION EventType = 0 // These are not iota, as it would be seriously bad for these numbers to change EVENT_NEW_MERGE_REQUEST = 1 EVENT_NEW_COMMENT = 2 EVENT_NEW_RELEASE = 3 )
const ( OPEN MergeRequestState = 0 // These are not iota, as it would be seriously bad for these numbers to change CLOSED_WITH_MERGE = 1 CLOSED_WITHOUT_MERGE = 2 )
const DefaultNumDisplayRows = 25
DefaultNumDisplayRows is the number of rows to display by default on the database page
const MaxDatabaseSize = 512
MaxDatabaseSize is the maximum database size accepted for upload (in MB)
const MaxLicenceSize = 1
MaxLicenceSize is the maximum licence size accepted for upload (in MB)
const MinioFolderChars = 6
MinioFolderChars is the number of leading characters of a files' sha256 used as the Minio folder name eg: When set to 6, then "34f4255a737156147fbd0a44323a895d18ade79d4db521564d1b0dbb8764cbbc"
-> Minio folder: "34f425" -> Minio filename: "5a737156147fbd0a44323a895d18ade79d4db521564d1b0dbb8764cbbc"
Variables ¶
var ( // AmqpChan is the AMQP channel handle we use for communication with our AMQP backend AmqpChan *amqp.Channel // AmqpDebug controls whether to output - via Log.Print*() functions - useful messages during processing. Mostly // useful for development / debugging purposes AmqpDebug = true )
var SQLiteFunctions = []function{
fnAbs,
fnChanges,
fnChar,
fnCoalesce,
fnGlob,
fnHex,
fnIfNull,
fnInstr,
fnLastInsertRowID,
fnLength,
fnLike,
fnLikelihood,
fnLikely,
fnLower,
fnLTrim,
fnMax,
fnMin,
fnNullIf,
fnPrintF,
fnQuot,
fnRandom,
fnRandomBlob,
fnReplace,
fnRound,
fnRTrim,
fnSoundEx,
fnSQLiteCompileOptionGet,
fnSQLiteCompileOptionUsed,
fnSQLiteOffset,
fnSQLiteSourceID,
fnSQLiteVersion,
fnSubstr,
fnTotalChanges,
fnTrim,
fnTypeOf,
fnUnlikely,
fnUpper,
fnZeroBlob,
fnDate,
fnTime,
fnDateTime,
fnJulianDay,
fnStrfTime,
fnAvg,
fnCount,
fnGroupConcat,
fnSum,
fnTotal,
fnRowNumber,
fnRank,
fnDenseRank,
fnPercentRank,
fnCumeDist,
fnNTile,
fnLag,
fnLead,
fnFirstValue,
fnLastValue,
fnNthValue,
fnJson,
fnJsonArray,
fnJsonArrayLength,
fnJsonExtract,
fnJsonInsert,
fnJsonObject,
fnJsonPatch,
fnJsonRemove,
fnJsonReplace,
fnJsonSet,
fnJsonType,
fnJsonValid,
fnJsonQuote,
fnJsonGroupArray,
fnJsonGroupObject,
fnJsonEach,
fnJsonTree,
fnVersion,
}
SQLiteFunctions lists the function we allow SQL queries to run
var ( // Validate is used for input validation Validate *valid.Validate )
Functions ¶
func APIKeySave ¶ added in v0.0.6
APIKeySave saves a new API key to the PostgreSQL database
func AddDatabase ¶
func AddDatabase(loggedInUser, dbOwner, dbFolder, dbName string, createBranch bool, branchName, commitID string, accessType SetAccessType, licenceName, commitMsg, sourceURL string, newDB io.Reader, lastModified, commitTime time.Time, authorName, authorEmail, committerName, committerEmail string, otherParents []string, dbSha string) (numBytes int64, newCommitID string, calculatedDbSha string, err error)
AddDatabase is handles database upload processing
func AddDefaultLicences ¶
func AddDefaultLicences() (err error)
AddDefaultLicences adds the default licences to the PostgreSQL database. Generally useful for populating a new database, or adding new entries to an existing one
func AddDefaultUser ¶
func AddDefaultUser() error
AddDefaultUser adds the default user to the system, so the referential integrity of licence user_id 0 works
func AuthorizerLive ¶ added in v0.0.15
func AuthorizerLive(d interface{}, action sqlite.Action, tableName, funcName, dbName, triggerName string) sqlite.Auth
AuthorizerLive is a SQLite authorizer callback intended to allow almost anything. Except for loading extensions, and running pragmas.
func AuthorizerSelect ¶ added in v0.0.6
func AuthorizerSelect(d interface{}, action sqlite.Action, tableName, funcName, dbName, triggerName string) sqlite.Auth
AuthorizerSelect is a SQLite authorizer callback which only allows SELECT queries and their needed sub-operations to run.
func CheckAPIKey ¶ added in v0.1.0
CheckAPIKey checks if a given string is a valid API key
func CheckDBExists ¶
CheckDBExists checks if a database exists. It does NOT perform any permission checks. If an error occurred, the true/false value should be ignored, as only the error value is valid
func CheckDBID ¶
CheckDBID checks if a given database ID is available, and returns it's folder/name so the caller can determine if it has been renamed. If an error occurs, the true/false value should be ignored, as only the error value is valid
func CheckDBLive ¶ added in v0.0.15
CheckDBLive checks if the given database is a live database
func CheckDBPermissions ¶ added in v0.0.15
func CheckDBPermissions(loggedInUser, dbOwner, dbFolder, dbName string, writeAccess bool) (bool, error)
CheckDBPermissions checks if a database exists and can be accessed by the given user. If an error occurred, the true/false value should be ignored, as only the error value is valid
func CheckDBStarred ¶
CheckDBStarred check if a database has been starred by a given user. The boolean return value is only valid when err is nil
func CheckDBWatched ¶
CheckDBWatched checks if a database is being watched by a given user. The boolean return value is only valid when err is nil
func CheckEmailExists ¶
CheckEmailExists checks if an email address already exists in our system. Returns true if the email is already in the system, false if not. If an error occurred, the true/false value should be ignored, as only the error value is valid
func CheckLicenceExists ¶ added in v0.0.5
CheckLicenceExists checks if a given licence exists in our system
func CheckUnicode ¶ added in v0.0.6
CheckUnicode checks if a given string is unicode, and safe for using in SQLite queries (eg no SQLite control characters)
func CheckUserExists ¶
CheckUserExists checks if a username already exists in our system. Returns true if the username is already taken, false if not. If an error occurred, the true/false value should be ignored, and only the error return code used
func ClearCache ¶ added in v0.0.15
func ClearCache() (err error)
ClearCache removes all items currently cached by Memcached, so it's like a newly started server
func CloseMQChannel ¶ added in v0.0.15
CloseMQChannel closes an open AMQP channel
func CloseMQConnection ¶ added in v0.0.15
func CloseMQConnection(connection *amqp.Connection) (err error)
CloseMQConnection closes an open AMQP connection
func CommitLicenceSHA ¶
CommitLicenceSHA returns the licence used by the database in a given commit
func CommitPublicFlag ¶ added in v0.0.15
func CommitPublicFlag(loggedInUser, dbOwner, dbFolder, dbName, commitID string) (public bool, err error)
CommitPublicFlag returns the public flag of a given commit
func ConnectMinio ¶
func ConnectMinio() (err error)
ConnectMinio parses the Minio configuration, to ensure it seems workable Note - this doesn't actually open a connection to the Minio server.
func ConnectPostgreSQL ¶
func ConnectPostgreSQL() (err error)
ConnectPostgreSQL creates a connection pool to the PostgreSQL server
func CreateCommitID ¶
func CreateCommitID(c CommitEntry) string
CreateCommitID generate a stable SHA256 for a commit
func CreateDBTreeID ¶
func CreateDBTreeID(entries []DBTreeEntry) string
CreateDBTreeID generate the SHA256 for a tree Tree entry structure is: * [ entry type ] [ licence sha256] [ file sha256 ] [ file name ] [ last modified (timestamp) ] [ file size (bytes) ]
func CypressSeed ¶ added in v0.0.15
func CypressSeed(w http.ResponseWriter, r *http.Request)
CypressSeed empties the backend database, then adds pre-defined test data (PostgreSQL and Minio)
func DBDetails ¶
func DBDetails(DB *SQLiteDBinfo, loggedInUser, dbOwner, dbFolder, dbName, commitID string) error
DBDetails returns the details for a specific database
func DBWatchers ¶
DBWatchers returns the watchers count for a given database
func DataValuesMatch ¶ added in v0.0.15
DataValuesMatch compares two slices of DataValue objects. It returns true if the two are equal, false otherwise.
func DefaultCommit ¶
DefaultCommit returns the default commit ID for a specific database
func DeleteBranchHistory ¶
func DeleteBranchHistory(dbOwner, dbFolder, dbName, branchName, commitID string) (isolatedTags, isolatedRels []string, err error)
DeleteBranchHistory safely removes the commit history for a branch, from the head of the branch back to (but not including) the specified commit. The new branch head will be at the commit ID specified
func DeleteComment ¶
DeleteComment deletes a specific comment from a discussion
func DeleteDatabase ¶
DeleteDatabase deletes a database from PostgreSQL
func DeleteLicence ¶ added in v0.0.5
DeleteLicence removes a (user supplied) database licence from the system
func DisconnectPostgreSQL ¶
func DisconnectPostgreSQL()
DisconnectPostgreSQL disconnects the PostgreSQL database connection
func DownloadDatabase ¶ added in v0.0.9
func DownloadDatabase(w http.ResponseWriter, r *http.Request, dbOwner, dbFolder, dbName, commitID, loggedInUser, sourceSw string) (bytesWritten int64, err error)
DownloadDatabase returns the SQLite database file to the requester
func EnvProd ¶ added in v0.0.15
func EnvProd(w http.ResponseWriter, r *http.Request)
EnvProd changes the running environment to be "production" NOTE - This route to call this is only available when the server is _started_ in the "test" environment
func EnvTest ¶ added in v0.0.15
func EnvTest(w http.ResponseWriter, r *http.Request)
EnvTest changes the running environment to be "test" NOTE - This route to call this is only available when the server is _started_ in the "test" environment
func EscapeId ¶ added in v0.0.6
EscapeId puts an SQL identifier in quote characters and escapes any quote characters it contains, making it safe for use in SQL queries
func EscapeValue ¶ added in v0.0.6
EscapeValue formats, quotes and escapes a DataValue for use in SQL queries
func EscapeValues ¶ added in v0.0.7
EscapeValues does the same as EscapeValue but for a slice of DataValues
func FlushViewCount ¶
func FlushViewCount()
FlushViewCount periodically flushes the database view count from Memcache to PostgreSQL
func ForkDatabase ¶
ForkDatabase forks the PostgreSQL entry for a SQLite database from one user to another
func ForkParent ¶
func ForkParent(loggedInUser, dbOwner, dbFolder, dbName string) (parentOwner, parentFolder, parentDBName string, err error)
ForkParent returns the parent of a database, if there is one (and it's accessible to the logged in user). If no parent was found, the returned Owner/Folder/DBName values will be empty strings
func ForkedFrom ¶
func ForkedFrom(dbOwner, dbFolder, dbName string) (forkOwn, forkFol, forkDB string, forkDel bool, err error)
ForkedFrom checks if the given database was forked from another, and if so returns that one's owner, folder and database name
func GenerateClientCert ¶
GenerateClientCert generates a new DBHub.io client certificate for the given user
func GetAPIKeyUser ¶ added in v0.0.6
GetAPIKeyUser returns the owner of a given API key. Returns an empty string if the key has no known owner
func GetBranches ¶
func GetBranches(dbOwner, dbFolder, dbName string) (branches map[string]BranchEntry, err error)
GetBranches load the branch heads for a database TODO: It might be better to have the default branch name be returned as part of this list, by indicating in the list TODO which of the branches is the default.
func GetCachedData ¶
GetCachedData retrieves cached data from Memcached
func GetCommitList ¶
func GetCommitList(dbOwner, dbFolder, dbName string) (map[string]CommitEntry, error)
GetCommitList returns the full commit list for a database
func GetCurrentFunctionName ¶
func GetCurrentFunctionName() (FuncName string)
GetCurrentFunctionName returns the name of the function this was called from
func GetDatabase ¶
GetDatabase extracts a database name from GET or POST/PUT data
func GetDefaultBranchName ¶
GetDefaultBranchName returns the default branch name for a database
func GetDefaultTableName ¶
GetDefaultTableName returns the default table name for a database
func GetDiscussionAndMRCount ¶
GetDiscussionAndMRCount returns the discussion and merge request counts for a database TODO: The only reason this function exists atm, is because we're incorrectly caching the discussion and MR data in TODO a way that makes invalidating it correctly hard/impossible. We should redo our memcached approach to solve the TODO issue properly
func GetFormBranch ¶
GetFormBranch return the requested branch name, from get or post data
func GetFormCommit ¶
GetFormCommit returns the requested database commit, from form data
func GetFormLicence ¶
GetFormLicence returns the licence name (if any) present in the form data
func GetFormLive ¶ added in v0.0.15
GetFormLive returns the "live" value (if any) present in the form data
func GetFormODC ¶ added in v0.0.6
GetFormODC returns the database owner, database name, and commit (if any) present in the form data
func GetFormOwner ¶ added in v0.0.6
GetFormOwner returns the database owner present in the GET or POST/PUT data
func GetFormRelease ¶
GetFormRelease returns the requested release name, from get or post data
func GetFormSourceURL ¶
GetFormSourceURL returns the source URL (if any) present in the form data
func GetFormTable ¶ added in v0.0.6
GetFormTable returns the table name present in the GET or POST/PUT data
func GetFormTag ¶
GetFormTag returns the requested tag name, from get or post data
func GetFormUDC ¶
GetFormUDC returns the username, database, and commit (if any) present in the form data
func GetLicence ¶
GetLicence returns the text for a given licence
func GetLicenceInfoFromSha256 ¶
GetLicenceInfoFromSha256 returns the friendly name + licence URL for the licence matching a given sha256 Note - When user defined licence has the same sha256 as a default one we return the user defined licences' friendly name
func GetLicenceSha256FromName ¶
GetLicenceSha256FromName returns the sha256 for a given licence
func GetLicences ¶
func GetLicences(user string) (map[string]LicenceEntry, error)
GetLicences returns the list of licences available to a user
func GetODC ¶
func GetODC(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, commitID string, err error)
GetODC returns the requested database owner, database name, and commit revision
func GetODT ¶
func GetODT(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, requestedTable string, err error)
GetODT returns the requested database owner, database name, and table name
func GetODTC ¶
func GetODTC(ignoreLeading int, r *http.Request) (dbOwner string, dbName string, requestedTable string, commitID string, err error)
GetODTC returns the requested database owner, database name, table name, and commit string
func GetPrimaryKeyAndOtherColumns ¶ added in v0.0.7
func GetPrimaryKeyAndOtherColumns(sdb *sqlite.Conn, schema, table string) (pks []string, implicitPk bool, other []string, err error)
GetPrimaryKeyAndOtherColumns figures out the primary key columns and the other columns of a table. The schema and table parameters specify the schema and table names to use. This function returns two arrays: One containing the list of primary key columns in the same order as they are used in the primary key. The other array contains a list of all the other, non-primary key columns. Generated columns are ignored completely. If the primary key exists only implicitly, i.e. it's the rowid column, the implicitPk flag is set to true.
func GetPub ¶
GetPub returns the requested "public" variable, if present in the form data If something goes wrong, it defaults to "false".
func GetReleases ¶
func GetReleases(dbOwner, dbFolder, dbName string) (releases map[string]ReleaseEntry, err error)
GetReleases returns the list of releases for a database
func GetSQLiteRowCount ¶
GetSQLiteRowCount returns the number of rows in a SQLite table.
func GetShares ¶ added in v0.0.15
func GetShares(dbOwner, dbFolder, dbName string) (shares map[string]ShareDatabasePermissions, err error)
GetShares returns a map with all users for which the given database is shared as key and their permissions as value.
func GetUFD ¶
func GetUFD(r *http.Request, allowGet bool) (userName string, dbFolder string, dbName string, err error)
GetUFD returns the username, folder, and database name (if any) present in the form data
func GetUsername ¶
GetUsername returns the username (if any) present in the GET or POST/PUT data
func GetUsernameFromEmail ¶
GetUsernameFromEmail returns the username associated with an email address
func GetViewCount ¶
GetViewCount retrieves the view count in Memcached for a database
func GetVisualisations ¶ added in v0.0.6
GetVisualisations returns the list of saved visualisations for a given database
func IncrementDownloadCount ¶
IncrementDownloadCount increments the download count for a database
func IncrementViewCount ¶
IncrementViewCount increments the view counter in Memcached for a database
func InvalidateCacheEntry ¶
func InvalidateCacheEntry(loggedInUser string, dbOwner string, dbFolder string, dbName string, commitID string) error
InvalidateCacheEntry invalidate Memcache data for a database entry or entries
func IsCommitInBranchHistory ¶
IsCommitInBranchHistory checks if a given commit ID is in the history of the given branch
func LiveAddDatabasePG ¶ added in v0.0.15
LiveAddDatabasePG adds the details for a live database to PostgreSQL
func LiveCreateDB ¶ added in v0.0.15
LiveCreateDB requests the AMQP backend create a new live SQLite database
func LiveDatabasesOnNode ¶ added in v0.1.0
LiveDatabasesOnNode returns the list of databases that are on a specific live backend node
func LiveRetrieveDatabaseMinio ¶ added in v0.0.15
LiveRetrieveDatabaseMinio retrieves a live SQLite database from Minio, and places it on the local filesystem
func LiveStoreDatabaseMinio ¶ added in v0.0.15
LiveStoreDatabaseMinio stores a live SQLite database in Minio
func LogDB4SConnect ¶ added in v0.0.6
LogDB4SConnect creates a DB4S default browse list entry
func LogDownload ¶
func LogDownload(dbOwner, dbFolder, dbName, loggedInUser, ipAddr, serverSw, userAgent string, downloadDate time.Time, sha string) error
LogDownload creates a download log entry
func LogSQLiteQueryAfter ¶ added in v0.0.6
LogSQLiteQueryAfter adds memory allocation stats for the execution run of a user supplied SQLite query
func LogSQLiteQueryBefore ¶ added in v0.0.6
func LogSQLiteQueryBefore(source, dbOwner, dbFolder, dbName, loggedInUser, ipAddr, userAgent, query string) (int64, error)
LogSQLiteQueryBefore logs the basic info for a user supplied SQLite query
func LogUpload ¶
func LogUpload(dbOwner, dbFolder, dbName, loggedInUser, ipAddr, serverSw, userAgent string, uploadDate time.Time, sha string) error
LogUpload creates an upload log entry
func MQColumnsResponse ¶ added in v0.1.0
func MQColumnsResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, columns []sqlite.Column, errMsg string) (err error)
MQColumnsResponse sends a columns list response
func MQCreateDBQueue ¶ added in v0.0.15
MQCreateDBQueue creates a queue on the MQ server for "create database" messages
func MQCreateQueryQueue ¶ added in v0.0.15
MQCreateQueryQueue creates a queue on the MQ server for sending database queries to
func MQCreateResponse ¶ added in v0.0.15
func MQCreateResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName, result string) (err error)
MQCreateResponse sends a success/failure response back
func MQDeleteResponse ¶ added in v0.1.0
func MQDeleteResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, errMsg string) (err error)
MQDeleteResponse sends an error message in response to an AMQP database deletion request
func MQErrorResponse ¶ added in v0.1.0
func MQErrorResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, errMsg string) (err error)
MQErrorResponse sends an error message in response to an AMQP request It is probably only useful for returning errors that occur before we've decoded the incoming AMQP request to know what type it is
func MQExecResponse ¶ added in v0.1.0
func MQExecResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, errMsg string) (err error)
MQExecResponse sends a message in response to an AMQP database query exec request
func MQIndexesResponse ¶ added in v0.1.0
func MQIndexesResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, indexes []APIJSONIndex, errMsg string) (err error)
MQIndexesResponse sends an indexes list response
func MQQueryResponse ¶ added in v0.1.0
func MQQueryResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, results SQLiteRecordSet, errMsg string) (err error)
MQQueryResponse sends a successful query response back
func MQSendRequest ¶ added in v0.1.0
func MQTablesResponse ¶ added in v0.1.0
func MQTablesResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, tables []string, errMsg string) (err error)
MQTablesResponse sends a tables list response to an AMQP caller
func MQViewsResponse ¶ added in v0.1.0
func MQViewsResponse(msg amqp.Delivery, channel *amqp.Channel, nodeName string, views []string, errMsg string) (err error)
MQViewsResponse sends a views list response to an AMQP caller
func MemcacheHandle ¶
MemcacheHandle returns the Memcached handle
func Merge ¶ added in v0.0.15
func Merge(destOwner, destFolder, destName, destBranch, srcOwner, srcFolder, srcName string, commitDiffList []CommitEntry, message, loggedInUser string) (newCommitID string, err error)
Merge merges the commits in commitDiffList into the destination branch destBranch of the given database
func MetadataCacheKey ¶
func MetadataCacheKey(prefix string, loggedInUser string, dbOwner string, dbFolder string, dbName string, commitID string) string
MetadataCacheKey generates a predictable cache key for metadata information
func MinioDeleteDatabase ¶ added in v0.0.15
MinioDeleteDatabase deletes a database file from Minio
func MinioHandle ¶
MinioHandle gets a handle from Minio for a SQLite database object
func MinioHandleClose ¶
func MinioHandleClose(userDB *minio.Object) (err error)
MinioHandleClose closes a Minio object handle. Probably most useful for calling with defer()
func MinioLocation ¶
func MinioLocation(dbOwner, dbFolder, dbName, commitID, loggedInUser string) (minioBucket, minioID string, lastModified time.Time, err error)
MinioLocation returns the Minio bucket and ID for a given database. dbOwner, dbFolder, & dbName are from owner/folder/database URL fragment, loggedInUser is the name for the currently logged in user, for access permission check. Use an empty string ("") as the loggedInUser parameter if the true value isn't set or known. If the requested database doesn't exist, or the loggedInUser doesn't have access to it, then an error will be returned
func NewEvent ¶
func NewEvent(details EventDetails) (err error)
NewEvent adds an event entry to PostgreSQL
func OpenSQLiteDatabase ¶ added in v0.0.6
OpenSQLiteDatabase retrieves a SQLite database from Minio, opens it, then returns the connection handle.
func OpenSQLiteDatabaseDefensive ¶ added in v0.0.6
func OpenSQLiteDatabaseDefensive(w http.ResponseWriter, r *http.Request, dbOwner, dbFolder, dbName, commitID, loggedInUser string) (sdb *sqlite.Conn, err error)
OpenSQLiteDatabaseDefensive is similar to OpenSQLiteDatabase(), but opens the database Read Only and implements the recommended defensive precautions for potentially malicious user provided SQL queries: https://www.sqlite.org/security.html
func OpenSQLiteDatabaseLive ¶ added in v0.0.15
OpenSQLiteDatabaseLive is similar to OpenSQLiteDatabase(), but opens the a live SQLite database and implements the recommended defensive precautions for potentially malicious user provided SQL queries: https://www.sqlite.org/security.html
func PrefUserMaxRows ¶
PrefUserMaxRows returns the user's preference for maximum number of SQLite rows to display.
func RandomString ¶
RandomString generates a random alphanumeric string of the desired length
func ReadSQLiteDBCSV ¶
ReadSQLiteDBCSV is a specialised variation of the ReadSQLiteDB() function, just for our CSV exporting code. It may be merged with that in future.
func RenameDatabase ¶
RenameDatabase renames a SQLite database
func ReservedUsernamesCheck ¶
ReservedUsernamesCheck checks a username against the list of reserved ones
func ResetDB ¶ added in v0.0.15
func ResetDB() error
ResetDB resets the database to its default state. eg for testing purposes
func RetrieveDatabaseFile ¶ added in v0.0.6
RetrieveDatabaseFile retrieves a SQLite database file from Minio. If there's a locally cached version already available though, use that
func SQLiteExecQueryLive ¶ added in v0.1.0
SQLiteExecQueryLive is used by our AMQP backend infrastructure to execute a user provided SQLite query
func SQLiteGetColumnsLive ¶ added in v0.0.15
func SQLiteGetColumnsLive(baseDir, dbOwner, dbName, table string) (columns []sqlite.Column, err error)
SQLiteGetColumnsLive is used by our AMQP backend nodes to retrieve the list of columns from a SQLite database
func SQLiteGetTablesLive ¶ added in v0.0.15
SQLiteGetTablesLive is used by our AMQP backend nodes to retrieve the list of tables in a SQLite database
func SQLiteGetViewsLive ¶ added in v0.0.15
SQLiteGetViewsLive is used by our AMQP backend nodes to retrieve the list of views in a SQLite database
func SQLiteSanityCheck ¶ added in v0.0.15
SQLiteSanityCheck performs basic sanity checks of an uploaded database.
func SQLiteVersionNumber ¶ added in v0.0.6
func SQLiteVersionNumber() int32
SQLiteVersionNumber returns the version number of the available SQLite library, in 300X00Y format.
func SanitiseLogString ¶ added in v0.0.15
func SaveDBSettings ¶
func SaveDBSettings(userName, dbFolder, dbName, oneLineDesc, fullDesc, defaultTable string, public bool, sourceURL, defaultBranch string) error
SaveDBSettings saves updated database settings to PostgreSQL
func SendEmails ¶
func SendEmails()
SendEmails sends status update emails to people watching databases
func SetClientCert ¶
SetClientCert stores a certificate for a given client
func SetUserPreferences ¶
SetUserPreferences sets the user's preference for maximum number of SQLite rows to display
func SetUserStatusUpdates ¶
SetUserStatusUpdates increments the view counter in Memcached for a database
func SocialStats ¶
SocialStats returns the latest social stats for a given database
func StatusUpdateCheck ¶
func StatusUpdateCheck(dbOwner, dbFolder, dbName string, thisID int, userName string) (numStatusUpdates int, err error)
StatusUpdateCheck checks if a status update for the user exists for a given discussion or MR, and if so then removes it
func StatusUpdates ¶
func StatusUpdates(loggedInUser string) (statusUpdates map[string][]StatusUpdateEntry, err error)
StatusUpdates returns the list of outstanding status updates for a user
func StatusUpdatesLoop ¶
func StatusUpdatesLoop()
StatusUpdatesLoop periodically generates status updates (alert emails TBD) from the event queue
func StoreBranches ¶
func StoreBranches(dbOwner, dbFolder, dbName string, branches map[string]BranchEntry) error
StoreBranches updates the branches list for a database
func StoreComment ¶
func StoreComment(dbOwner, dbFolder, dbName, commenter string, discID int, comText string, discClose bool, mrState MergeRequestState) error
StoreComment adds a comment to a discussion
func StoreCommits ¶
func StoreCommits(dbOwner, dbFolder, dbName string, commitList map[string]CommitEntry) error
StoreCommits updates the commit list for a database
func StoreDatabase ¶
func StoreDatabase(dbOwner, dbFolder, dbName string, branches map[string]BranchEntry, c CommitEntry, pub bool, buf *os.File, sha string, dbSize int64, oneLineDesc, fullDesc string, createDefBranch bool, branchName, sourceURL string) error
StoreDatabase stores database details in PostgreSQL, and the database data itself in Minio
func StoreDatabaseFile ¶
StoreDatabaseFile stores a database file in Minio
func StoreDefaultBranchName ¶
StoreDefaultBranchName stores the default branch name for a database
func StoreDefaultTableName ¶
StoreDefaultTableName stores the default table name for a database
func StoreDiscussion ¶
func StoreDiscussion(dbOwner, dbFolder, dbName, loggedInUser, title, text string, discType DiscussionType, mr MergeRequestEntry) (newID int, err error)
StoreDiscussion stores a new discussion for a database
func StoreLicence ¶
func StoreLicence(userName, licenceName string, txt []byte, url string, orderNum int, fullName, fileFormat string) error
StoreLicence stores a licence
func StoreReleases ¶
func StoreReleases(dbOwner, dbFolder, dbName string, releases map[string]ReleaseEntry) error
StoreReleases stores the releases for a database
func StoreShares ¶ added in v0.0.15
func StoreShares(dbOwner, dbFolder, dbName string, shares map[string]ShareDatabasePermissions) (err error)
StoreShares stores the shares of a database
func StoreStatusUpdates ¶
func StoreStatusUpdates(userName string, statusUpdates map[string][]StatusUpdateEntry) error
StoreStatusUpdates stores the status updates list for a user
func SwitchDefault ¶ added in v0.0.15
func SwitchDefault(w http.ResponseWriter, r *http.Request)
SwitchDefault changes the logged in user to be the user "default"
func SwitchFirst ¶ added in v0.0.15
func SwitchFirst(w http.ResponseWriter, r *http.Request)
SwitchFirst changes the logged in user to be the test user "first"
func SwitchSecond ¶ added in v0.0.15
func SwitchSecond(w http.ResponseWriter, r *http.Request)
SwitchSecond changes the logged in user to be the test user "second"
func SwitchThird ¶ added in v0.0.15
func SwitchThird(w http.ResponseWriter, r *http.Request)
SwitchThird changes the logged in user to be the test user "third"
func TableRowsCacheKey ¶
func TableRowsCacheKey(prefix string, loggedInUser string, dbOwner string, dbFolder string, dbName string, commitID string, dbTable string, rows int) string
TableRowsCacheKey generates a predictable cache key for SQLite row data
func TablesAndViews ¶ added in v0.0.6
TablesAndViews returns the list of tables and views in the SQLite database.
func TestLogout ¶ added in v0.0.15
func TestLogout(w http.ResponseWriter, r *http.Request)
TestLogout logs out the user for test runs
func ToggleDBStar ¶
ToggleDBStar toggles the starring of a database by a user
func ToggleDBWatch ¶
ToggleDBWatch toggles the watch status of a database by a user
func UpdateAvatarURL ¶
UpdateAvatarURL updates the Avatar URL for a user
func UpdateComment ¶
func UpdateComment(dbOwner, dbFolder, dbName, loggedInUser string, discID, comID int, newText string) error
UpdateComment updates the text for a comment
func UpdateContributorsCount ¶
UpdateContributorsCount updates the contributors count for a database
func UpdateDiscussion ¶
func UpdateDiscussion(dbOwner, dbFolder, dbName, loggedInUser string, discID int, newTitle, newText string) error
UpdateDiscussion updates the text for a discussion
func UpdateMergeRequestCommits ¶
func UpdateMergeRequestCommits(dbOwner, dbFolder, dbName string, discID int, mrCommits []CommitEntry) (err error)
UpdateMergeRequestCommits updates the commit list for a Merge Request
func UploadResponse ¶ added in v0.0.13
func UploadResponse(w http.ResponseWriter, r *http.Request, loggedInUser, targetUser, targetDB, commitID, serverSw string) (retMsg map[string]string, httpStatus int, err error)
UploadResponse validates incoming upload requests from the db4s and api daemons, then processes the upload
func UserNameFromAuth0ID ¶
UserNameFromAuth0ID returns the username for a given Auth0 ID
func UserStatusUpdates ¶
UserStatusUpdates returns the number of status updates outstanding for a user
func ValidateBranchName ¶
ValidateBranchName validates the provided branch, release, or tag name
func ValidateCommitID ¶ added in v0.0.5
ValidateCommitID validates the provided commit ID
func ValidateDiscussionTitle ¶
ValidateDiscussionTitle validates the provided discussion or merge request title
func ValidateDisplayName ¶ added in v0.0.5
ValidateDisplayName validates a provided full name
func ValidateEmail ¶
ValidateEmail validates the provided email address
func ValidateFieldName ¶
ValidateFieldName validates the SQLite field name
func ValidateFolder ¶
ValidateFolder validates the provided folder name
func ValidateLicence ¶
ValidateLicence validates the provided licence name (ID)
func ValidateLicenceFullName ¶ added in v0.0.5
ValidateLicenceFullName validate the provided licence full name
func ValidateMarkdown ¶
ValidateMarkdown validates the provided markdown
func ValidatePGTable ¶
ValidatePGTable validates the provided PostgreSQL table name
func ValidateUser ¶
ValidateUser validates the provided username
func ValidateUserDB ¶
ValidateUserDB validates the provided user and database name
func ValidateUserDBTable ¶
ValidateUserDBTable validates the provided user, database, and table name
func ValidateUserEmail ¶
ValidateUserEmail validates the provided username and email address
func VisualisationDeleteParams ¶ added in v0.0.6
VisualisationDeleteParams deletes a set of visualisation parameters
func VisualisationSaveData ¶ added in v0.0.6
func VisualisationSaveData(dbOwner, dbFolder, dbName, commitID, hash string, visData []VisRowV1) (err error)
VisualisationSaveData saves visualisation result data for later retrieval
func VisualisationSaveParams ¶ added in v0.0.6
func VisualisationSaveParams(dbOwner, dbFolder, dbName, visName string, visParams VisParamsV2) (err error)
VisualisationSaveParams saves a set of visualisation parameters for later retrieval
func WriteDBtoDisk ¶ added in v0.0.15
func WriteDBtoDisk(loggedInUser, dbOwner, dbFolder, dbName string, newDB io.Reader) (numBytes int64, tempDB *os.File, sha string, sTbls []string, err error)
WriteDBtoDisk gets an uploaded database file from the user's incoming request, and writes it to a local temporary file
Types ¶
type APIJSONColumn ¶ added in v0.0.6
type APIJSONColumn struct { Cid int `json:"column_id"` Name string `json:"name"` DataType string `json:"data_type"` NotNull bool `json:"not_null"` DfltValue string `json:"default_value"` Pk int `json:"primary_key"` }
APIJSONColumn is a copy of the Column type from github.com/gwenn/gosqlite, but including JSON field name info
type APIJSONIndex ¶ added in v0.0.11
type APIJSONIndex struct { Name string `json:"name"` Table string `json:"table"` Columns []APIJSONIndexColumn `json:"columns"` }
APIJSONIndex holds the details of an index for a SQLite database. It's used by our API for returning index information
func SQLiteGetIndexesLive ¶ added in v0.0.15
func SQLiteGetIndexesLive(baseDir, dbOwner, dbName string) (indexes []APIJSONIndex, err error)
SQLiteGetIndexesLive is used by our AMQP backend nodes to retrieve the list of indexes from a SQLite database
type APIJSONIndexColumn ¶ added in v0.0.11
APIJSONIndexColumn holds the details of one column of a SQLite database index. It's used by our API for returning index information
type APIKey ¶ added in v0.0.6
APIKey is an internal structure used for passing around user API keys
func GetAPIKeys ¶ added in v0.0.6
GetAPIKeys returns the list of API keys for a user
type AccessType ¶
type AccessType int
AccessType is whether a database is private, or public, or both
const ( DB_BOTH AccessType = iota DB_PRIVATE DB_PUBLIC )
type ActivityRange ¶
type ActivityRange string
type ActivityRow ¶
type ActivityStats ¶
type ActivityStats struct { Downloads []ActivityRow Forked []ActivityRow Starred []ActivityRow Uploads []UploadRow Viewed []ActivityRow }
func GetActivityStats ¶
func GetActivityStats() (stats ActivityStats, err error)
GetActivityStats returns the latest activity stats
type ApiInfo ¶ added in v0.0.6
type ApiInfo struct { BaseDir string `toml:"base_dir"` BindAddress string `toml:"bind_address"` Certificate string `toml:"certificate"` CertificateKey string `toml:"certificate_key"` RequestLog string `toml:"request_log"` ServerName string `toml:"server_name"` }
ApiInfo contains configuration info for the API daemon
type BranchEntry ¶
type BranchListResponseContainer ¶ added in v0.0.8
type BranchListResponseContainer struct { Branches map[string]BranchEntry `json:"branches"` DefaultBranch string `json:"default_branch"` }
BranchListResponseContainer holds the response to a client request for the database branch list. It's a temporary structure, mainly so the JSON created for it is consistent between our various daemons
func BranchListResponse ¶ added in v0.0.8
func BranchListResponse(dbOwner, dbFolder, dbName string) (list BranchListResponseContainer, err error)
BranchListResponse returns the branch list for a database. It's used by both the DB4S and API daemons, to ensure they return exactly the same data
type CommitData ¶
type CommitData struct { AuthorAvatar string `json:"author_avatar"` AuthorEmail string `json:"author_email"` AuthorName string `json:"author_name"` AuthorUsername string `json:"author_username"` ID string `json:"id"` Parent string `json:"parent"` LicenceChange string `json:"licence_change"` Message string `json:"message"` Timestamp time.Time `json:"timestamp"` }
type CommitEntry ¶
type CommitEntry struct { AuthorEmail string `json:"author_email"` AuthorName string `json:"author_name"` CommitterEmail string `json:"committer_email"` CommitterName string `json:"committer_name"` ID string `json:"id"` Message string `json:"message"` OtherParents []string `json:"other_parents"` Parent string `json:"parent"` Timestamp time.Time `json:"timestamp"` Tree DBTree `json:"tree"` }
func GetCommonAncestorCommits ¶
func GetCommonAncestorCommits(srcOwner, srcFolder, srcDBName, srcBranch, destOwner, destFolder, destName, destBranch string) (ancestorID string, commitList []CommitEntry, errType int, err error)
GetCommonAncestorCommits determines the common ancestor commit (if any) between a source and destination branch. Returns the commit ID of the ancestor and a slice of the commits between them. If no common ancestor exists, the returned ancestorID will be an empty string. Created for use by our Merge Request functions.
type DB4SInfo ¶
type DB4SInfo struct { CAChain string `toml:"ca_chain"` Certificate string CertificateKey string `toml:"certificate_key"` Debug bool Port int Server string }
DB4SInfo contains configuration info for the DB4S end point daemon
type DBEntry ¶
type DBEntry struct { Folder string DateEntry time.Time DBName string Owner string OwnerDisplayName string `json:"display_name"` }
func UserStarredDBs ¶
UserStarredDBs returns the list of databases starred by a user
func UserWatchingDBs ¶
UserWatchingDBs returns the list of databases watched by a user
func UsersStarredDB ¶
UsersStarredDB returns the list of users who starred a database
func UsersWatchingDB ¶
UsersWatchingDB returns the list of users watching a database
type DBInfo ¶
type DBInfo struct { Branch string Branches int BranchList []string Commits int CommitID string Contributors int Database string DateCreated time.Time DBEntry DBTreeEntry DefaultBranch string DefaultTable string Discussions int Downloads int Folder string Forks int FullDesc string LastModified time.Time Licence string LicenceURL string MRs int OneLineDesc string Public bool RepoModified time.Time Releases int SHA256 string Size int64 SourceURL string Stars int Tables []string Tags int Views int Watchers int }
func LiveUserDBs ¶ added in v0.0.15
LiveUserDBs returns the list of live databases owned by the user
type DBTree ¶
type DBTree struct { ID string `json:"id"` Entries []DBTreeEntry `json:"entries"` }
type DBTreeEntry ¶
type DBTreeEntryType ¶
type DBTreeEntryType string
type DataDiff ¶ added in v0.0.6
type DataDiff struct { ActionType DiffType `json:"action_type"` Sql string `json:"sql,omitempty"` Pk []DataValue `json:"pk"` DataBefore []interface{} `json:"data_before,omitempty"` DataAfter []interface{} `json:"data_after,omitempty"` }
DataDiff stores a single change in the data of a table, i.e. a single new, deleted, or changed row
type DiffObjectChangeset ¶ added in v0.0.6
type DiffObjectChangeset struct { ObjectName string `json:"object_name"` ObjectType string `json:"object_type"` Schema *SchemaDiff `json:"schema,omitempty"` Data []DataDiff `json:"data,omitempty"` }
DiffObjectChangeset stores all the differences between two objects in a database, for example two tables. Both Schema and Data are optional and can be nil if there are no respective changes in this object.
type DiffType ¶ added in v0.0.6
type DiffType string
DiffType specifies the type of change in a row or object
type Diffs ¶ added in v0.0.6
type Diffs struct {
Diff []DiffObjectChangeset `json:"diff"`
}
Diffs is able to store all the differences between two databases.
func Diff ¶ added in v0.0.6
func Diff(ownerA string, folderA string, nameA string, commitA string, ownerB string, folderB string, nameB string, commitB string, loggedInUser string, merge MergeStrategy, includeData bool) (Diffs, error)
Diff generates the differences between the two commits commitA and commitB of the two databases specified in the other parameters
type DiscussionCommentEntry ¶
type DiscussionCommentEntry struct { AvatarURL string `json:"avatar_url"` Body string `json:"body"` BodyRendered string `json:"body_rendered"` Commenter string `json:"commenter"` DateCreated time.Time `json:"creation_date"` EntryType DiscussionCommentType `json:"entry_type"` ID int `json:"com_id"` }
func DiscussionComments ¶
func DiscussionComments(dbOwner, dbFolder, dbName string, discID, comID int) (list []DiscussionCommentEntry, err error)
DiscussionComments returns the list of comments for a given discussion If a non-0 comID value is passed, it will only return the details for that specific comment in the discussion. Otherwise it will return a list of all comments for a given discussion Note - This returns a slice instead of a map. We use a slice because it lets us use an ORDER BY clause in the SQL
and preserve the returned order (maps don't preserve order). If in future we no longer need to preserve the order, it might be useful to switch to using a map instead since they're often simpler to work with.
type DiscussionCommentType ¶
type DiscussionCommentType string
type DiscussionEntry ¶
type DiscussionEntry struct { AvatarURL string `json:"avatar_url"` Body string `json:"body"` BodyRendered string `json:"body_rendered"` CommentCount int `json:"comment_count"` Creator string `json:"creator"` DateCreated time.Time `json:"creation_date"` ID int `json:"disc_id"` LastModified time.Time `json:"last_modified"` MRDetails MergeRequestEntry `json:"mr_details"` Open bool `json:"open"` Title string `json:"title"` Type DiscussionType `json:"discussion_type"` }
func Discussions ¶
func Discussions(dbOwner, dbFolder, dbName string, discType DiscussionType, discID int) (list []DiscussionEntry, err error)
Discussions returns the list of discussions or MRs for a given database If a non-0 discID value is passed, it will only return the details for that specific discussion/MR. Otherwise it will return a list of all discussions or MRs for a given database Note - This returns a slice of DiscussionEntry, instead of a map. We use a slice because it lets us use an ORDER
BY clause in the SQL and preserve the returned order (maps don't preserve order). If in future we no longer need to preserve the order, it might be useful to switch to using a map instead since they're often simpler to work with.
type DiscussionType ¶
type DiscussionType int
const ( DISCUSSION DiscussionType = 0 // These are not iota, as it would be seriously bad for these numbers to change MERGE_REQUEST = 1 )
type DiskCacheInfo ¶
type DiskCacheInfo struct {
Directory string
}
DiskCacheInfo contains the path to the root of the local disk cache
type EnvInfo ¶
EnvInfo holds information about the purpose of the running server. eg "is this a production, docker, or development" instance?
type EventDetails ¶
type EventDetails struct { DBName string `json:"database_name"` DiscID int `json:"discussion_id"` Folder string `json:"database_folder"` ID string `json:"event_id"` Message string `json:"message"` Owner string `json:"database_owner"` Timestamp time.Time `json:"event_timestamp"` Title string `json:"title"` Type EventType `json:"event_type"` URL string `json:"event_url"` UserName string `json:"username"` }
type EventProcessingInfo ¶
type EventProcessingInfo struct { Delay time.Duration `toml:"delay"` EmailQueueProcessingDelay time.Duration `toml:"email_queue_processing_delay"` Smtp2GoKey string `toml:"smtp2go_key"` // The SMTP2GO API key }
EventProcessingInfo hold configuration for the event processing loop
type ForkEntry ¶
type ForkEntry struct { DBName string `json:"database_name"` Folder string `json:"database_folder"` ForkedFrom int `json:"forked_from"` IconList []ForkType `json:"icon_list"` ID int `json:"id"` Owner string `json:"database_owner"` Processed bool `json:"processed"` Public bool `json:"public"` Deleted bool `json:"deleted"` }
type JsonError ¶ added in v0.0.6
type JsonError struct {
Error string `json:"error"`
}
JsonError holds the details of an error. It's used by our API for returning error information
type LicenceEntry ¶
type LicenceInfo ¶ added in v0.0.5
type LicenceInfo struct {
LicenceDir string `toml:"licence_dir"`
}
LicenceInfo -> LicenceDir holds the path to the licence files
type LiveDBColumnsResponse ¶ added in v0.0.15
type LiveDBColumnsResponse struct { Node string `json:"node"` Columns []sqlite.Column `json:"columns"` Error string `json:"error"` }
LiveDBColumnsResponse holds the fields used for receiving column list responses from our AMQP backend
type LiveDBErrorResponse ¶ added in v0.0.15
LiveDBErrorResponse holds just the node name and any error message used in responsed by our AMQP backend It's useful for error message, and other responses where no other fields are needed
type LiveDBIndexesResponse ¶ added in v0.0.15
type LiveDBIndexesResponse struct { Node string `json:"node"` Indexes []APIJSONIndex `json:"indexes"` Error string `json:"error"` }
LiveDBIndexesResponse holds the fields used for receiving index list responses from our AMQP backend
type LiveDBQueryResponse ¶ added in v0.0.15
type LiveDBQueryResponse struct { Node string `json:"node"` Results SQLiteRecordSet `json:"results"` Error string `json:"error"` }
LiveDBQueryResponse holds the fields used for receiving query responses from our AMQP backend
type LiveDBRequest ¶ added in v0.0.15
type LiveDBRequest struct { Operation string `json:"operation"` DBOwner string `json:"dbowner"` DBName string `json:"dbname"` Query string `json:"query"` RequestingUser string `json:"requesting_user"` }
LiveDBRequest holds the fields used for sending requests to our AMQP backend
type LiveDBResponse ¶ added in v0.0.15
type LiveDBResponse struct { Node string `json:"node"` Result string `json:"result"` Error string `json:"error"` }
LiveDBResponse holds the fields used for receiving (non-query) responses from our AMQP backend
type LiveDBTablesResponse ¶ added in v0.0.15
type LiveDBTablesResponse struct { Node string `json:"node"` Tables []string `json:"tables"` Error string `json:"error"` }
LiveDBTablesResponse holds the fields used for receiving table list responses from our AMQP backend
type LiveDBViewsResponse ¶ added in v0.0.15
type LiveDBViewsResponse struct { Node string `json:"node"` Views []string `json:"views"` Error string `json:"error"` }
LiveDBViewsResponse holds the fields used for receiving view list responses from our AMQP backend
type LiveDBs ¶ added in v0.1.0
type LiveDBs struct { DBOwner string `json:"owner_name"` DBName string `json:"database_name"` DateCreated time.Time `json:"date_created"` }
LiveDBs is used for general purpose holding of details about live databases
type MQInfo ¶ added in v0.0.15
type MQInfo struct { CertFile string `toml:"cert_file"` KeyFile string `toml:"key_file"` Password string `toml:"password"` Port int `toml:"port"` Server string `toml:"server"` Username string `toml:"username"` }
MQInfo contains the AMQP backend connection configuration info
type MemcacheInfo ¶
type MemcacheInfo struct { DefaultCacheTime int `toml:"default_cache_time"` Server string `toml:"server"` ViewCountFlushDelay time.Duration `toml:"view_count_flush_delay"` }
MemcacheInfo contains the Memcached configuration parameters
type MergeRequestEntry ¶
type MergeRequestEntry struct { Commits []CommitEntry `json:"commits"` DestBranch string `json:"destination_branch"` SourceBranch string `json:"source_branch"` SourceDBID int64 `json:"source_database_id"` SourceDBName string `json:"source_database_name"` SourceFolder string `json:"source_folder"` SourceOwner string `json:"source_owner"` State MergeRequestState `json:"state"` }
type MergeRequestState ¶
type MergeRequestState int
type MergeStrategy ¶ added in v0.0.7
type MergeStrategy int
MergeStrategy specifies the type of SQL statements included in the diff results. The SQL statements can be used for merging databases and depending on whether and how you want to merge you should choose your merge strategy.
const ( // NoMerge removes any SQL statements for merging from the diff results NoMerge MergeStrategy = iota // PreservePkMerge produces SQL statements which preserve the values of the primary key columns. // Executing these statements on the first database produces a database similar to the second. PreservePkMerge // NewPkMerge produces SQL statements which generate new values for the primary key columns when // executed. This avoids a couple of possible conflicts and allows merging more distant databases. NewPkMerge )
type MetadataResponseContainer ¶ added in v0.0.8
type MetadataResponseContainer struct { Branches map[string]BranchEntry `json:"branches"` Commits map[string]CommitEntry `json:"commits"` DefBranch string `json:"default_branch"` Releases map[string]ReleaseEntry `json:"releases"` Tags map[string]TagEntry `json:"tags"` WebPage string `json:"web_page"` }
MetadataResponseContainer holds the response to a client request for database metadata. It's a temporary structure, mainly so the JSON created for it is consistent between our various daemons
func MetadataResponse ¶ added in v0.0.8
func MetadataResponse(dbOwner, dbFolder, dbName string) (meta MetadataResponseContainer, err error)
MetadataResponse returns the metadata for a database. It's used by both the DB4S and API daemons, to ensure they return exactly the same data
type MinioInfo ¶
type MinioInfo struct { AccessKey string `toml:"access_key"` HTTPS bool Secret string Server string }
MinioInfo contains the Minio connection parameters
type PGInfo ¶
type PGInfo struct { Database string NumConnections int `toml:"num_connections"` Port int Password string Server string SSL bool Username string }
PGInfo contains the PostgreSQL connection parameters
type QuerySource ¶ added in v0.0.6
type QuerySource int
QuerySource is used internally to help choose the output format from a SQL query
const ( QuerySourceWebUI QuerySource = iota QuerySourceDB4S QuerySourceVisualisation QuerySourceAPI QuerySourceInternal )
type ReleaseEntry ¶
type SQLiteDBinfo ¶
type SQLiteRecordSet ¶
type SQLiteRecordSet struct { ColCount int ColNames []string Offset int Records []DataRow RowCount int SortCol string SortDir string Tablename string TotalRows int }
func LiveQueryDB ¶ added in v0.1.0
func LiveQueryDB(channel *amqp.Channel, nodeName, requestingUser, dbOwner, dbName, query string) (rows SQLiteRecordSet, err error)
LiveQueryDB sends a SQLite query to a live database on its hosting node
func ReadSQLiteDB ¶
func ReadSQLiteDB(sdb *sqlite.Conn, dbTable, sortCol, sortDir string, maxRows, rowOffset int) (SQLiteRecordSet, error)
ReadSQLiteDB reads up to maxRows number of rows from a given SQLite database table. If maxRows < 0 (eg -1), then read all rows.
func ReadSQLiteDBCols ¶
func ReadSQLiteDBCols(sdb *sqlite.Conn, dbTable, sortCol, sortDir string, ignoreBinary, ignoreNull bool, maxRows, rowOffset int) (SQLiteRecordSet, error)
ReadSQLiteDBCols reads up to maxRows # of rows from a SQLite database. Only returns the requested columns.
func SQLiteRunQuery ¶ added in v0.0.6
func SQLiteRunQuery(sdb *sqlite.Conn, querySource QuerySource, dbQuery string, ignoreBinary, ignoreNull bool) (memUsed, memHighWater int64, dataRows SQLiteRecordSet, err error)
SQLiteRunQuery runs a SQLite query. DO NOT use this for user provided SQL queries. For those, use SQLiteRunQueryDefensive().
func SQLiteRunQueryDefensive ¶ added in v0.0.6
func SQLiteRunQueryDefensive(w http.ResponseWriter, r *http.Request, querySource QuerySource, dbOwner, dbFolder, dbName, commitID, loggedInUser, query string) (SQLiteRecordSet, error)
SQLiteRunQueryDefensive runs a user provided SQLite query, using our "defensive" mode. eg with limits placed on what it's allowed to do.
func SQLiteRunQueryLive ¶ added in v0.0.15
func SQLiteRunQueryLive(baseDir, dbOwner, dbName, loggedInUser, query string) (records SQLiteRecordSet, err error)
SQLiteRunQueryLive is used by our AMQP backend infrastructure to run a user provided SQLite query
type SchemaDiff ¶ added in v0.0.6
type SchemaDiff struct { ActionType DiffType `json:"action_type"` Sql string `json:"sql,omitempty"` Before string `json:"before"` After string `json:"after"` }
SchemaDiff describes the changes to the schema of a database object, i.e. a created, dropped or altered object
type SetAccessType ¶ added in v0.0.15
type SetAccessType int
SetAccessType is used for setting the public flag of a database
const ( SetToPublic SetAccessType = iota SetToPrivate KeepCurrentAccessType )
type SetDBType ¶ added in v0.0.15
type SetDBType int
SetDBType is used for setting what type of database we're working with
type ShareDatabasePermissions ¶ added in v0.0.15
type ShareDatabasePermissions string
const ( MayRead ShareDatabasePermissions = "r" MayReadAndWrite ShareDatabasePermissions = "rw" )
type ShareDatabasePermissionsOthers ¶ added in v0.0.15
type ShareDatabasePermissionsOthers struct {}
ShareDatabasePermissionsOthers contains a list of user permissions for a given database
type ShareDatabasePermissionsUser ¶ added in v0.0.15
type ShareDatabasePermissionsUser struct {}
ShareDatabasePermissionsUser contains a list of shared database permissions for a given user
func GetSharesForUser ¶ added in v0.0.15
func GetSharesForUser(userName string) (shares []ShareDatabasePermissionsUser, err error)
GetSharesForUser returns a list of all the databases shared with the given user, and their permissions.
type SigningInfo ¶
type SigningInfo struct { CertDaysValid int `toml:"cert_days_valid"` Enabled bool `toml:"enabled"` IntermediateCert string `toml:"intermediate_cert"` IntermediateKey string `toml:"intermediate_key"` }
SigningInfo contains the info used for signing DB4S client certificates
type StatusResponseContainer ¶ added in v0.0.14
type StatusResponseContainer struct {
Status string `json:"status"`
}
StatusResponseContainer holds a general status message response to a client request.
type StatusUpdateEntry ¶
type TomlConfig ¶
type TomlConfig struct { Api ApiInfo Auth0 Auth0Info DB4S DB4SInfo Environment EnvInfo DiskCache DiskCacheInfo Event EventProcessingInfo Licence LicenceInfo Live LiveInfo Memcache MemcacheInfo Minio MinioInfo MQ MQInfo Pg PGInfo Sign SigningInfo UserMgmt UserMgmtInfo Web WebInfo }
TomlConfig is a top level structure containing the server configuration information
var ( // Conf holds our configuration info Conf TomlConfig )
type UploadResponseContainer ¶ added in v0.0.13
UploadResponseContainer holds the response to a client upload. It's a temporary structure, mainly so the JSON created for it is consistent between our various daemons
type UserDetails ¶
type UserDetails struct { AvatarURL string ClientCert []byte DateJoined time.Time DisplayName string Email string Password string PHash []byte PVerify string Username string }
func User ¶
func User(userName string) (user UserDetails, err error)
User returns details for a user
type UserInfoSlice ¶ added in v0.0.6
type UserInfoSlice []UserInfo
UserInfoSlice is used for sorting a UserInfo list by Last Modified date descending
func DB4SDefaultList ¶
func DB4SDefaultList(loggedInUser string) (UserInfoSlice, error)
DB4SDefaultList returns a list of 1) users with public databases, 2) along with the logged in users' most recently modified database (including their private one(s))
func (UserInfoSlice) Len ¶ added in v0.0.6
func (u UserInfoSlice) Len() int
func (UserInfoSlice) Less ¶ added in v0.0.6
func (u UserInfoSlice) Less(i, j int) bool
func (UserInfoSlice) Swap ¶ added in v0.0.6
func (u UserInfoSlice) Swap(i, j int)
type UserMgmtInfo ¶ added in v0.0.15
type UserMgmtInfo struct { BannedUsers []string `toml:"banned_users"` // List of users banned from the service SizeOverrideUsers []string `toml:"size_override_users"` // List of users allowed to override the database upload size limits }
UserMgmtInfo contains the various settings for specific users, or groups of users
type ValType ¶
type ValType int
ValType indicates the type of data in a field returned from a SQLite query
type VisGetFields ¶ added in v0.0.6
type VisGetFields struct {
VisName string `validate:"required,visname,min=1,max=63"` // 63 char limit seems reasonable
}
VisGetFields is used when validating input
type VisParamsV2 ¶ added in v0.0.6
type VisParamsV2 struct { ChartType string `json:"chart_type"` ShowXLabel bool `json:"show_x_label"` ShowYLabel bool `json:"show_y_label"` SQL string `json:"sql"` XAXisColumn string `json:"x_axis_label"` YAXisColumn string `json:"y_axis_label"` }
func GetVisualisationParams ¶ added in v0.0.6
func GetVisualisationParams(dbOwner, dbFolder, dbName, visName string) (params VisParamsV2, ok bool, err error)
GetVisualisationParams returns a saved set of visualisation parameters
type WebInfo ¶
type WebInfo struct { BaseDir string `toml:"base_dir"` BindAddress string `toml:"bind_address"` Certificate string `toml:"certificate"` CertificateKey string `toml:"certificate_key"` RequestLog string `toml:"request_log"` ServerName string `toml:"server_name"` SessionStorePassword string `toml:"session_store_password"` }
WebInfo contains configuration info for the webUI daemon
type WebpageResponseContainer ¶ added in v0.0.12
type WebpageResponseContainer struct {
WebPage string `json:"web_page"`
}
WebpageResponseContainer holds the response to a client request for the database webUI URL. It's a temporary structure, mainly so the JSON created for it is consistent between our various daemons