common

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyColor         = "color"          // string
	KeyDebug         = "debug"          // bool
	KeyOutput        = "output"         // string
	KeyTty           = "tty-encode"     // string
	KeyServerAddress = "server-address" // string
	KeyTimeout       = "timeout"        // duration
	KeyRetries       = "retries"        // int
	KeyNamespace     = "namespace"      // string
	KeyLogLevel      = "loglevel"       // string
)

Variables

View Source
var (
	Debug         bool
	ServerAddress string
	Timeout       time.Duration
	Retries       int
)

Functions

func CliRun

func CliRun(fn func(ctx context.Context, cli tetragon.FineGuidanceSensorsClient))

func CliRunErr

func CliRunErr(fn func(ctx context.Context, cli tetragon.FineGuidanceSensorsClient), fnErr func(err error))

func HumanizeByteCount added in v1.2.1

func HumanizeByteCount(b int) string

HumanizeByteCount transforms bytes count into a quickly-readable version, for example it transforms 4458824 into "4.46 MB". I copied this code from https://yourbasic.org/golang/formatting-byte-size-to-human-readable-format/

func ResolveServerAddress added in v1.2.0

func ResolveServerAddress() string

ResolveServerAdress returns the server address given by the user from the command line flag, if not set, try to read from tetragon-info.json, and, if the file doesn't exist, returns the default value.

Types

type ClientWithContext added in v1.2.0

type ClientWithContext struct {
	Client tetragon.FineGuidanceSensorsClient
	// Ctx is a combination of the signal context and the timeout context
	Ctx context.Context
	// SignalCtx is only the signal context, you might want to use that context
	// when the command should never timeout (like a stream command)
	SignalCtx context.Context
	// contains filtered or unexported fields
}

func NewClient added in v1.2.0

func NewClient(ctx context.Context, address string, timeout time.Duration) (*ClientWithContext, error)

func NewClientWithDefaultContextAndAddress added in v1.2.0

func NewClientWithDefaultContextAndAddress() (*ClientWithContext, error)

NewClientWithDefaultContextAndAddress returns a client to a tetragon server after resolving the server address using helpers, accompanied with an initialized context that can be used for the RPC call, caller must call Close() on the client.

func (ClientWithContext) Close added in v1.2.0

func (c ClientWithContext) Close()

Close cleanup resources, it closes the connection and cancel the context

Jump to

Keyboard shortcuts

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