command

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 14 Imported by: 0

README

github.com/cyberark/summon/internal/command

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

Documentation

Index

Constants

View Source
const DEVSHM = "/dev/shm"

DEVSHM is the default *nix shared-memory directory path

View Source
const ENV_FILE_MAGIC = "@SUMMONENVFILE"
View Source
const SUMMON_ENV_KEY_NAME = "SUMMON_ENV"

Variables

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

	provider, err := prov.Resolve(c.String("provider"))

	if err != nil && !c.Bool("all-provider-versions") {
		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"),
		RecurseUp:            c.Bool("up"),
		ShowProviderVersions: c.Bool("all-provider-versions"),
		Subs:                 convertSubsToMap(c.StringSlice("D")),
	})

	code, err := returnStatusOfError(err)

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

	os.Exit(code)
}

Action is the runner for the main program logic

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.BoolFlag{
		Name:  "up",
		Usage: "Go up in the directory hierarchy until the secrets file is found",
	},
	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",
	},
	cli.BoolFlag{
		Name:  "all-provider-versions, V",
		Usage: "List of all of the providers in the default path and their versions(if they have the --version tag)",
	},
}

Flags define all the available CLI switches and aargs that a user can provide

Functions

func DefaultTempPath

func DefaultTempPath() string

DefaultTempPath returns the best possible temp folder path for temp files

Types

type ActionConfig

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

ActionConfig is an object that holds all the info needed to run a Summon instance

type TempFactory

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

TempFactory handels transient files that require cleaning up after the child process exits.

func NewTempFactory

func NewTempFactory(path string) TempFactory

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

func (*TempFactory) Cleanup

func (tf *TempFactory) Cleanup()

Cleanup removes the temporary files created with this factory.

func (*TempFactory) Push

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

Push creates 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