common

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBodyRequired           = fmt.Errorf("body is required")
	ErrTitleRequired          = fmt.Errorf("title is required")
	ErrSigningKeyPassRequired = fmt.Errorf("passphrase of signing key is required")
)

Functions

func GetRPCClient

func GetRPCClient(cmd *cobra.Command, targetRepo remotetypes.LocalRepo) (*client.RPCClient, error)

GetRPCClient returns an RPC client. If target repo is provided, the RPC server information will be extracted from one of the remote URLs. The target remote is set via viper's "remote.name" or "--remote" root flag.

func GetRemoteAddrFromRepo

func GetRemoteAddrFromRepo(repo remotetypes.LocalRepo, remoteName string) (string, int, bool)

GetRemoteAddrFromRepo gets remote address from the given repo. It will return false if no (good) url was found.

func GetRepoAndClient

func GetRepoAndClient(cmd *cobra.Command, cfg *config.AppConfig, repoDir string) (remotetypes.LocalRepo, types2.Client)

GetRepoAndClient opens a the repository on the current working directory and returns an RPC client.

func MakePassEnvVar

func MakePassEnvVar(appName string) string

MakePassEnvVar is the name of the env variable expected to contain a key's passphrase.

func MakeRepoScopedEnvVar

func MakeRepoScopedEnvVar(appName, repoName, varName string) string

MakeRepoScopedEnvVar returns a repo-specific env variable

func ShowTxStatusTracker

func ShowTxStatusTracker(stdout io.Writer, hash string, rpcClient types2.Client) error

ShowTxStatusTracker tracks transaction status and displays updates to stdout.

func UnlockKey

func UnlockKey(cfg *config.AppConfig, args *UnlockKeyArgs) (types.StoredKey, error)

UnlockKey takes a key address or index, unlocks it and returns the key. - It will using the given passphrase if set, otherwise - if the target repo is set, it will try to get it from the git config (user.passphrase). - If passphrase is still unknown, it will attempt to get it from an environment variable. - On success, args.Passphrase is updated with the passphrase used to unlock the key.

func WriteToPager

func WriteToPager(pagerCmd string, content io.Reader, stdOut, stdErr io.Writer)

WriteToPager spawns the specified page, passing the given content to it

Types

type PagerWriter

type PagerWriter func(pagerCmd string, content io.Reader, stdOut, stdErr io.Writer)

pagerWriter describes a function for writing a specified content to a pager program

type TxStatusTrackerFunc

type TxStatusTrackerFunc func(stdout io.Writer, hash string, rpcClient types2.Client) error

type UnlockKeyArgs

type UnlockKeyArgs struct {

	// KeyStoreID is the index or address of the key on the keystore
	KeyStoreID string

	// Passphrase is the passphrase to use for unlocking the key
	Passphrase string

	// TargetRepo is the target repository in the current working directory.
	// It's config `user.passphrase` is checked for the passphrase.
	TargetRepo remotetypes.LocalRepo

	// NoPrompt if true, will launch a prompt if passphrase was not gotten from other means
	NoPrompt bool

	// Prompt is a message to print out when launching a prompt.
	Prompt string

	Stdout io.Writer
}

UnlockKeyArgs contains arguments for UnlockKey

type UnlockKeyFunc

type UnlockKeyFunc func(cfg *config.AppConfig, args *UnlockKeyArgs) (types.StoredKey, error)

UnlockKeyFunc describes a function for unlocking a keystore key.

Jump to

Keyboard shortcuts

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