utils

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteShellCommand added in v1.7.0

func ExecuteShellCommand(command string) error

ExecuteShellCommand replaces the current process with a shell that runs the given command. This supports pipes, redirection, and all shell features.

func FollowRedirects added in v1.3.0

func FollowRedirects(url string) (string, error)

func FormatDuration

func FormatDuration(milliseconds int64) string

func ParseHTTPError

func ParseHTTPError(err error, htt *http.Response) error

func PrettyJSON

func PrettyJSON(j []byte) string

Prints JSON bytes nicely indented, or returns the original bytes as string if it fails

func ServiceFqnToStr added in v1.3.0

func ServiceFqnToStr(s ServiceFqn) string

func SortByVersion

func SortByVersion(unsorted []string) []string

SortByVersion sorts a slice of strings by semantic version number, highest first

func TransformValidationError added in v1.3.0

func TransformValidationError(inputJSON string) ([]string, error)

Types

type GeneralKeyMap added in v1.3.0

type GeneralKeyMap struct {
	help.KeyMap
	// For non-interactive mode
	Quit key.Binding
	// General navigation
	Back   key.Binding
	Retry  key.Binding
	Cancel key.Binding
	// Directions
	Up       key.Binding
	Down     key.Binding
	Left     key.Binding
	Right    key.Binding
	Next     key.Binding
	Previous key.Binding
	// Operations on items
	Delete  key.Binding
	New     key.Binding
	Confirm key.Binding
	Save    key.Binding
	// Misc
	Toggle    key.Binding
	Logs      key.Binding
	Details   key.Binding
	Configure key.Binding
}

This is a reusable key map that can be used for many different views (you can select which key.Binding to implement)

func NewGeneralKeyMap added in v1.3.0

func NewGeneralKeyMap() GeneralKeyMap

For at least implementing the quit key

func (GeneralKeyMap) FullHelp added in v1.3.0

func (k GeneralKeyMap) FullHelp() [][]key.Binding

FullHelp returns keybindings for the expanded help view. It's part of the key.Map interface.

func (GeneralKeyMap) ShortHelp added in v1.3.0

func (k GeneralKeyMap) ShortHelp() []key.Binding

ShortHelp returns keybindings to be shown in the mini help view. It's part of the key.Map interface.

type ServiceFqn

type ServiceFqn struct {
	Author  string
	Name    string
	Version string
}

type ServiceInformation added in v1.6.0

type ServiceInformation struct {
	Name    string `yaml:"name"`
	Version string `yaml:"version"`
}

Parsed from the service YAML files (simplified)

func GetServiceInformation added in v1.6.0

func GetServiceInformation(path string) (*ServiceInformation, error)

type UpdateAvailable added in v1.7.0

type UpdateAvailable struct {
	Name           string
	Available      bool
	CurrentVersion string
	LatestVersion  string
}

func CheckForGithubUpdate added in v1.7.0

func CheckForGithubUpdate(name string, org string, currentVersion string) (*UpdateAvailable, error)

CheckForGithubUpdate checks if an update is available for the given repository by checking releases on GitHub

type ValidationError added in v1.3.0

type ValidationError struct {
	ValidationErrors struct {
		UnmetStreams []struct {
			Source string `json:"source"`
			Target string `json:"target"`
			Stream string `json:"stream"`
		} `json:"unmet_streams"`
	} `json:"validation_errors"`
}

Define the structure of the JSON input

Jump to

Keyboard shortcuts

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