helpers

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package helpers contains various helper functions for the commands.

Index

Constants

View Source
const ExpectedVersion = "4.5.0"

ExpectedVersion is the expected API version we'll use. This is for informational purposes only

Variables

This section is empty.

Functions

func APIError

func APIError(res *http.Response, e error) error

APIError creates an error instance based on error message and HTTP response returned from API call.

func AsMap added in v0.2.7

func AsMap(config []string) *map[string]string

AsMap converts a list of strings with name:value (with optional quotes) into a *map[string]string

func CheckVersion

func CheckVersion(ctx context.Context, client *spanapi.APIClient)

CheckVersion checks the server version of the Span API and emits a warning if there's a version mismatch.

func DateFormat

func DateFormat(dateStr string, numeric bool) string

DateFormat formats a date to RFC3339 if the date formatting flag is set

func DumpToTable

func DumpToTable(t table.Writer, s any) error

DumpToTable writes a struct to a table writer with one row for each field. Arrays are not (yet) handled.

func EllipsisString

func EllipsisString(s string, n int) string

EllipsisString returns a string no longer than n. If the string is truncated an ellipsis is added

func LocalTimeFormat

func LocalTimeFormat(ts string) string

LocalTimeFormat formats a timestamp string into local time

func NewSpanAPIClient

func NewSpanAPIClient() (*spanapi.APIClient, context.Context, context.CancelFunc)

NewSpanAPIClient creates a new SpanAPI client based on the command line options and/or defaults.

func NewTableOutput

func NewTableOutput(format commonopt.ListFormat) table.Writer

NewTableOutput creates a new table writer with the specified settings

func NewUserAPIClient

func NewUserAPIClient() *spanuserapi.APIClient

NewSpanAPIClient creates a new SpanAPI client based on the command line options and/or defaults.

func PayloadFormat

func PayloadFormat(pl string, decode bool) string

PayloadFormat formats the payload

func ReadCredentials

func ReadCredentials() string

ReadCredentials reads credentials from a local file. If no file is found the returned string is empty

func RemoveCredentials

func RemoveCredentials()

RemoveCredentials removes the local credentials file

func RenderTable

func RenderTable(t table.Writer, format string)

RenderTable renders the table according to settings

func TagsToString

func TagsToString(tags map[string]string) string

TagsToString converts a map of tags into a string with key:value fields

func WriteCredentials

func WriteCredentials(creds string) error

WriteCredentials writes (JWT) credentials to a local file

Types

This section is empty.

Jump to

Keyboard shortcuts

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