opa

package
v0.14.9 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

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, policyData string) ClientError
	EvaluatePolicy(policy string, input []byte) (*EvaluatePolicyResponse, error)
}

Client is an interface for sending requests to the OPA API

func NewClient

func NewClient(logger *zap.Logger, host string, explainQuery bool) Client

NewClient OpaClient constructor

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"
	OpaClientErrorTypeLoadPolicy     ClientErrorType = "Load Policy"
)

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 []*pb.EvaluatePolicyViolation `json:"violations"`
}

EvaluatePolicyResult OPA evaluate policy result

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

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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