opa

package
v1.3.13 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) *bool

Bool returns a pointer to b.

func Int

func Int(i int) *int

Int returns a pointer to i.

func IsNotFoundErr

func IsNotFoundErr(e error) bool

IsNotFoundErr returns true if the error or it's cause is a 404 response from Opa.

func String

func String(s string) *string

String returns pointer to s.

func StringSlice

func StringSlice(elements ...string) []*string

StringSlice converts a slice of string to a slice of *string

Types

type Client

type Client struct {
	Policies *PolicyService

	custom.Registry
	// contains filtered or unexported fields
}

Client talks to the Admin API or control plane of a Opa cluster

func NewClient

func NewClient(baseURL *string, client *http.Client) (*Client, error)

NewClient returns a Client which talks to Admin API of Opa

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request,
	v interface{}) (*Response, error)

Do executes a HTTP request and returns a response

func (*Client) Health

func (c *Client) Health(ctx context.Context) (map[string]interface{}, error)

Health returns the response of GET request on root of Admin API (GET /).

func (*Client) NewFile

func (c *Client) NewFile(body string) (*os.File, error)

NewFile creates a request based on the inputs. endpoint should be relative to the baseURL specified during client creation. body is always marshaled into JSON.

func (*Client) NewFormEncodedRequest

func (c *Client) NewFormEncodedRequest(method, endpoint string, qs interface{},
	reader io.Reader) (*http.Request, error)

NewFormEncodedRequest creates a request based on the inputs. endpoint should be relative to the baseURL specified during client creation.

func (*Client) NewJSONRequest

func (c *Client) NewJSONRequest(method, endpoint string, qs interface{},
	body interface{}) (*http.Request, error)

NewJSONRequest creates a request based on the inputs. endpoint should be relative to the baseURL specified during client creation. body is always marshaled into JSON.

func (*Client) Root

func (c *Client) Root(ctx context.Context) (map[string]interface{}, error)

Root returns the response of GET request on root of Admin API (GET /).

func (*Client) SetDebugMode

func (c *Client) SetDebugMode(enableDebug bool)

SetDebugMode enables or disables logging of the request to the logger set by SetLogger(). By default, debug logging is disabled.

func (*Client) SetLogger

func (c *Client) SetLogger(w io.Writer)

SetLogger sets the debug logger, defaults to os.StdErr

func (*Client) Status

func (c *Client) Status(ctx context.Context) (*Status, error)

Status returns the status of a Opa node

type Configuration

type Configuration map[string]interface{}

Configuration represents a config of a plugin in Opa.

type ListOpt

type ListOpt struct {
	Pretty bool
}

ListOpt aids in paginating through list endpoints

type Policy

type Policy struct {
	ID  *string `json:"id,omitempty" yaml:"id,omitempty"`
	Raw *string `json:"raw,omitempty" yaml:"raw,omitempty"`
}

Policy represents a Policy in Opa. +k8s:deepcopy-gen=true

func (*Policy) DeepCopy

func (in *Policy) DeepCopy() *Policy

DeepCopy copies the receiver, creating a new Configuration.

func (*Policy) DeepCopyInto

func (in *Policy) DeepCopyInto(out *Policy)

DeepCopyInto copies the receiver, writing into out. in must be non-nil.

type PolicyService

type PolicyService service

PolicyService handles Policies in Opa.

func (*PolicyService) Create

func (s *PolicyService) Create(ctx context.Context,
	policy *Policy) (*Policy, error)

Create creates a Policy in Opa. If an ID is specified, it will be used to create a policy in Opa, otherwise an ID is auto-generated.

func (*PolicyService) Delete

func (s *PolicyService) Delete(ctx context.Context,
	usernameOrID *string) error

Delete deletes a Policy in Opa

func (*PolicyService) Get

func (s *PolicyService) Get(ctx context.Context,
	usernameOrID *string) (*Policy, error)

Get fetches a Policy in Opa.

func (*PolicyService) GetByCustomID

func (s *PolicyService) GetByCustomID(ctx context.Context,
	customID *string) (*Policy, error)

GetByCustomID fetches a Policy in Opa.

func (*PolicyService) List

func (s *PolicyService) List(ctx context.Context,
	opt *ListOpt) ([]*Policy, *ListOpt, error)

List fetches a list of Policies in Opa. opt can be used to control pagination.

func (*PolicyService) ListAll

func (s *PolicyService) ListAll(ctx context.Context) ([]*Policy, error)

ListAll fetches all Policies in Opa. This method can take a while if there a lot of Policies present.

func (*PolicyService) Update

func (s *PolicyService) Update(ctx context.Context,
	policy *Policy) (*Policy, error)

Update updates a Policy in Opa

type Response

type Response struct {
	*http.Response
}

Response is a Opa Admin API response. It wraps http.Response.

type Status

type Status struct {
	Database struct {
		Reachable bool `json:"reachable"`
	} `json:"database"`
	Server struct {
		ConnectionsAccepted int `json:"connections_accepted"`
		ConnectionsActive   int `json:"connections_active"`
		ConnectionsHandled  int `json:"connections_handled"`
		ConnectionsReading  int `json:"connections_reading"`
		ConnectionsWaiting  int `json:"connections_waiting"`
		ConnectionsWriting  int `json:"connections_writing"`
		TotalRequests       int `json:"total_requests"`
	} `json:"server"`
}

Status respresents current status of a Opa node.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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