opa

package
v0.0.0-...-ae8710e Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TagsAction    = "tags"
	ExecuteAction = "execute"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractClient

type AbstractClient interface {
	GenerateTags(input interface{}) ([]amphora.Tag, error)
	CanExecute(input interface{}) (bool, error)
}

AbstractClient is an interface that defines the methods that an OPA client must implement.

type Client

type Client struct {
	URL           url.URL
	PolicyPackage string
	HttpClient    http.Client
	Logger        *zap.SugaredLogger
}

Client represents an OPA client that can be used to interact with an OPA server.

func NewClient

func NewClient(logger *zap.SugaredLogger, endpoint string, policyPackage string) (*Client, error)

NewClient creates a new OPA client with the given endpoint and policy package. It returns an error if the endpoint is invalid or the policy package is empty.

func (*Client) CanExecute

func (c *Client) CanExecute(data interface{}) (bool, error)

CanExecute checks if the program can be executed with the input described by the data provided according to the policy package. It returns true if the program can be executed, false otherwise. An error is returned if the request fails.

func (*Client) GenerateTags

func (c *Client) GenerateTags(data interface{}) ([]amphora.Tag, error)

GenerateTags generates tags for the data described by the data provided according to the policy package. It returns the tags if the request was successful. An error is returned if the request fails.

type ExecuteResponse

type ExecuteResponse struct {
	IsAllowed bool `json:"result"`
}

type OpaRequest

type OpaRequest struct {
	Input interface{} `json:"input"`
}

type TagResponse

type TagResponse struct {
	Tags []amphora.Tag `json:"result"`
}

Jump to

Keyboard shortcuts

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