Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecuteRequest ¶
type ExecuteRequest struct {
// Policy is the policy that should be executed.
Policy *Policy
// UpdateCallback gets called when the client receives updates on policy execution (optional).
UpdateCallback ExecutionCallback
// StopOnFailure if true policy execution will stop on first failure
StopOnFailure bool
// SkipVersioning if true policy will be executed without checking out the version of the policy repo using git tags
SkipVersioning bool
}
ExecuteRequest is a request that triggers policy execution.
type ExecutionCallback ¶
ExecutionCallback represents the format of the policy callback function.
type ExecutionResult ¶
type ExecutionResult struct {
// True if all policies have passed
Passed bool
// Map of all query result sets
Results map[string]*QueryResult
}
ExecutionResult contains all policy execution results.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor implements the execution framework.
func NewExecutor ¶
NewExecutor creates a new executor.
func (*Executor) CreateView ¶
CreateView creates the given view temporary.
func (*Executor) ExecutePolicies ¶
func (e *Executor) ExecutePolicies(ctx context.Context, execReq *ExecuteRequest, policyMap map[string]*config.Policy) (*ExecutionResult, error)
ExecutePolicies executes multiple given policies and the related sub queries/views. Note: It does not execute sub policies that are attached to the policies. Is is the callers responsibility to do that.
func (*Executor) ExecuteQuery ¶
ExecuteQuery executes the given query and returns the result.
type Manager ¶
type Manager interface {
// ParsePolicyHubPath parses a given policy hub path and returns a Policy object.
ParsePolicyHubPath(args []string, subPolicyPath string) (*Policy, error)
// DownloadPolicy downloads the given policy.
DownloadPolicy(ctx context.Context, p *Policy) error
// RunPolicy runs the given policy.
RunPolicy(ctx context.Context, execRequest *ExecuteRequest) (*ExecutionResult, error)
}
Manager is the interface that describes the interaction with the policy hub. Implemented by ManagerImpl.
type ManagerImpl ¶
type ManagerImpl struct {
// contains filtered or unexported fields
}
ManagerImpl is the manager implementation struct.
func (*ManagerImpl) DownloadPolicy ¶
func (m *ManagerImpl) DownloadPolicy(ctx context.Context, p *Policy) error
DownloadPolicy downloads the given policy from GitHub and stores it in the local policy directory.
func (*ManagerImpl) ParsePolicyHubPath ¶
func (m *ManagerImpl) ParsePolicyHubPath(args []string, subPolicyPath string) (*Policy, error)
ParsePolicyHubPath parses and validates the given arguments into the Policy struct. Given args should follow the following semantic structure: [(organization/)repository-name(@tag)] ([repository-path])
func (*ManagerImpl) RunPolicy ¶
func (m *ManagerImpl) RunPolicy(ctx context.Context, execReq *ExecuteRequest) (*ExecutionResult, error)
RunPolicy runs the given policy.
type Policy ¶
type Policy struct {
// Organization is the policy org.
Organization string
// Repository is the policy repository.
Repository string
// RepositoryPath is the policy repository internal path.
RepositoryPath string
// Version is the git repository tag that should be used.
Version string
// SubPath is the policy sub-path.
SubPath string
}
Policy represents a single policy.
type QueryResult ¶
type QueryResult struct {
Name string `json:"name"`
Columns []string `json:"result_headers"`
Data [][]interface{} `json:"result_rows"`
Passed bool `json:"check_passed"`
}
QueryResult contains the result information from an executed query.