utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultECCurve = "P-256"

DefaultECCurve sets the default curve for EC to P-256.

View Source
const DefaultRSASize = 2048

DefaultRSASize sets the default key size for RSA to 2048 bits.

Variables

View Source
var (
	// ErrFileExists is the error returned if a file exists.
	ErrFileExists = errors.New("file exists")

	// ErrIsDir is the error returned if the file is a directory.
	ErrIsDir = errors.New("file is a directory")
)

Functions

func Fail

func Fail(err error)

Fail prints out the error struct if STEPDEBUG is true otherwise it just prints out the error message. Finally, it exits with an error code of 1.

func GetKeyDetailsFromCLI

func GetKeyDetailsFromCLI(ctx *cli.Context, insecure bool, ktyKey, curveKey, sizeKey string) (string, string, int, error)

GetKeyDetailsFromCLI gets the key pair algorithm, curve, and size inputs from the CLI context.

func ReadAll

func ReadAll(r io.Reader) ([]byte, error)

ReadAll returns a slice of bytes with the content of the given reader.

func ReadInput

func ReadInput(prompt string) ([]byte, error)

ReadInput from stdin if something is detected or ask the user for an input using the given prompt.

func ReadPassword

func ReadPassword(prompt string) ([]byte, error)

ReadPassword asks the user for a password using the given prompt. If the program is receiving data from STDIN using a pipe, we cannot use terminal.ReadPassword on STDIN and we need to open the tty and read from it.

This solution works on darwin and linux, but it might not work on other OSs.

func ReadString

func ReadString(r io.Reader) (string, error)

ReadString reads one line from the given io.Reader.

func WriteFile

func WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile wraps ioutil.WriteFile with a prompt to overwrite a file if the file exists. It returns ErrFileExists if the user picks to not overwrite the file.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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