Documentation ¶
Overview ¶
Package context contains the application context types.
This package only exists to avoid a circular import between app and cli packages, otherwise these types should be in the app package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { Ctx context.Context // global context FS vfs.FileSystem // filesystem DataDir string // app data storage directory Env Environment // process environment Logger *slog.Logger // global logger UUIDGen func() string // UUID generator // Standard streams Stdin io.Reader Stdout io.Writer Stderr io.Writer // Stores DB *db.DB Store store.Store User *models.User // current app user // Metadata Version *VersionInfo VersionInit string // app version the DB was initialized with }
Context contains common objects used by the application. It is passed around the application to avoid direct dependencies on external systems, and make testing easier.
func (*Context) LoadLocalUser ¶
LoadLocalUser loads the local user from the database into c.User, optionally validating the provided encryption key with the stored hash. Note that this *must* load a single user. Currently only a single local user is created, but in the future this might change.
func (*Context) ServerTLSInfo ¶
ServerTLSInfo returns the TLS certificate, private key and Subject Alternative Name used by the server.
type Environment ¶
Environment is the interface to the process environment.
type VersionInfo ¶
type VersionInfo struct { Commit string Semantic string TagDistance int // number of commits since latest tag Dirty bool // contains filtered or unexported fields }
VersionInfo stores app version information.
func GetVersion ¶
func GetVersion() (*VersionInfo, error)
GetVersion returns the app version including VCS and Go runtime information. It first reads the VCS version set at build time, and falls back to the VCS information provided by the Go runtime. The information in the Go runtime is not as extensive as the one extracted from Git, and we use the Go runtime information in case the binary is built without setting -ldflags (e.g. Homebrew), so we still need both. See https://github.com/golang/go/issues/50603
func (*VersionInfo) String ¶
func (vi *VersionInfo) String() string
String returns the full version information.
func (*VersionInfo) UnmarshalText ¶
func (vi *VersionInfo) UnmarshalText(data []byte) error
UnmarshalText parses the output of `git describe`.