adapters

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowedFileType

type AllowedFileType string

AllowedFileType - alias type for describing allowed file types.

const (
	// JSONFile - JSON file type token.
	JSONFile AllowedFileType = "JSONFile"
	// YAMLFile - YAML file type token.
	YAMLFile AllowedFileType = "YAMLFile"
)

type FileAdapter

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

FileAdapter - StorageAdapter implementation, providing file-based persistence. It can be configured to use JSON or YAML format.

func NewFileAdapter

func NewFileAdapter(fileName string, fileType AllowedFileType) *FileAdapter

NewFileAdapter - returns new FileAdapter instance.

func (*FileAdapter) LoadPolicy

func (fa *FileAdapter) LoadPolicy() (*restrict.PolicyDefinition, error)

LoadPolicy - loads and returns policy from file specified when creating FileAdapter.

func (*FileAdapter) SavePolicy

func (fa *FileAdapter) SavePolicy(policy *restrict.PolicyDefinition) error

SavePolicy - saves given policy in file specified when creating FileAdapter.

func (*FileAdapter) SetFilePerm

func (fa *FileAdapter) SetFilePerm(perm FilePerm)

SetFilePerm - allows to set perm of the file the policy is written into.

func (*FileAdapter) SetJSONIndent

func (fa *FileAdapter) SetJSONIndent(indent string)

SetJsonIndent - allows to set indentation used when marshaling the Policy into JSON.

type FilePerm

type FilePerm os.FileMode

type FileReadWriter

type FileReadWriter interface {
	ReadFile(name string) ([]byte, error)
	WriteFile(name string, data []byte, perm FilePerm) error
}

FileReadWriter - facade interface for os read/write file functions.

type FileTypeNotSupportedError

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

FileTypeNotSupportedError - thrown when FileAdapter is used with inappropriate file type.

func (*FileTypeNotSupportedError) Error

func (e *FileTypeNotSupportedError) Error() string

Error - error interface implementation.

type InMemoryAdapter

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

InMemoryAdapter - StorageAdapter implementation, providing in-memory persistence.

func NewInMemoryAdapter

func NewInMemoryAdapter(policy *restrict.PolicyDefinition) *InMemoryAdapter

NewInMemoryAdapter - returns new InMemoryAdapter instance.

func (*InMemoryAdapter) LoadPolicy

func (ia *InMemoryAdapter) LoadPolicy() (*restrict.PolicyDefinition, error)

LoadPolicy - returns policy from memory.

func (*InMemoryAdapter) SavePolicy

func (ia *InMemoryAdapter) SavePolicy(policy *restrict.PolicyDefinition) error

SavePolicy - saves policy to memory.

type JSONMarshalUnmarshaler

type JSONMarshalUnmarshaler interface {
	Unmarshal(data []byte, v interface{}) error
	MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
}

JSONMarshalUnmarshaler - facade interface for json operations.

type YAMLMarshalUnmarshaler

type YAMLMarshalUnmarshaler interface {
	Unmarshal(in []byte, out interface{}) (err error)
	Marshal(in interface{}) (out []byte, err error)
}

YAMLMarshalUnmarshaler - facade interface for yaml operations.

Jump to

Keyboard shortcuts

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