Documentation
¶
Overview ¶
Package letsgo uses several popular application libraries (Viper, Zap, Go-TUF) to provide an opinionated jumpstart wrapper library.
``` letsgo.QuickStart(
ApplicationName string, // Define ApplicationName, value is not used if a config directory is defined. Will set default config location to ~/.config/$ApplicationName opts *QuickStartOptions, // Additional optional settings; set to nil to accept all defaults
) ``` Initialize logger and configuration file with directory using sane defaults. **This is the only command required to use this library**. QuickStart() returns (\*zap.Logger, error) and sets up viper config.
Index ¶
- Variables
- func PackageDelivery(remoteRepo string, files []string, root []byte, opts *PackageDeliveryOptions) error
- func QuickSetup(applicationName string, opts *QuickStartOptions) (*zerolog.Logger, error)
- func RestartExecutable()
- func SwitchFile(oldFile, newFile string) error
- func VerifyPath(path string, mode os.FileMode) error
- type CloudflareZTOptions
- type PackageDeliveryOptions
- type QuickStartOptions
- type SmartSuffixOptions
Constants ¶
This section is empty.
Variables ¶
var KeyString string
Functions ¶
func PackageDelivery ¶ added in v0.3.0
func PackageDelivery(remoteRepo string, files []string, root []byte, opts *PackageDeliveryOptions) error
PackageDelivery
Easily Update your package binary to the latest version. Returned error should not fatal; error should be considered informational only per TUF specification. (https://theupdateframework.github.io/specification/latest/#detailed-client-workflow)
Uses TUF native golang library to download file.
Remote repository must be a valid TUF repository.
File will be downlaoded to $ViperConfigDirectory/updates
## Through Cloudflare ZTNA
Going through cloudflare ztna requires extra steps, namely, providing a valid JWT to authenticate. This can be aquired by calling `cloudflared access login {url}` using cloudflared (https://github.com/cloudflare/cloudflared)
letsgo supports its usage, but does not provide functionality for getting a valid JWT; it must be provided as function argument.
## Arguments
repo: string | Remote TUF repository url. (include prefix http|https, do not include ending /)
file: string | File to download
root: []byte | original tuf repo root.json ( tuf assumes that a good, trusted copy of this file was shipped with the package manager or software updater using an out-of-band process.)
opts: struct | see struct for details; nil is supported (uses option defaults)
func QuickSetup ¶
func QuickSetup(applicationName string, opts *QuickStartOptions) (*zerolog.Logger, error)
QuickSetup
The simpliest way to initialize config structure and logging or your money back guarantee.
applicationName (string): Define ApplicationName, value is not used if a config directory is defined. Will set default config location to /home/$USER$/.config/$ApplicationName
opts (QuickStartOptions): Can be set to nil to go with QuickSetup defaults.
returns (*zap.Logger):, use this in place of default logger
func RestartExecutable ¶ added in v0.3.0
func RestartExecutable()
RestartExecutable
Restarts the currently running excutable by spawning a seperate process that kills the current running program and spawns a new instance.
WIP
func SwitchFile ¶ added in v0.7.0
SwitchFile
oldFile (string): File that you wish to replace newFile (string): New file that will take the place of the old file
Types ¶
type CloudflareZTOptions ¶ added in v0.3.0
type CloudflareZTOptions struct {
JWT string // CloudflareZT requires a JSON Web Token to be passed to authenticate through ZTNA. This can be a static service-app JWT or the value generated by calling `cloudflared access login {url}`.
}
type PackageDeliveryOptions ¶ added in v0.3.0
type PackageDeliveryOptions struct { LocalRepo string // Set local tuf repository | Leave "" for default $viperConfigDir/updates ReplaceBinary string // Set whether to automatically replace the current running binary with a downloaded file. Set string to name of desired file. Empty string will not replace // FilesAreRegex bool // You can set your []files string to be regex rather than direct file names. This will allow many options such as searcing for a specific release (IE: file-windows64 ) SmartSuffixOptions *SmartSuffixOptions // Used to find correct file if different binaries are packaged per arch. CloudflareZTOptions *CloudflareZTOptions // There is extra backend work for authentication that must occur to host TUF Repo behind cloudflared zero trust | Default OFF }
type QuickStartOptions ¶ added in v0.3.0
type QuickStartOptions struct { LogLevelDefault int8 // Set zerolog default level [-1 to 6] -1 will disable logging EnableConfigEncryption bool // Determine whether to create secure folder. This creates a folder with 0700 (this mirrors ssh private key requirements) permissions that store an encryption key, you can than use this key to store encrypted information in the config file. This allows the config file to retain wider read permissions while still containing sensitive information. }
type SmartSuffixOptions ¶ added in v0.3.0
type SmartSuffixOptions struct { EnableSmartSuffix bool // Will look for file suffix to determine which file to download. IE: If you want to download file "file1" from linux-amd64, it will look to download "file_linux-amd64". | Default OFF NameSeperatorValue string // Value between filename and arch values. | Default "_": "file1_linux-amd64" ArchSeperatorValue string // Value between GOOS and GOARCH. | Default "-": "file1_linux-amd64" }