privilege

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ReadData      = List{GRANT, SELECT}
	ReadWriteData = List{GRANT, SELECT, INSERT, DELETE, UPDATE}
)

Predefined sets of privileges.

View Source
var ByValue = [...]Kind{
	ALL, CREATE, DROP, GRANT, SELECT, INSERT, DELETE, UPDATE,
}

ByValue is just an array of privilege kinds sorted by value.

Functions

This section is empty.

Types

type Kind

type Kind uint32

Kind defines a privilege. This is output by the parser, and used to generate the privilege bitfields in the PrivilegeDescriptor.

const (
	ALL Kind
	CREATE
	DROP
	GRANT
	SELECT
	INSERT
	DELETE
	UPDATE
)

List of privileges. ALL is specifically encoded so that it will automatically pick up new privileges.

func (Kind) Mask

func (k Kind) Mask() uint32

Mask returns the bitmask for a given privilege.

func (Kind) String

func (i Kind) String() string

type List

type List []Kind

List is a list of privileges.

func ListFromBitField

func ListFromBitField(m uint32) List

ListFromBitField takes a bitfield of privileges and returns a list. It is ordered in increasing value of privilege.Kind.

func (List) Format

func (pl List) Format(buf *bytes.Buffer)

Format prints out the list in a buffer. This keeps the existing order and uses ", " as separator.

func (List) Len

func (pl List) Len() int

Len, Swap, and Less implement the Sort interface.

func (List) Less

func (pl List) Less(i, j int) bool

func (List) SortedNames

func (pl List) SortedNames() []string

SortedNames returns a list of privilege names in sorted order.

func (List) SortedString

func (pl List) SortedString() string

SortedString is similar to String() but returns privileges sorted by name and uses "," as separator.

func (List) String

func (pl List) String() string

String implements the Stringer interface. This keeps the existing order and uses ", " as separator.

func (List) Swap

func (pl List) Swap(i, j int)

func (List) ToBitField

func (pl List) ToBitField() uint32

ToBitField returns the bitfield representation of a list of privileges.

type Lists

type Lists []List

Lists is a list of privilege lists

func (Lists) Contains

func (pls Lists) Contains(m uint32) bool

Contains returns whether the list of privilege lists contains exactly the privilege list represented by bitfield m. This intentionally treats ALL and {CREATE, ..., UPDATE} as distinct privilege lists.

func (Lists) String

func (pls Lists) String() string

String stringifies each constituent list of privileges, groups each inside of {} braces, and joins them with " or ".

Examples:

{{SELECT}}.String() -> "{SELECT}"
{{SELECT}, {SELECT, GRANT}}.String() -> "{SELECT} or {SELECT, GRANT}"

Jump to

Keyboard shortcuts

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