command

package
v0.10.10 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 9 Imported by: 0

README

github.com/cyberark/summon/pkg/command

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

Documentation

Index

Constants

This section is empty.

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)
	}

	if c.Bool("all-provider-versions") {
		if err := runPrintProviderVersions(); err != nil {
			fmt.Println(err.Error())
			os.Exit(127)
		}
		return
	}

	code, err := summon.RunSubprocess(&summon.SubprocessConfig{
		Args:        c.Args(),
		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"),
		Subs:        c.StringSlice("D"),
		Provider:    provider,
		FetchSecret: func(secretId string) ([]byte, error) {
			s, err := prov.Call(provider, secretId)
			return []byte(s), 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

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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