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 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.