policies

package
v0.49.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPolicyNotFound = errors.New("Policy not found")

ErrPolicyNotFound is returned when a policy could not be found

Functions

This section is empty.

Types

type Downloader

type Downloader interface {
	DownloadPolicy(string) ([]byte, error)
}

type PolicyDownloader

type PolicyDownloader struct {
	Downloader
}

func (*PolicyDownloader) DownloadPolicy

func (pdown *PolicyDownloader) DownloadPolicy(id string) ([]byte, error)

type PolicyRegistry

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

func NewRegistry

func NewRegistry(options ...RegistryOption) *PolicyRegistry

NewRegistry returns a new instance of policy registry with default registry storage and policy downloader registry can be created with default options as r := NewRegistry() or with itw own custom options - ie specify a registry storage backend r := NewRegistry(MemStore)

func (*PolicyRegistry) GetPolicy

func (pr *PolicyRegistry) GetPolicy(id string) ([]byte, error)

func (*PolicyRegistry) ListPolicies

func (pr *PolicyRegistry) ListPolicies() []string

type PolicyStorage

type PolicyStorage interface {
	ListPolicies() ([]string, error)
	GetPolicy(string) ([]byte, error)
	UpsertPolicy(string, []byte) error
	//DeletePolicy(string) error
	HasPolicy(string) bool
}

PolicyStorage defines the interface for policy module storage.

type RegistryOption

type RegistryOption func(*PolicyRegistry)
var (
	MemStore RegistryOption = func(pr *PolicyRegistry) {
		pr.registry = NewMemStore()
	}
	FSStore = func(basedir string) RegistryOption {
		return func(pr *PolicyRegistry) {
			pr.registry = NewFSStore(basedir)
		}
	}
)

type Store

type Store interface {
	PolicyStorage
}

Store defines the interface for any Policy Storage implementation

func NewFSStore

func NewFSStore(path string) Store

NewFSStore returns an empty store based on local file system

func NewMemStore

func NewMemStore() Store

NewMemStore returns an empty in-memory store.

Jump to

Keyboard shortcuts

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