command

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: MIT Imports: 11 Imported by: 0

README

github.com/cyberark/summon/command

Provides the flags and action for the Summon command-line interface.

Documentation

Index

Constants

View Source
const DEVSHM = "/dev/shm"
View Source
const ENV_FILE_MAGIC = "@SUMMONENVFILE"

Variables

View Source
var Action = func(c *cli.Context) {
	if !c.Args().Present() {
		fmt.Println("Enter a subprocess to run!")
		os.Exit(127)
	}

	provider, err := prov.Resolve(c.String("provider"))
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(127)
	}

	err = runAction(&ActionConfig{
		Args:        c.Args(),
		Provider:    provider,
		Environment: c.String("environment"),
		Filepath:    c.String("f"),
		YamlInline:  c.String("yaml"),
		Ignores:     c.StringSlice("ignore"),
		IgnoreAll:   c.Bool("ignore-all"),
		Subs:        convertSubsToMap(c.StringSlice("D")),
	})

	code, err := returnStatusOfError(err)

	if err != nil {
		fmt.Println(err.Error())
		os.Exit(127)
	}

	os.Exit(code)
}
View Source
var Flags = []cli.Flag{
	cli.StringFlag{
		Name:  "p, provider",
		Usage: "Path to provider for fetching secrets",
	},
	cli.StringFlag{
		Name:  "e, environment",
		Usage: "Specify section/environment to parse from secrets.yaml",
	},
	cli.StringFlag{
		Name:  "f",
		Value: "secrets.yml",
		Usage: "Path to secrets.yml",
	},
	cli.StringSliceFlag{
		Name:  "D",
		Value: &cli.StringSlice{},
		Usage: "var=value causes substitution of value to $var",
	},
	cli.StringFlag{
		Name:  "yaml",
		Usage: "secrets.yml as a literal string",
	},
	cli.StringSliceFlag{
		Name:  "ignore, i",
		Value: &cli.StringSlice{},
		Usage: "Ignore the specified key if is isn't accessible or doesn't exist",
	},
	cli.BoolFlag{
		Name:  "ignore-all, I",
		Usage: "Ignore inaccessible or missing keys",
	},
}

Functions

func DefaultTempPath

func DefaultTempPath() string

Default temporary file path Returns /dev/shm if it is a directory, otherwise home dir of current user Else returns the system default

Types

type ActionConfig added in v0.5.0

type ActionConfig struct {
	Args        []string
	Provider    string
	Filepath    string
	YamlInline  string
	Subs        map[string]string
	Ignores     []string
	IgnoreAll   bool
	Environment string
}

type TempFactory

type TempFactory struct {
	// contains filtered or unexported fields
}

func NewTempFactory

func NewTempFactory(path string) TempFactory

Create a new temporary file factory. defer Cleanup() if you want the files removed.

func (*TempFactory) Cleanup

func (tf *TempFactory) Cleanup()

Remove the temporary files created with this factory.

func (*TempFactory) Push

func (tf *TempFactory) Push(value string) string

Create a temp file with given value. Returns the path.

Jump to

Keyboard shortcuts

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