Documentation
¶
Overview ¶
These functions extract (and validate) user provided form data.
Index ¶
- Constants
- Variables
- func APIKeySave(key string, loggedInUser string, dateCreated time.Time) error
- func AddDatabase(r *http.Request, loggedInUser string, dbOwner string, dbFolder string, ...) (numBytes int64, newCommitID string, err error)
- func AddDefaultLicences() (err error)
- func AddDefaultUser() error
- func AddUser(auth0ID string, userName string, password string, email string, ...) error
- func AuthorizerSelect(d interface{}, action sqlite.Action, ...) sqlite.Auth
- func CacheData(cacheKey string, cacheData interface{}, cacheSeconds int) error
- func CheckDBExists(loggedInUser string, dbOwner string, dbFolder string, dbName string) (bool, error)
- func CheckDBID(loggedInUser string, dbOwner string, dbID int64) (avail bool, dbFolder string, dbName string, err error)
- func CheckDBStarred(loggedInUser string, dbOwner string, dbFolder string, dbName string) (bool, error)
- func CheckDBWatched(loggedInUser string, dbOwner string, dbFolder string, dbName string) (bool, error)
- func CheckEmailExists(email string) (bool, error)
- func CheckLicenceExists(userName string, licenceName string) (exists bool, err error)
- func CheckUnicode(rawInput string) (str string, err error)
- func CheckUserExists(userName string) (bool, error)
- func ClientCert(userName string) ([]byte, error)
- func CommitLicenceSHA(dbOwner string, dbFolder string, dbName string, commitID string) (licenceSHA string, err error)
- func ConnectCache() error
- func ConnectMinio() (err error)
- func ConnectPostgreSQL() (err error)
- func CreateCommitID(c CommitEntry) string
- func CreateDBTreeID(entries []DBTreeEntry) string
- func DBDetails(DB *SQLiteDBinfo, loggedInUser string, dbOwner string, dbFolder string, ...) error
- func DBStars(dbOwner string, dbFolder string, dbName string) (starCount int, err error)
- func DBWatchers(dbOwner string, dbFolder string, dbName string) (watcherCount int, err error)
- func DefaultCommit(dbOwner string, dbFolder string, dbName string) (string, error)
- func DeleteBranchHistory(dbOwner string, dbFolder string, dbName string, branchName string, ...) (isolatedTags []string, isolatedRels []string, err error)
- func DeleteComment(dbOwner string, dbFolder string, dbName string, discID int, comID int) error
- func DeleteDatabase(dbOwner string, dbFolder string, dbName string) error
- func DeleteLicence(userName string, licenceName string) (err error)
- func DisconnectPostgreSQL()
- 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 string, dbFolder string, dbName string, dstOwner string) (newForkCount int, err error)
- func ForkParent(loggedInUser string, dbOwner string, dbFolder string, dbName string) (parentOwner string, parentFolder string, parentDBName string, err error)
- func ForkedFrom(dbOwner string, dbFolder string, dbName string) (forkOwn string, forkFol string, forkDB string, forkDel bool, err error)
- func GenerateClientCert(userName string) (_ []byte, err error)
- func GetAPIKeyUser(key string) (user string, err error)
- func GetBranches(dbOwner string, dbFolder string, dbName string) (branches map[string]BranchEntry, err error)
- func GetCachedData(cacheKey string, cacheData interface{}) (bool, error)
- func GetCommitList(dbOwner string, dbFolder string, dbName string) (map[string]CommitEntry, error)
- func GetCurrentFunctionName() (FuncName string)
- func GetDatabase(r *http.Request, allowGet bool) (string, error)
- func GetDefaultBranchName(dbOwner string, dbFolder string, dbName string) (branchName string, err error)
- func GetDefaultTableName(dbOwner string, dbFolder string, dbName string) (tableName string, err error)
- func GetDiscussionAndMRCount(dbOwner string, dbFolder string, dbName string) (discCount int, mrCount int, err error)
- func GetFolder(r *http.Request, allowGet bool) (string, error)
- func GetFormBranch(r *http.Request) (string, error)
- func GetFormCommit(r *http.Request) (string, error)
- func GetFormLicence(r *http.Request) (licenceName string, err error)
- func GetFormODC(r *http.Request) (string, string, string, error)
- func GetFormOwner(r *http.Request, allowGet bool) (string, 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) (string, error)
- func GetFormTag(r *http.Request) (tag string, err error)
- func GetFormUDC(r *http.Request) (string, string, string, error)
- func GetLicence(userName string, licenceName string) (txt string, format string, err error)
- func GetLicenceInfoFromSha256(userName string, sha256 string) (lName string, lURL string, err error)
- func GetLicenceSha256FromName(userName string, licenceName string) (sha256 string, err error)
- func GetLicences(user string) (map[string]LicenceEntry, error)
- func GetOD(ignoreLeading int, r *http.Request) (string, string, error)
- func GetODC(ignoreLeading int, r *http.Request) (string, string, string, error)
- func GetODT(ignoreLeading int, r *http.Request) (string, string, string, error)
- func GetODTC(ignoreLeading int, r *http.Request) (string, string, string, string, error)
- func GetPrimaryKeyAndOtherColumns(sdb *sqlite.Conn, schema string, table string) (pks []string, implicitPk bool, other []string, err error)
- func GetPub(r *http.Request) (bool, error)
- func GetReleases(dbOwner string, dbFolder string, dbName string) (releases map[string]ReleaseEntry, err error)
- func GetSQLiteRowCount(sdb *sqlite.Conn, dbTable string) (int, error)
- func GetTable(r *http.Request) (string, error)
- func GetTags(dbOwner string, dbFolder string, dbName string) (tags map[string]TagEntry, err error)
- func GetUFD(r *http.Request, allowGet bool) (string, string, string, error)
- func GetUsername(r *http.Request, allowGet bool) (string, error)
- func GetUsernameFromEmail(email string) (userName string, 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 string, dbFolder string, 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 string, dbFolder string, dbName string, branchName string, ...) (bool, error)
- func LogDB4SConnect(userAcc string, ipAddr string, userAgent string, downloadDate time.Time) error
- func LogDownload(dbOwner string, dbFolder string, dbName string, loggedInUser string, ...) error
- func LogSQLiteQueryAfter(insertID, memUsed, memHighWater int64) (err error)
- func LogSQLiteQueryBefore(...) (int64, error)
- func LogUpload(dbOwner string, dbFolder string, dbName string, loggedInUser string, ...) error
- func MemcacheHandle() *memcache.Client
- func MetadataCacheKey(prefix string, loggedInUser string, dbOwner string, dbFolder string, ...) string
- func MinioHandle(bucket string, id string) (*minio.Object, error)
- func MinioHandleClose(userDB *minio.Object) (err error)
- func MinioLocation(dbOwner string, dbFolder string, dbName string, commitID string, ...) (minioBucket string, minioID string, lastModified time.Time, err error)
- func NewEvent(details EventDetails) (err error)
- func OpenSQLiteDatabase(bucket, id string) (*sqlite.Conn, error)
- func OpenSQLiteDatabaseDefensive(w http.ResponseWriter, r *http.Request, ...) (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 string, dbFolder string, dbName string, newName string) error
- func ReservedUsernamesCheck(userName string) error
- func RetrieveDatabaseFile(bucket string, id string) (newDB string, err error)
- func SQLiteVersionNumber() int32
- func SanityCheck(fileName string) (tables []string, err error)
- func SaveDBSettings(userName string, dbFolder string, dbName string, oneLineDesc string, ...) error
- func SendEmails()
- func SetClientCert(newCert []byte, userName string) error
- func SetUserPreferences(userName string, maxRows int, displayName string, email string) error
- func SetUserStatusUpdates(userName string, numUpdates int) error
- func SocialStats(dbOwner string, dbFolder string, dbName string) (wa int, st int, fo int, err error)
- func StatusUpdateCheck(dbOwner string, dbFolder string, 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 string, dbFolder string, dbName string, ...) error
- func StoreComment(dbOwner string, dbFolder string, dbName string, commenter string, discID int, ...) error
- func StoreCommits(dbOwner string, dbFolder string, dbName string, ...) error
- func StoreDatabase(dbOwner string, dbFolder string, dbName string, ...) error
- func StoreDatabaseFile(db *os.File, sha string, dbSize int64) error
- func StoreDefaultBranchName(dbOwner string, folder string, dbName string, branchName string) error
- func StoreDefaultTableName(dbOwner string, folder string, dbName string, tableName string) error
- func StoreDiscussion(dbOwner string, dbFolder string, dbName string, loggedInUser string, ...) (newID int, err error)
- func StoreLicence(userName string, licenceName string, txt []byte, url string, orderNum int, ...) error
- func StoreReleases(dbOwner string, dbFolder string, dbName string, ...) error
- func StoreStatusUpdates(userName string, statusUpdates map[string][]StatusUpdateEntry) error
- func StoreTags(dbOwner string, dbFolder string, dbName string, tags map[string]TagEntry) error
- 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 ToggleDBStar(loggedInUser string, dbOwner string, dbFolder string, dbName string) error
- func ToggleDBWatch(loggedInUser string, dbOwner string, dbFolder string, dbName string) error
- func UpdateAvatarURL(userName string, avatarURL string) error
- func UpdateComment(dbOwner string, dbFolder string, dbName string, loggedInUser string, ...) error
- func UpdateContributorsCount(dbOwner string, dbFolder, dbName string) error
- func UpdateDiscussion(dbOwner string, dbFolder string, dbName string, loggedInUser string, ...) error
- func UpdateMergeRequestCommits(dbOwner string, dbFolder string, dbName string, discID 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 string, db string) error
- func ValidateUserDBTable(user string, db string, table string) error
- func ValidateUserEmail(user string, email string) error
- func ViewCount(dbOwner string, dbFolder string, dbName string) (viewCount int, err error)
- func Views(sdb *sqlite.Conn) (vw []string, err error)
- func VisualisationDeleteParams(dbOwner string, dbFolder string, dbName string, visName string) (err error)
- func VisualisationSaveData(dbOwner string, dbFolder string, dbName string, commitID string, hash string, ...) (err error)
- func VisualisationSaveParams(dbOwner string, dbFolder string, dbName string, visName string, ...) (err error)
- type APIJSONColumn
- type APIKey
- type AccessType
- type ActivityRange
- type ActivityRow
- type ActivityStats
- type ApiInfo
- type Auth0Info
- type Auth0Set
- type BranchEntry
- type CommitData
- type CommitEntry
- type DB4SInfo
- type DBEntry
- func UserStarredDBs(userName string) (list []DBEntry, err error)
- func UserWatchingDBs(userName string) (list []DBEntry, err error)
- func UsersStarredDB(dbOwner string, dbFolder string, dbName string) (list []DBEntry, err error)
- func UsersWatchingDB(dbOwner string, dbFolder string, dbName string) (list []DBEntry, err error)
- 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 MemcacheInfo
- type MergeRequestEntry
- type MergeRequestState
- type MergeStrategy
- type MetaInfo
- type MinioInfo
- type PGInfo
- type QuerySource
- type RedashColumnMeta
- type RedashTableData
- type ReleaseEntry
- type SQLiteDBinfo
- type SQLiteRecordSet
- 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)
- type SchemaDiff
- type SigningInfo
- type StatusUpdateEntry
- type TagEntry
- type TomlConfig
- type UploadRow
- type UserDetails
- type UserInfo
- type UserInfoSlice
- type ValType
- type VisGetFields
- type VisParamsV2
- type VisRowV1
- type WebInfo
- 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
Number of rows to display by default on the database page
const MaxDatabaseSize = 512
The maximum database size accepted for upload (in MB)
const MaxLicenceSize = 1
The maximum licence size accepted for upload (in MB)
const MinioFolderChars = 6
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 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,
}
var ( // For input validation Validate *valid.Validate )
Functions ¶
func APIKeySave ¶ added in v0.0.6
Saves a new API key to the PostgreSQL database.
func AddDatabase ¶
func AddDatabase(r *http.Request, loggedInUser string, dbOwner string, dbFolder string, dbName string, createBranch bool, branchName string, commitID string, public bool, licenceName string, commitMsg string, sourceURL string, newDB io.Reader, serverSw string, lastModified time.Time, commitTime time.Time, authorName string, authorEmail string, committerName string, committerEmail string, otherParents []string, dbSha string) (numBytes int64, newCommitID string, err error)
The main function which handles database upload processing for both the webUI and DB4S end points
func AddDefaultUser ¶
func AddDefaultUser() error
Add the default user to the system, used so the referential integrity of licence user_id 0 works.
func AddUser ¶
func AddUser(auth0ID string, userName string, password string, email string, displayName string, avatarURL string) error
Add a user to the system.
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 CheckDBExists ¶
func CheckDBExists(loggedInUser string, dbOwner string, dbFolder string, dbName string) (bool, error)
Check if a database exists If an error occurred, the true/false value should be ignored, as only the error value is valid.
func CheckDBID ¶
func CheckDBID(loggedInUser string, dbOwner string, dbID int64) (avail bool, dbFolder string, dbName string, err error)
Check if a given database ID is available, and return 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 CheckDBStarred ¶
func CheckDBStarred(loggedInUser string, dbOwner string, dbFolder string, dbName string) (bool, error)
Check if a database has been starred by a given user. The boolean return value is only valid when err is nil.
func CheckDBWatched ¶
func CheckDBWatched(loggedInUser string, dbOwner string, dbFolder string, dbName string) (bool, error)
Check if a database is being watched by a given user. The boolean return value is only valid when err is nil.
func CheckEmailExists ¶
Check 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
Checks if a licence exists in our system.
func CheckUnicode ¶ added in v0.0.6
Checks if a given string is unicode, and safe for using in SQLite queries (eg no SQLite control characters)
func CheckUserExists ¶
Check 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 ClientCert ¶
Returns the certificate for a given user.
func CommitLicenceSHA ¶
func CommitLicenceSHA(dbOwner string, dbFolder string, dbName string, commitID string) (licenceSHA string, err error)
Returns the licence used by the database in a given commit
func ConnectCache ¶
func ConnectCache() error
func ConnectMinio ¶
func ConnectMinio() (err error)
Parse 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)
Creates a connection pool to the PostgreSQL server.
func CreateCommitID ¶
func CreateCommitID(c CommitEntry) string
Generate a stable SHA256 for a commit.
func CreateDBTreeID ¶
func CreateDBTreeID(entries []DBTreeEntry) string
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 DBDetails ¶
func DBDetails(DB *SQLiteDBinfo, loggedInUser string, dbOwner string, dbFolder string, dbName string, commitID string) error
Retrieve the details for a specific database
func DBWatchers ¶
Returns the watchers count for a given database.
func DefaultCommit ¶
Retrieve the default commit ID for a specific database
func DeleteBranchHistory ¶
func DeleteBranchHistory(dbOwner string, dbFolder string, dbName string, branchName string, commitID string) (isolatedTags []string, isolatedRels []string, err error)
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 ¶
Delete a specific comment from a discussion
func DeleteDatabase ¶
Deletes a database from PostgreSQL.
func DeleteLicence ¶ added in v0.0.5
Removes a (user supplied) database licence from the system.
func DisconnectPostgreSQL ¶
func DisconnectPostgreSQL()
Disconnects the PostgreSQL database connection.
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()
Periodically flushes the database view count from memcache to PostgreSQL
func ForkDatabase ¶
func ForkDatabase(srcOwner string, dbFolder string, dbName string, dstOwner string) (newForkCount int, err error)
Fork the PostgreSQL entry for a SQLite database from one user to another
func ForkParent ¶
func ForkParent(loggedInUser string, dbOwner string, dbFolder string, dbName string) (parentOwner string, parentFolder string, parentDBName string, err error)
Return 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 string, dbFolder string, dbName string) (forkOwn string, forkFol string, forkDB string, forkDel bool, err error)
Checks if the given database was forked from another, and if so returns that one's owner, folder and database name
func GenerateClientCert ¶
func GetAPIKeyUser ¶ added in v0.0.6
Returns the owner of a given API key. Returns an empty string if the key has no known owner.
func GetBranches ¶
func GetBranches(dbOwner string, dbFolder string, dbName string) (branches map[string]BranchEntry, err error)
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 ¶
Retrieves cached data from Memcached
func GetCommitList ¶
Retrieves the full commit list for a database.
func GetCurrentFunctionName ¶
func GetCurrentFunctionName() (FuncName string)
Returns the name of the function this was called from
func GetDatabase ¶
Extracts a database name from GET or POST/PUT data.
func GetDefaultBranchName ¶
func GetDefaultBranchName(dbOwner string, dbFolder string, dbName string) (branchName string, err error)
Returns the default branch name for a database.
func GetDefaultTableName ¶
func GetDefaultTableName(dbOwner string, dbFolder string, dbName string) (tableName string, err error)
Returns the default table name for a database.
func GetDiscussionAndMRCount ¶
func GetDiscussionAndMRCount(dbOwner string, dbFolder string, dbName string) (discCount int, mrCount int, err error)
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 ¶
Return the requested branch name, from get or post data.
func GetFormCommit ¶
Return the requested database commit, from form data.
func GetFormLicence ¶
Returns the licence name (if any) present in the form data
func GetFormODC ¶ added in v0.0.6
Return the database owner, database name, and commit (if any) present in the form data.
func GetFormOwner ¶ added in v0.0.6
Return the database owner present in the GET or POST/PUT data.
func GetFormRelease ¶
Return the requested release name, from get or post data.
func GetFormSourceURL ¶
Returns the source URL (if any) present in the form data
func GetFormTable ¶ added in v0.0.6
Return the table name present in the GET or POST/PUT data.
func GetFormTag ¶
Return the requested tag name, from get or post data.
func GetFormUDC ¶
Return the username, database, and commit (if any) present in the form data.
func GetLicence ¶
Returns the text for a given licence.
func GetLicenceInfoFromSha256 ¶
func GetLicenceInfoFromSha256(userName string, sha256 string) (lName string, lURL string, err error)
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 ¶
Returns the sha256 for a given licence.
func GetLicences ¶
func GetLicences(user string) (map[string]LicenceEntry, error)
Returns the list of licences available to a user.
func GetPrimaryKeyAndOtherColumns ¶ added in v0.0.7
func GetPrimaryKeyAndOtherColumns(sdb *sqlite.Conn, schema string, table string) (pks []string, implicitPk bool, other []string, err error)
Figure 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 ¶
Returns the requested "public" variable, if present in the form data. If something goes wrong, it defaults to "false".
func GetReleases ¶
func GetReleases(dbOwner string, dbFolder string, dbName string) (releases map[string]ReleaseEntry, err error)
Retrieve the list of releases for a database.
func GetSQLiteRowCount ¶
GetSQLiteRowCount returns the number of rows in a SQLite table.
func GetUsername ¶
Return the username (if any) present in the GET or POST/PUT data.
func GetUsernameFromEmail ¶
Returns the username associated with an email address.
func GetViewCount ¶
Retrieves the view count in memcached for a database
func GetVisualisations ¶ added in v0.0.6
Returns the list of saved visualisations for a given database
func IncrementDownloadCount ¶
Increments the download count for a database
func 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
Invalidate memcache data for a database entry or entries
func IsCommitInBranchHistory ¶
func IsCommitInBranchHistory(dbOwner string, dbFolder string, dbName string, branchName string, commitID string) (bool, error)
Checks if a given commit ID is in the history of the given branch
func LogDB4SConnect ¶ added in v0.0.6
Create a DB4S default browse list entry
func LogDownload ¶
func LogDownload(dbOwner string, dbFolder string, dbName string, loggedInUser string, ipAddr string, serverSw string, userAgent string, downloadDate time.Time, sha string) error
Create a download log entry
func LogSQLiteQueryAfter ¶ added in v0.0.6
Add 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)
Log the basic info for a user supplied SQLite query
func LogUpload ¶
func LogUpload(dbOwner string, dbFolder string, dbName string, loggedInUser string, ipAddr string, serverSw string, userAgent string, uploadDate time.Time, sha string) error
Create an upload log entry
func MetadataCacheKey ¶
func MetadataCacheKey(prefix string, loggedInUser string, dbOwner string, dbFolder string, dbName string, commitID string) string
Generate a predictable cache key for metadata information
func MinioHandle ¶
Get a handle from Minio for a SQLite database object.
func MinioHandleClose ¶
func MinioHandleClose(userDB *minio.Object) (err error)
Close a Minio object handle. Probably most useful for calling with defer().
func MinioLocation ¶
func MinioLocation(dbOwner string, dbFolder string, dbName string, commitID string, loggedInUser string) (minioBucket string, minioID string, lastModified time.Time, err error)
Return 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 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 PrefUserMaxRows ¶
Return the user's preference for maximum number of SQLite rows to display.
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 ¶
Rename a SQLite database.
func ReservedUsernamesCheck ¶
Checks a username against the list of reserved ones.
func RetrieveDatabaseFile ¶ added in v0.0.6
Retrieves a SQLite database file from Minio. If there's a locally cached version already available though, use that
func SQLiteVersionNumber ¶ added in v0.0.6
func SQLiteVersionNumber() int32
SQLiteVersionNumber returns the version number of the available SQLite library, in 300X00Y format.
func SanityCheck ¶
SanityCheck performs basic sanity checks of an uploaded database.
func SaveDBSettings ¶
func SaveDBSettings(userName string, dbFolder string, dbName string, oneLineDesc string, fullDesc string, defaultTable string, public bool, sourceURL string, defaultBranch string) error
Saves updated database settings to PostgreSQL.
func SetClientCert ¶
Stores a certificate for a given client.
func SetUserPreferences ¶
Sets the user's preference for maximum number of SQLite rows to display.
func SetUserStatusUpdates ¶
Increments the view counter in memcached for a database
func SocialStats ¶
func SocialStats(dbOwner string, dbFolder string, dbName string) (wa int, st int, fo int, err error)
Retrieve the latest social stats for a given database.
func StatusUpdateCheck ¶
func StatusUpdateCheck(dbOwner string, dbFolder string, dbName string, thisID int, userName string) (numStatusUpdates int, err error)
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)
Retrieve the list of outstanding status updates for a user
func StatusUpdatesLoop ¶
func StatusUpdatesLoop()
Periodically generates status updates (alert emails TBD) from the event queue
func StoreBranches ¶
func StoreBranches(dbOwner string, dbFolder string, dbName string, branches map[string]BranchEntry) error
Updates the branches list for a database.
func StoreComment ¶
func StoreComment(dbOwner string, dbFolder string, dbName string, commenter string, discID int, comText string, discClose bool, mrState MergeRequestState) error
Adds a comment to a discussion.
func StoreCommits ¶
func StoreCommits(dbOwner string, dbFolder string, dbName string, commitList map[string]CommitEntry) error
Updates the commit list for a database.
func StoreDatabase ¶
func StoreDatabase(dbOwner string, dbFolder string, dbName string, branches map[string]BranchEntry, c CommitEntry, pub bool, buf *os.File, sha string, dbSize int64, oneLineDesc string, fullDesc string, createDefBranch bool, branchName string, sourceURL string) error
Stores database details in PostgreSQL, and the database data itself in Minio.
func StoreDatabaseFile ¶
Store a database file in Minio.
func StoreDefaultBranchName ¶
Stores the default branch name for a database.
func StoreDefaultTableName ¶
Stores the default table name for a database.
func StoreDiscussion ¶
func StoreDiscussion(dbOwner string, dbFolder string, dbName string, loggedInUser string, title string, text string, discType DiscussionType, mr MergeRequestEntry) (newID int, err error)
Stores a new discussion for a database.
func StoreLicence ¶
func StoreLicence(userName string, licenceName string, txt []byte, url string, orderNum int, fullName string, fileFormat string) error
Store a licence.
func StoreReleases ¶
func StoreReleases(dbOwner string, dbFolder string, dbName string, releases map[string]ReleaseEntry) error
Store the releases for a database.
func StoreStatusUpdates ¶
func StoreStatusUpdates(userName string, statusUpdates map[string][]StatusUpdateEntry) error
Store the status updates list for a user
func TableRowsCacheKey ¶
func TableRowsCacheKey(prefix string, loggedInUser string, dbOwner string, dbFolder string, dbName string, commitID string, dbTable string, rows int) string
Generate 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 ToggleDBStar ¶
Toggle on or off the starring of a database by a user.
func ToggleDBWatch ¶
Toggle on or off the watching of a database by a user.
func UpdateAvatarURL ¶
Updates the Avatar URL for a user.
func UpdateComment ¶
func UpdateComment(dbOwner string, dbFolder string, dbName string, loggedInUser string, discID int, comID int, newText string) error
Updates the text for a comment
func UpdateContributorsCount ¶
Updates the contributors count for a database.
func UpdateDiscussion ¶
func UpdateDiscussion(dbOwner string, dbFolder string, dbName string, loggedInUser string, discID int, newTitle string, newText string) error
Updates the text for a discussion
func UpdateMergeRequestCommits ¶
func UpdateMergeRequestCommits(dbOwner string, dbFolder string, dbName string, discID int, mrCommits []CommitEntry) (err error)
Updates the commit list for a Merge Request
func UserNameFromAuth0ID ¶
Returns the username for a given Auth0 ID.
func UserStatusUpdates ¶
Returns the number of status updates outstanding for a user
func ValidateBranchName ¶
Validate the provided branch, release, or tag name.
func ValidateCommitID ¶ added in v0.0.5
Validate the provided commit ID.
func ValidateDiscussionTitle ¶
Validate the provided discussion or merge request title.
func ValidateDisplayName ¶ added in v0.0.5
Validate a provided full name.
func ValidateFieldName ¶
Validate the SQLite field name.
func ValidateLicence ¶
Validate the provided licence name (ID).
func ValidateLicenceFullName ¶ added in v0.0.5
Validate the provided licence full name.
func ValidateMarkdown ¶
Validate the provided markdown.
func ValidatePGTable ¶
Validate the provided PostgreSQL table name.
func ValidateUserDB ¶
Validate the provided user and database name.
func ValidateUserDBTable ¶
Validate the provided user, database, and table name.
func ValidateUserEmail ¶
Validate the provided username and email address.
func VisualisationDeleteParams ¶ added in v0.0.6
func VisualisationDeleteParams(dbOwner string, dbFolder string, dbName string, visName string) (err error)
Deletes a set of visualisation parameters
func VisualisationSaveData ¶ added in v0.0.6
func VisualisationSaveData(dbOwner string, dbFolder string, dbName string, commitID string, hash string, visData []VisRowV1) (err error)
Saves visualisation result data for later retrieval
func VisualisationSaveParams ¶ added in v0.0.6
func VisualisationSaveParams(dbOwner string, dbFolder string, dbName string, visName string, visParams VisParamsV2) (err error)
Saves a set of visualisation parameters for later retrieval
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"` Autoinc bool `json:"autoinc"` CollSeq string `json:"collation_seq"` }
APIJSONColumn is a copy of the Column type from github.com/gwenn/gosqlite, but including JSON field name info
type APIKey ¶ added in v0.0.6
func GetAPIKeys ¶ added in v0.0.6
Returns the list of API keys for a user.
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)
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"` }
Config info for the API server
type BranchEntry ¶
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"` 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 string, srcFolder string, srcDBName string, srcBranch string, destOwner string, destFolder string, destName string, destBranch string) (ancestorID string, commitList []CommitEntry, err error, errType int)
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 }
Configuration info for the DB4S end point
type DBEntry ¶
type DBEntry struct { Folder string DateEntry time.Time DBName string Owner string OwnerDisplayName string `json:"display_name"` }
func UserStarredDBs ¶
Returns the list of databases starred by a user.
func UserWatchingDBs ¶
Returns the list of databases watched by a user.
func UsersStarredDB ¶
Returns the list of users who starred 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 }
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"` Pk []DataValue `json:"pk"` }
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"` Data []DataDiff `json:"data"` }
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) (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 string, dbFolder string, dbName string, discID int, comID int) (list []DiscussionCommentEntry, err error)
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 string, dbFolder string, dbName string, discType DiscussionType, discID int) (list []DiscussionEntry, err error)
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 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"` EmailQueueDir string `toml:"email_queue_dir"` EmailQueueProcessingDelay time.Duration `toml:"email_queue_processing_delay"` }
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 LicenceEntry ¶
type LicenceInfo ¶ added in v0.0.5
type LicenceInfo struct {
LicenceDir string `toml:"licence_dir"`
}
Path to the licence files
type MemcacheInfo ¶
type MemcacheInfo struct { DefaultCacheTime int `toml:"default_cache_time"` Server string `toml:"server"` ViewCountFlushDelay time.Duration `toml:"view_count_flush_delay"` }
Memcached connection 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 MinioInfo ¶
type MinioInfo struct { AccessKey string `toml:"access_key"` HTTPS bool Secret string Server string }
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 }
PostgreSQL connection parameters
type QuerySource ¶ added in v0.0.6
type QuerySource int
const ( WebUI QuerySource = iota DB4S Visualisation API Internal )
type RedashColumnMeta ¶ added in v0.0.5
type RedashColumnMeta struct { Name string `json:"name"` Type string `json:"type"` FriendlyName string `json:"friendly_name"` }
When SQLite data is prepared for sending to Redash (as JSON), the RedashColumnMeta and RedashTableData structures are used to hold it
type RedashTableData ¶ added in v0.0.5
type RedashTableData struct { Columns []RedashColumnMeta `json:"columns"` Rows []map[string]interface{} `json:"rows"` }
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 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.
type SchemaDiff ¶ added in v0.0.6
SchemaDiff describes the changes to the schema of a database object, i.e. a created, dropped or altered object
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"` }
Used for signing DB4S client certificates
type StatusUpdateEntry ¶
type TomlConfig ¶
type TomlConfig struct { Api ApiInfo Auth0 Auth0Info DB4S DB4SInfo Environment EnvInfo DiskCache DiskCacheInfo Event EventProcessingInfo Licence LicenceInfo Memcache MemcacheInfo Minio MinioInfo Pg PGInfo Sign SigningInfo Web WebInfo }
Configuration file
var ( // Our configuration info Conf TomlConfig )
type UserDetails ¶
type UserInfoSlice ¶ added in v0.0.6
type UserInfoSlice []UserInfo
For sorting a UserInfo list by Last Modified date descending
func DB4SDefaultList ¶
func DB4SDefaultList(loggedInUser string) (UserInfoSlice, error)
Return 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 VisGetFields ¶ added in v0.0.6
type VisGetFields struct {
VisName string `validate:"required,visname,min=1,max=63"` // 63 char limit seems reasonable
}
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 string, dbFolder string, dbName string, visName string) (params VisParamsV2, ok bool, err error)
Retrieves 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"` }