cliutil

package
v0.0.0-...-953fec9 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2025 License: Apache-2.0, MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKeyToFile

func GenerateKeyToFile(fname string) error

GenerateKeyToFile makes the private key and store it into the file

func GetDidResolver

func GetDidResolver(cctx *cli.Context) did.Resolver

func GetPLCClient

func GetPLCClient(cctx *cli.Context) *api.PLCServer

func GetXrpcClient

func GetXrpcClient(cctx *cli.Context, authreq bool) (*xrpc.Client, error)

func LoadKeyFromFile

func LoadKeyFromFile(kfile string) (*did.PrivKey, error)

LoadKeyFromFile reads the private key from file

func NewHttpClient

func NewHttpClient() *http.Client

func ReadAuth

func ReadAuth(fname string) (*xrpc.AuthInfo, error)

func SetIpfsWriter

func SetIpfsWriter(out io.Writer, format string, level string)

func SetupDatabase

func SetupDatabase(dburl string, maxConnections int) (*gorm.DB, error)

Supports both previous "dbtype=" prefixed DSNs, and URI-style database config strings, for both sqlite and postgresql.

Examples: - "sqlite=dir/file.sqlite" - "sqlite://file.sqlite" - "postgres=host=localhost user=postgres password=password dbname=pdsdb port=5432 sslmode=disable" - "postgresql://postgres:password@localhost:5432/pdsdb?sslmode=disable"

func SetupSlog

func SetupSlog(options LogOptions) (*slog.Logger, error)

SetupSlog integrates passed in options and env vars.

passing default cliutil.LogOptions{} is ok.

BSKYLOG_LOG_LEVEL=info|debug|warn|error

BSKYLOG_LOG_FMT=text|json

BSKYLOG_FILE=path (or "-" or "" for stdout), %T gets UnixMilli; if a path with '/', {prefix}/current becomes a link to active log file

BSKYLOG_ROTATE_BYTES=int maximum size of log chunk before rotating

BSKYLOG_ROTATE_KEEP=int keep N olg logs (not including current)

The env vars were derived from ipfs logging library, and also respond to some GOLOG_ vars from that library, but BSKYLOG_ variables are preferred because imported code still using the ipfs log library may misbehave if some GOLOG values are set, especially GOLOG_FILE.

func TryReadConfig

func TryReadConfig()

func WriteConfig

func WriteConfig(cfg *CliConfig) error

Types

type CliConfig

type CliConfig struct {
	PDS string
	// contains filtered or unexported fields
}
var Config *CliConfig

type LogOptions

type LogOptions struct {
	// e.g. 1_000_000_000
	LogRotateBytes int64

	// path to write to, if rotating, %T gets UnixMilli at file open time
	// NOTE: substitution is simple replace("%T", "")
	LogPath string

	// text|json
	LogFormat string

	// info|debug|warn|error
	LogLevel string

	// Keep N old logs (not including current); <0 disables removal, 0==remove all old log files immediately
	KeepOld int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳