policy

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a policy engine client

func New

func New(options ...Option) (*Client, error)

New creates a new Local client. It requires one or more WithFile, WithDir or WithPolicyData.

func (*Client) Query

func (x *Client) Query(ctx context.Context, query string, input interface{}, output interface{}, options ...QueryOption) error

Query evaluates policy with `input` data. The result will be written to `out`. `out` must be pointer of instance.

type Option

type Option func(x *Client)

Option is a functional option for Client

func WithDir

func WithDir(dirPath string) Option

WithDir specifies directory path of .rego policy. Import policy files recursively.

func WithFile

func WithFile(filePath string) Option

WithFile specifies file path of .rego policy. Import policy files recursively.

func WithPolicyData

func WithPolicyData(name, policy string) Option

WithPolicyData specifies raw policy data with name. If the `name` conflicts with file path loaded by WithFile or WithDir, the policy overwrites data loaded by WithFile or WithDir.

func WithReadFile

func WithReadFile(fn func(string) ([]byte, error)) Option

WithReadFile specifies file path of .rego policy. Import policy files recursively.

type QueryOption

type QueryOption func(cfg *queryConfig)

func WithRegoPrint

func WithRegoPrint(callback RegoPrint) QueryOption

type RegoPrint

type RegoPrint func(file string, row int, msg string) error

Jump to

Keyboard shortcuts

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