command

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 29 Imported by: 4

Documentation

Overview

Package command provides command-line interface functionality for Privateer plugins.

Index

Constants

View Source
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

View Source
var ActiveEvaluationOrchestrator *pluginkit.EvaluationOrchestrator

ActiveEvaluationOrchestrator is the currently active evaluation orchestrator.

Functions

func Contains added in v1.12.0

func Contains(slice []*PluginPkg, search string) bool

Contains checks if a plugin with the given name exists in the slice.

func GeneratePlugin deprecated added in v1.12.0

func GeneratePlugin(logger hclog.Logger) (exitCode int)

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

Deprecated: use harness.GeneratePlugin instead. This will be removed once the pvtr CLI migrates to the command/harness import path.

func GetInstallCmd deprecated added in v1.23.0

func GetInstallCmd(writerFn func() Writer) *cobra.Command

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). The install logic lives in internal/install; this is the CLI seam that owns the writer and dispatches between the grc.store and --local paths.

Deprecated: use harness.GetInstallCmd instead. This will be removed once the pvtr CLI migrates to the command/harness import path.

func GetListCmd deprecated added in v1.12.0

func GetListCmd(writerFn func() Writer) *cobra.Command

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

Deprecated: use harness.GetListCmd instead. This will be removed once the pvtr CLI migrates to the command/harness import path.

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 Run deprecated added in v1.12.0

func Run(logger hclog.Logger, getPlugins func() []*PluginPkg) (exitCode int)

Run executes all plugins with handling for the command line.

Deprecated: use harness.Run instead. This will be removed once the pvtr CLI migrates to the command/harness import path.

func SetBase

func SetBase(cmd *cobra.Command)

SetBase sets the flags that are universal to every command. These are safe to place on a shared root because they apply to all subcommands. Execution-only flags live in SetRunFlags so their shorthands (e.g. -o) do not collide with sibling subcommands such as generate-plugin's --output-dir.

func SetListCmdFlags deprecated added in v1.23.0

func SetListCmdFlags(cmd *cobra.Command)

SetListCmdFlags registers the standard list flags on the given command.

Deprecated: use harness.SetListCmdFlags instead. This will be removed once the pvtr CLI migrates to the command/harness import path.

func SetRunFlags added in v1.31.2

func SetRunFlags(cmd *cobra.Command)

SetRunFlags registers the execution-specific flags on the command that runs a plugin (the pvtr `run` command, or a plugin binary's root). These are kept off the shared root so their shorthands cannot collide with other subcommands.

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 Plugin

type Plugin struct{}

Plugin represents a Privateer plugin instance.

func (*Plugin) Start

func (p *Plugin) Start() (int, error)

Start will be called by Privateer via gRPC.

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

type PluginError struct {
	Plugin string
	Err    error
}

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
	Version       string // requested version; "" means "latest installed"
	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.

Requested plugins already carry their resolved binary path and Installed state from NewPluginPkg (which consults the manifest by name+version), so they are taken as-is. Installed plugins not requested in the config are then appended for visibility in `list`.

func NewPluginPkg added in v1.11.0

func NewPluginPkg(pluginName, version, serviceName string) *PluginPkg

NewPluginPkg creates a new PluginPkg for the given plugin name, requested version (empty for "latest installed"), and service. It resolves the binary from the manifest: on success the package is marked Installed with its Path set; on failure Error is recorded and Installed stays false.

type Req added in v1.12.0

type Req struct {
	Id   string
	Text string
}

Req represents an assessment requirement with an ID and text description.

type Writer added in v1.12.0

type Writer interface {
	io.Writer
	Flush() error
}

Writer is an interface for output operations that supports writing and flushing.

Directories

Path Synopsis
Package harness is the import surface for Privateer harnesses (the pvtr CLI and future similar tools) — the commands that drive plugins rather than the commands a plugin serves about itself.
Package harness is the import surface for Privateer harnesses (the pvtr CLI and future similar tools) — the commands that drive plugins rather than the commands a plugin serves about itself.

Jump to

Keyboard shortcuts

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