Help us shape the future of Go! Take the 2026 Go Developer Survey

token

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2015 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecScript added in v0.1.2

func ExecScript(script string) (*exec.Cmd, error)

ExecScript returns a command to execute a script

func HelperPath

func HelperPath(path string) string

HelperPath takes the configured path to a helper and expands it to a full absolute path that can be executed. If the path is relative then a prefix of "vault token-" will be prepended to the path.

func Test

func Test(t *testing.T, h *Helper)

Test is a public function that can be used in other tests to test that a helper is functioning properly.

func TestHelperProcessCLI

func TestHelperProcessCLI(t *testing.T, cmd cli.Command)

TestHelperProcessCLI can be called to implement TestHelperProcess for TestProcess that just executes a CLI command.

func TestProcess

func TestProcess(t *testing.T, s ...string)

TestProcess is used to re-execute this test in order to use it as the helper process. For this to work, the TestHelperProcess function must exist.

func TestProcessPath

func TestProcessPath(t *testing.T, s ...string) string

TestProcessPath returns the path to the test process.

Types

type Helper

type Helper struct {
	Path string
	Env  []string
}

Helper is the struct that has all the logic for storing and retrieving tokens from the token helper. The API for the helpers is simple: the Path is executed within a shell with environment Env. The last argument appended will be the operation, which is:

  • "get" - Read the value of the token and write it to stdout.
  • "store" - Store the value of the token which is on stdin. Output nothing.
  • "erase" - Erase the contents stored. Output nothing.

Any errors can be written on stdout. If the helper exits with a non-zero exit code then the stderr will be made part of the error value.

func (*Helper) Erase

func (h *Helper) Erase() error

Erase deletes the contents from the helper.

func (*Helper) Get

func (h *Helper) Get() (string, error)

Get gets the token value from the helper.

func (*Helper) Store

func (h *Helper) Store(v string) error

Store stores the token value into the helper.

Jump to

Keyboard shortcuts

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