lib

package
v0.0.0-...-74056c7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultServerHostname = "https://api.hishtory.dev"
View Source
const NUM_IMPORTED_ENTRIES_SLOW int = 20_000

The number of entries where if we're importing more than this many entries, the import is likely to be slow, and it is then worth displaying a progress bar.

View Source
const SEARCH_RETRY_COUNT = 3
View Source
const SQLITE_LOCKED_ERR_MSG = "database is locked ("

Variables

View Source
var (
	Version   string = "Unknown"
	GitCommit string = "Unknown"
)
View Source
var BASH_FIRST_COMMAND_BUG_REGEX = regexp.MustCompile(`^#\d+\s+$`)
View Source
var ConfigFishContents string
View Source
var ConfigShContents string
View Source
var ConfigZshContents string
View Source
var ImportBatchSize = 100

The batch size for the DB operations for importing history. Used by all types of imports.

View Source
var ZSH_FIRST_COMMAND_BUG_REGEX = regexp.MustCompile(`: \d+:\d;(.*)`)

Functions

func AddToDbIfNew

func AddToDbIfNew(db *gorm.DB, entry data.HistoryEntry)

func ApiGet

func ApiGet(ctx context.Context, path string) ([]byte, error)

func ApiPost

func ApiPost(ctx context.Context, path, contentType string, reqBody []byte) ([]byte, error)

func BuildTableRow

func BuildTableRow(ctx context.Context, columnNames []string, entry data.HistoryEntry, commandRenderer func(string) string) ([]string, error)

func CanReachHishtoryServer

func CanReachHishtoryServer(ctx context.Context) bool

func CheckFatalError

func CheckFatalError(err error)

func CountStoredEntries

func CountStoredEntries(db *gorm.DB) (int64, error)

func EncryptAndMarshal

func EncryptAndMarshal(config *hctx.ClientConfig, entries []*data.HistoryEntry) ([]byte, error)

func GetBanner

func GetBanner(ctx context.Context) ([]byte, error)

func GetHttpClient

func GetHttpClient() *http.Client

func GetServerHostname

func GetServerHostname() string

func HandleDeletionRequests

func HandleDeletionRequests(ctx context.Context, deletionRequests []*shared.DeletionRequest) error

func HandleSlsaFailure

func HandleSlsaFailure(srcErr error) error

func ImportHistory

func ImportHistory(ctx context.Context, shouldReadStdin, force bool) (int, error)

func IsOfflineBinary

func IsOfflineBinary() bool

func IsOfflineError

func IsOfflineError(ctx context.Context, err error) bool

func MakeRegexFromQuery

func MakeRegexFromQuery(query string) string

Make a regex that matches the non-tokenized bits of the given query

func MakeWhereQueryFromSearch

func MakeWhereQueryFromSearch(ctx context.Context, db *gorm.DB, query string) (*gorm.DB, error)

func ProcessDeletionRequests

func ProcessDeletionRequests(ctx context.Context) error

func ReadStdin

func ReadStdin() ([]string, error)

func ReliableDbCreate

func ReliableDbCreate(db *gorm.DB, entry data.HistoryEntry) error

func RetrieveAdditionalEntriesFromRemote

func RetrieveAdditionalEntriesFromRemote(ctx context.Context, queryReason string) error

func RetryingDbFunction

func RetryingDbFunction(dbFunc func() error) error

func RetryingDbFunctionWithResult

func RetryingDbFunctionWithResult[T any](dbFunc func() (T, error)) (T, error)

func Reupload

func Reupload(ctx context.Context) error
func Search(ctx context.Context, db *gorm.DB, query string, limit int) ([]*data.HistoryEntry, error)

func SearchWithOffset

func SearchWithOffset(ctx context.Context, db *gorm.DB, query string, limit, offset int) ([]*data.HistoryEntry, error)

func SendDeletionRequest

func SendDeletionRequest(ctx context.Context, deletionRequest shared.DeletionRequest) error

func Values

func Values[Slice ~[]Elem, Elem any](s Slice) iter.Seq2[Elem, error]

Convert a slice into an iterator. TODO: Equivalent of the future Go stdlib function iter.Values

func VerifyBinary

func VerifyBinary(ctx context.Context, binaryPath, attestationPath, versionTag string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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