Documentation
¶
Overview ¶
Package command provides command-line interface functionality for Privateer plugins.
Index ¶
- Constants
- Variables
- func Contains(slice []*PluginPkg, search string) bool
- func GeneratePlugin(logger hclog.Logger) (exitCode int)
- func GetInstallCmd(writerFn func() Writer) *cobra.Command
- func GetListCmd(writerFn func() Writer) *cobra.Command
- func NewPluginCommands(pluginName, buildVersion, buildGitCommitHash, buildTime string, ...) *cobra.Command
- func ReadConfig()
- func Run(logger hclog.Logger, getPlugins func() []*PluginPkg) (exitCode int)
- func SetBase(cmd *cobra.Command)
- func SetListCmdFlags(cmd *cobra.Command)
- type CatalogData
- type Plugin
- type PluginConfig
- type PluginError
- type PluginErrors
- type PluginPkg
- type Req
- type Writer
Constants ¶
const ( TestPass = shared.TestPass TestFail = shared.TestFail Aborted = shared.Aborted InternalError = shared.InternalError BadUsage = shared.BadUsage NoTests = shared.NoTests )
Aliases for the canonical values in shared/ — kept here so command.TestPass etc. stay valid for existing callers.
Variables ¶
var ActiveEvaluationOrchestrator *pluginkit.EvaluationOrchestrator
ActiveEvaluationOrchestrator is the currently active evaluation orchestrator.
Functions ¶
func Contains ¶ added in v1.12.0
Contains checks if a plugin with the given name exists in the slice.
func GeneratePlugin ¶ added in v1.12.0
GeneratePlugin executes the plugin generation flow and returns an exit code from the same set used by Run (TestPass, TestFail, InternalError, BadUsage). Mirrors Run's shape: classification + logging happen here so the CLI just calls os.Exit(GeneratePlugin(logger)).
func GetInstallCmd ¶ added in v1.23.0
GetInstallCmd returns the install command that can be added to a root command. writerFn is called at command execution time, so the writer can be initialized lazily (e.g. in a PersistentPreRun hook).
func GetListCmd ¶ added in v1.12.0
GetListCmd returns the list command with flags registered. writerFn is called at command execution time, so the writer can be initialized lazily (e.g. in a PersistentPreRun hook).
func NewPluginCommands ¶
func NewPluginCommands(pluginName, buildVersion, buildGitCommitHash, buildTime string, orchestrator *pluginkit.EvaluationOrchestrator) *cobra.Command
NewPluginCommands creates a new cobra command for the plugin with version and orchestrator support.
func ReadConfig ¶
func ReadConfig()
ReadConfig reads the configuration file. If --config is explicitly provided, that exact path is used. Otherwise, it searches ./config.yml and ~/.privateer/config.yml.
func SetListCmdFlags ¶ added in v1.23.0
SetListCmdFlags registers the standard list flags on the given command.
Types ¶
type CatalogData ¶ added in v1.12.0
type CatalogData struct {
gemara.ControlCatalog
ServiceName string
Organization string
Requirements []Req
ApplicabilityCategories []string
StrippedName string
}
CatalogData extends gemara.ControlCatalog with additional fields for plugin generation.
type PluginConfig ¶ added in v1.21.0
type PluginConfig struct {
TemplatesDir string
SourcePath string
OutputDir string
ServiceName string
Organization string
}
PluginConfig holds the validated configuration for plugin generation.
type PluginError ¶ added in v1.11.0
PluginError retains an error object and the name of the pack that generated it.
type PluginErrors ¶ added in v1.11.0
type PluginErrors struct {
Errors []PluginError
}
PluginErrors holds a list of errors and an Error() method so it adheres to the standard Error interface.
func (*PluginErrors) Error ¶ added in v1.11.0
func (e *PluginErrors) Error() string
type PluginPkg ¶ added in v1.11.0
type PluginPkg struct {
Name string
Path string
ServiceTarget string
Command *exec.Cmd
Result string
Installable bool
Installed bool
Requested bool
Successful bool
Error error
}
PluginPkg represents a plugin package with its metadata and execution state.
func GetPlugins ¶ added in v1.12.0
func GetPlugins() []*PluginPkg
GetPlugins returns a combined list of all plugins (requested and local). Used by Run to determine which plugins to execute.
func NewPluginPkg ¶ added in v1.11.0
NewPluginPkg creates a new PluginPkg instance for the given plugin and service names.