Documentation
¶
Overview ¶
Package helpers contains various helper functions for the commands.
Index ¶
- Constants
- func APIError(res *http.Response, e error) error
- func AsMap(config []string) *map[string]string
- func CheckVersion(ctx context.Context, client *spanapi.APIClient)
- func DateFormat(dateStr string, numeric bool) string
- func DumpToTable(t table.Writer, s any) error
- func EllipsisString(s string, n int) string
- func LocalTimeFormat(ts string) string
- func NewSpanAPIClient() (*spanapi.APIClient, context.Context, context.CancelFunc)
- func NewTableOutput(format commonopt.ListFormat) table.Writer
- func NewUserAPIClient() *spanuserapi.APIClient
- func PayloadFormat(pl string, decode bool) string
- func ReadCredentials() string
- func RemoveCredentials()
- func RenderTable(t table.Writer, format string)
- func TagsToString(tags map[string]string) string
- func WriteCredentials(creds string) error
Constants ¶
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 ¶
APIError creates an error instance based on error message and HTTP response returned from API call.
func AsMap ¶ added in v0.2.7
AsMap converts a list of strings with name:value (with optional quotes) into a *map[string]string
func CheckVersion ¶
CheckVersion checks the server version of the Span API and emits a warning if there's a version mismatch.
func DateFormat ¶
DateFormat formats a date to RFC3339 if the date formatting flag is set
func DumpToTable ¶
DumpToTable writes a struct to a table writer with one row for each field. Arrays are not (yet) handled.
func EllipsisString ¶
EllipsisString returns a string no longer than n. If the string is truncated an ellipsis is added
func LocalTimeFormat ¶
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 ¶
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 ¶
RenderTable renders the table according to settings
func TagsToString ¶
TagsToString converts a map of tags into a string with key:value fields
func WriteCredentials ¶
WriteCredentials writes (JWT) credentials to a local file
Types ¶
This section is empty.