Documentation ¶
Overview ¶
Package opa provides client make requests to the Open Policy Agent API
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { InitializePolicy(policy string) ClientError EvaluatePolicy(policy string, input []byte) (*EvaluatePolicyResponse, error) }
Client is an interface for sending requests to the OPA API
type ClientError ¶
type ClientError interface { error Type() ClientErrorType CausedBy() error }
ClientError interface for errors created by client
func NewClientError ¶
func NewClientError(message string, errorType ClientErrorType, causedBy error) ClientError
NewClientError constructor
type ClientErrorType ¶
type ClientErrorType string
ClientErrorType defines error types
const ( OpaClientErrorTypeGetPolicy ClientErrorType = "Get Policy" OpaClientErrorTypePolicyNotFound ClientErrorType = "Policy Not Found" OpaClientErrorTypePublishPolicy ClientErrorType = "Publish Policy" OpaClientErrorTypeHTTP ClientErrorType = "HTTP Error" OpaClientErrorTypeBadResponse ClientErrorType = "Bad Response" )
OpaClientErrorType constants
type EvaluatePolicyResponse ¶
type EvaluatePolicyResponse struct { Result *EvaluatePolicyResult `json:"result"` Explanation *[]string `json:"explanation"` }
EvaluatePolicyResponse OPA evaluate policy response
type EvaluatePolicyResult ¶
type EvaluatePolicyResult struct { Pass bool `json:"pass"` Violations []*EvaluatePolicyViolation `json:"violations"` }
EvaluatePolicyResult OPA evaluate policy result
type EvaluatePolicyViolation ¶
type EvaluatePolicyViolation struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` Message string `json:"message"` Link string `json:"link"` Pass bool `json:"pass"` }
EvaluatePolicyViolation OPA evaulate policy violation
type EvalutePolicyRequest ¶
type EvalutePolicyRequest struct {
Input json.RawMessage `json:"input"`
}
EvalutePolicyRequest OPA evalute policy request
type PolicyViolation ¶
type PolicyViolation struct {
Conditions []byte
}
PolicyViolation Rego rule conditions
func (*PolicyViolation) Write ¶
func (v *PolicyViolation) Write(w io.Writer)
Write Rego rule to IO writer
Click to show internal directories.
Click to hide internal directories.