helper

package
v0.0.0-...-5fe617f Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FORCE_SELF_UPDATE     = "force_self_update"
	NO_MERGE_STATUS_CHECK = "no_merge_status_check"
	SHOW_CMD_EXEC_STDOUT  = "show_cmd_exec_stdout"
	USE_FILE_VAULT        = "use_file_vault"
)

Variables

This section is empty.

Functions

func BodyAsString

func BodyAsString(resp *http.Response) (string, error)

func CallExternalNoStdOut

func CallExternalNoStdOut(additionalEnv []string, cwd string, executable string, args ...string) (int, error)

Call external command without output to standard out/err

func CallExternalStdOut

func CallExternalStdOut(additionalEnv []string, cwd string, executable string, args ...string) (int, error)

Call external command and output to standard out/err

func CallExternalWithOutput

func CallExternalWithOutput(additionalEnv []string, cwd string, executable string, args ...string) (int, string, error)

Call external command and return the output string

func ContextualHelpError

func ContextualHelpError(err error, suggestions ...string) error

A contextual help error not only provides the error message, but also a suggestion for user to correct them in the next command

for example, when command fails to find necessary files in the workspace, an actionable error will be helpful to remind the user double check the workspace, or specify a different one with dedicated flag

func CopyLocalFile

func CopyLocalFile(src string, dest string, showProgress bool) error

func DownloadFile

func DownloadFile(fileUrlOrPath string, dest string, showProgress bool) error

Download file from http(s) or local disk Use http:// https:// as prefix for remote file Use file:// or no prefix for local file

func DownloadFileFromUrl

func DownloadFileFromUrl(url string, dest string, showProgress bool) error

func GetAuthToken

func GetAuthToken() (string, error)

func GetPassword

func GetPassword() (string, error)

func GetSecret

func GetSecret(key string) (string, error)

func GetUsername

func GetUsername() (string, error)

func HasDebugFlag

func HasDebugFlag(name string) bool

check if a debug flag exists

func Hash

func Hash(s string) uint32

func HttpDoWithBasicAuth

func HttpDoWithBasicAuth(method, url, user, password string, input io.Reader) (int, []byte, error)

func HttpEtag

func HttpEtag(url string) (int, string, error)

func HttpGet

func HttpGet(url string) (int, []byte, error)

func HttpGetWithBasicAuth

func HttpGetWithBasicAuth(url, user, password string) (int, []byte, error)

func HttpGetWrapper

func HttpGetWrapper(url string) (*http.Response, error)

func HttpNewRequestWrapper

func HttpNewRequestWrapper(method, url string, body io.Reader) (*http.Request, error)

func HttpPostInputWithBasicAuth

func HttpPostInputWithBasicAuth(url, user, password string, input io.Reader) (int, []byte, error)

func HttpPostWithBasicAuth

func HttpPostWithBasicAuth(url, user, password string) (int, []byte, error)

func Is2xx

func Is2xx(statusCode int) bool

func IsAbsolutePath

func IsAbsolutePath(pathname string) bool

Check if the path is an absolute path

The standard go function does not support Windows :(

func LoadFile

func LoadFile(fileUrlOrPath string) ([]byte, error)

Load file from http(s) or local disk Use http:// https:// as prefix for remote file Use file:// or no prefix for local file

func LoadFileFromUrl

func LoadFileFromUrl(url string) ([]byte, error)

Load a file from a http(s) url

func ReadPassword

func ReadPassword() ([]byte, error)

func ResolveUrl

func ResolveUrl(url string) (string, bool)

func SetPassword

func SetPassword(value string) error

func SetSecret

func SetSecret(key string, value string) error

func SetUsername

func SetUsername(value string) error

func TestCommand

func TestCommand(cmd *cobra.Command, args ...string) (string, error)

Types

type DebugFlags

type DebugFlags struct {
	ForceSelfUpdate    bool // Force the self update of the CDT
	NoMergeStatusCheck bool // do not check merge status when querying merged changes in gerrit
	ShowCmdExecStdout  bool // always show cmd exec stdout to console
	UseFileVault       bool // use file vault instead of system vault
}

func LoadDebugFlags

func LoadDebugFlags() DebugFlags

load all debug flags into DebugFlags struct

Jump to

Keyboard shortcuts

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