lib

package
v0.0.0-...-7ae9f15 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 32 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 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 GitCommit string = "Unknown"
View Source
var Version string = "Unknown"
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 EncryptAndMarshal

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

func GetBanner

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

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 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 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 SendDeletionRequest

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

func VerifyBinary

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

Types

type Seq2

type Seq2[K, V any] func(yield func(K, V) bool) bool

Represents an iterator of (K,V). Equivalent of the future Go stdlib type iter.Seq2. TODO: Swap this to the stdlib function once it has been released, along with the below two functions

func Values

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

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

Jump to

Keyboard shortcuts

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