Documentation ¶
Overview ¶
nolint:structcheck,unused
nolint:structcheck,unused
Index ¶
- Constants
- Variables
- func FormatStatus(status Status, outputType string) (statusMessage string, err error)
- type BackendI
- type BackendStatus
- type BackendType
- type BinaryConfig
- type CommonConfig
- type Config
- type ContainerConfig
- type ContainerOutput
- type DirectoryPaths
- type Docker
- func (d *Docker) Exec(tool *Tool, args []string, prmConfig Config, paths DirectoryPaths) (ToolExitCode, error)
- func (d *Docker) GetTool(tool *Tool, prmConfig Config) error
- func (d *Docker) ImageName(tool *Tool, prmConfig Config) string
- func (d *Docker) Status() BackendStatus
- func (d *Docker) Validate(toolInfo ToolInfo, prmConfig Config, paths DirectoryPaths) (ValidateExitCode, string, error)
- type DockerClientI
- type ExecExitCode
- type GemConfig
- type Group
- type InstallSteps
- type OutputModes
- type OutputSettings
- type PluginConfig
- type Pool
- type Prm
- func (p *Prm) EnsureCacheDirExists() error
- func (p *Prm) Exec(tool *Tool, args []string) error
- func (p *Prm) FilterFiles(ss []ToolConfig, test func(ToolConfig) bool) (ret []ToolConfig)
- func (*Prm) FormatTools(tools map[string]*Tool, jsonOutput string) (string, error)
- func (p *Prm) GenerateDefaultCfg()
- func (p *Prm) GetDefaultToolPath() (string, error)
- func (p *Prm) GetStatus() (status Status)
- func (p *Prm) GetValidationGroupFromFile(selectedGroupID string) (Group, error)
- func (p *Prm) IsToolAvailable(tool string) (*Tool, bool)
- func (p *Prm) IsToolReady(tool *Tool) bool
- func (p *Prm) List(toolPath string, toolName string, onlyValidators bool) error
- func (p *Prm) LoadConfig() error
- func (p *Prm) Validate(toolsInfo []ToolInfo, workerCount int, settings OutputSettings) error
- type PuppetConfig
- type PuppetVersion
- type Status
- type Task
- type Tool
- type ToolConfig
- type ToolConfigInfo
- type ToolExitCode
- type ToolInfo
- type ToolInst
- type ValidateExitCode
- type ValidateYmlContent
- type ValidationOutput
Constants ¶
const ( PuppetCmdFlag string = "puppet" BackendCmdFlag string = "backend" PuppetVerCfgKey string = "puppetversion" // Should match Config struct key. BackendCfgKey string = "backend" // Should match Config struct key. DefaultPuppetVer string = "7.15.0" DefaultBackend BackendType = DOCKER ToolPathCfgKey string = "toolpath" ToolTimeoutCfgKey string = "toolTimeout" DefaultToolTimeout int = 1800 // 30 minutes )
const ( ToolConfigName = "prm-config" ToolConfigFileName = "prm-config.yml" )
Variables ¶
var (
ErrDockerNotRunning = fmt.Errorf("docker is not running, please start the docker process")
)
var ( ToolGroups = map[string][]ToolInst{ "group/modules": { {Name: "puppetlabs/spec_cache"}, { Name: "puppetlabs/spec_puppet", Args: []string{ "spec_prep", }, }, {Name: "puppetlabs/spec_puppet"}, {Name: "puppetlabs/rubocop"}, {Name: "puppetlabs/puppet-lint"}, {Name: "puppetlabs/puppet-syntax"}, {Name: "puppetlabs/puppet-strings"}, }, } )
Functions ¶
Types ¶
type BackendI ¶
type BackendI interface { GetTool(tool *Tool, prmConfig Config) error Validate(toolInfo ToolInfo, prmConfig Config, paths DirectoryPaths) (ValidateExitCode, string, error) Exec(tool *Tool, args []string, prmConfig Config, paths DirectoryPaths) (ToolExitCode, error) Status() BackendStatus }
type BackendStatus ¶
The BackendStatus must report whether the backend is available and any useful status information; in the case of the backend being unavailable, report the error message to the user.
type BinaryConfig ¶
type BinaryConfig struct { Name string `mapstructure:"name"` InstallSteps *InstallSteps `mapstructure:"install_steps"` }
type CommonConfig ¶
type CommonConfig struct { CanValidate bool `mapstructure:"can_validate"` NeedsWriteAccess bool `mapstructure:"needs_write_access"` UseScript string `mapstructure:"use_script"` RequiresGit bool `mapstructure:"requires_git"` DefaultArgs []string `mapstructure:"default_args"` HelpArg string `mapstructure:"help_arg"` SuccessExitCode int `mapstructure:"success_exit_code"` InterleaveStdOutErr bool `mapstructure:"interleave_stdout"` OutputMode *OutputModes `mapstructure:"output_mode"` Env map[string]string `mapstructure:"env"` }
type ContainerConfig ¶
type ContainerOutput ¶
type ContainerOutput struct {
// contains filtered or unexported fields
}
type DirectoryPaths ¶
type DirectoryPaths struct {
// contains filtered or unexported fields
}
type Docker ¶
type Docker struct { // We need to be able to mock the docker client in testing Client DockerClientI Context context.Context ContextCancel func() ContextTimeout time.Duration AFS *afero.Afero IOFS *afero.IOFS AlwaysBuild bool }
func (*Docker) Exec ¶
func (d *Docker) Exec(tool *Tool, args []string, prmConfig Config, paths DirectoryPaths) (ToolExitCode, error)
func (*Docker) ImageName ¶
Creates a unique name for the image based on the tool and the PRM configuration
func (*Docker) Status ¶
func (d *Docker) Status() BackendStatus
Check to see if the Docker runtime is available: if so, return true and info about Docker on this node; if not, return false and the error message
func (*Docker) Validate ¶
func (d *Docker) Validate(toolInfo ToolInfo, prmConfig Config, paths DirectoryPaths) (ValidateExitCode, string, error)
type DockerClientI ¶
type DockerClientI interface { // All docker client functions must be noted here so they can be mocked ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) ServerVersion(context.Context) (types.Version, error) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error }
type ExecExitCode ¶
type ExecExitCode int64
const ( EXEC_SUCCESS ExecExitCode = iota EXEC_FAILURE EXEC_ERROR )
type InstallSteps ¶
type OutputModes ¶
type OutputSettings ¶
type PluginConfig ¶
type PluginConfig struct { install.ConfigParams `mapstructure:",squash"` Display string `mapstructure:"display"` UpstreamProjUrl string `mapstructure:"upstream_project_url"` }
type Prm ¶
type Prm struct { AFS *afero.Afero IOFS *afero.IOFS RunningConfig Config CodeDir string CacheDir string Cache map[string]*Tool Backend BackendI }
func (*Prm) EnsureCacheDirExists ¶
func (*Prm) FilterFiles ¶
func (p *Prm) FilterFiles(ss []ToolConfig, test func(ToolConfig) bool) (ret []ToolConfig)
func (*Prm) FormatTools ¶
FormatTools formats one or more templates to display on the console in table format or json format.
func (*Prm) GenerateDefaultCfg ¶
func (p *Prm) GenerateDefaultCfg()
func (*Prm) GetDefaultToolPath ¶
func (*Prm) GetValidationGroupFromFile ¶
func (*Prm) IsToolAvailable ¶
Check to see if the requested tool can be found installed. If installed read the tool configuration and return
func (*Prm) IsToolReady ¶
Check to see if the tool is ready to execute
func (*Prm) List ¶
List lists all templates in a given path and parses their configuration. Does not return any errors from parsing invalid templates, but returns them as debug log events
func (*Prm) LoadConfig ¶
type PuppetConfig ¶
type PuppetConfig struct {
Enabled bool `mapstructure:"enabled"`
}
type PuppetVersion ¶
type PuppetVersion struct {
// contains filtered or unexported fields
}
type Status ¶
type Status struct { PuppetVersion *semver.Version Backend BackendType BackendStatus BackendStatus }
type Task ¶
type Task[T any] struct { // Output holds an error that occurred during a task. Its // result is only meaningful after Run has been called // for the pool that holds it. Name string Output T // contains filtered or unexported fields }
Task encapsulates a work item that should go in a work pool.
func CreateTask ¶
type Tool ¶
type Tool struct { Stdout io.Reader Stderr io.Reader ExitCode ToolExitCode Cfg ToolConfig }
type ToolConfig ¶
type ToolConfig struct { Path string Plugin *PluginConfig `mapstructure:"plugin"` Gem *GemConfig `mapstructure:"gem"` Container *ContainerConfig `mapstructure:"container"` Binary *BinaryConfig `mapstructure:"binary"` Puppet *PuppetConfig `mapstructure:"puppet"` Common CommonConfig `mapstructure:"common"` }
type ToolConfigInfo ¶
type ToolConfigInfo struct { Plugin PluginConfig `mapstructure:"plugin"` Defaults map[string]interface{} }
ToolConfigInfo is the housing struct for marshaling YAML data
type ToolExitCode ¶
type ToolExitCode int64
const ( FAILURE ToolExitCode = iota SUCCESS TOOL_ERROR TOOL_NOT_FOUND )
type ToolInst ¶
This package contains ToolGroups, which defines what inidividual tools make up a specific ToolGroup.
This allows users to specify 'group/mygroup' and have PRM execute against a larger list of tools, without needing to define or understand what is being called.
type ValidateExitCode ¶
type ValidateExitCode int64
const ( VALIDATION_PASS ValidateExitCode = iota VALIDATION_FAILED VALIDATION_ERROR )
type ValidateYmlContent ¶
type ValidateYmlContent struct {
Groups []Group `yaml:"groups"`
}
type ValidationOutput ¶
type ValidationOutput struct {
// contains filtered or unexported fields
}