cgroups

package
v0.0.0-...-7578c0e Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const OptionsResource = "client_groups"

Variables

View Source
var OptionsListDefaultFields = map[string][]string{
	fmt.Sprintf("fields[%s]", OptionsResource): {
		"id",
		"description",
	},
}
View Source
var OptionsListDefaultSort = map[string][]string{
	"sort": {"id"},
}
View Source
var OptionsSupportedFields = map[string]map[string]bool{
	OptionsResource: {
		"id":                    true,
		"description":           true,
		"params":                true,
		"allowed_user_groups":   true,
		"client_ids":            true,
		"num_clients":           true,
		"num_clients_connected": true,
	},
}
View Source
var OptionsSupportedFiltersAndSorts = map[string]bool{
	"id":          true,
	"description": true,
}

Functions

func MatchesRawTags

func MatchesRawTags(p *json.RawMessage, values []string) bool

func ParseTag

func ParseTag(p *json.RawMessage) (string, []string, error)

Types

type ClientGroup

type ClientGroup struct {
	ID                string            `json:"id" db:"id"`
	Description       string            `json:"description" db:"description"`
	Params            *ClientParams     `json:"params" db:"params"`
	AllowedUserGroups types.StringSlice `json:"allowed_user_groups" db:"allowed_user_groups"`
	// ClientIDs shows what clients belong to a given group. Note: it's populated separately.
	ClientIDs []string `json:"client_ids" db:"-"`
}

func (*ClientGroup) OneOfUserGroupsIsAllowed

func (g *ClientGroup) OneOfUserGroupsIsAllowed(userGroups []string) bool

func (*ClientGroup) UserGroupIsAllowed

func (g *ClientGroup) UserGroupIsAllowed(requiredUserGroup string) bool

type ClientGroupProvider

type ClientGroupProvider interface {
	Get(ctx context.Context, id string) (*ClientGroup, error)
	GetAll(ctx context.Context) ([]*ClientGroup, error)
	List(ctx context.Context, options *query.ListOptions) ([]*ClientGroup, error)
	Create(ctx context.Context, group *ClientGroup) error
	Update(ctx context.Context, group *ClientGroup) error
	Delete(ctx context.Context, id string) error
	Close() error
}

type ClientParams

type ClientParams struct {
	ClientID        *ParamValues     `json:"client_id"`
	Name            *ParamValues     `json:"name"`
	OS              *ParamValues     `json:"os"`
	OSArch          *ParamValues     `json:"os_arch"`
	OSFamily        *ParamValues     `json:"os_family"`
	OSKernel        *ParamValues     `json:"os_kernel"`
	Hostname        *ParamValues     `json:"hostname"`
	IPv4            *ParamValues     `json:"ipv4"`
	IPv6            *ParamValues     `json:"ipv6"`
	Tag             *json.RawMessage `json:"tag"`
	Version         *ParamValues     `json:"version"`
	Address         *ParamValues     `json:"address"`
	ClientAuthID    *ParamValues     `json:"client_auth_id"`
	ConnectionState *ParamValues     `json:"connection_state"`
}

func (*ClientParams) HasNoParams

func (p *ClientParams) HasNoParams() bool

func (*ClientParams) Scan

func (p *ClientParams) Scan(value interface{}) error

func (*ClientParams) Value

func (p *ClientParams) Value() (driver.Value, error)

type Param

type Param string

type ParamValues

type ParamValues []Param

func (*ParamValues) MatchesOneOf

func (p *ParamValues) MatchesOneOf(values ...string) bool

type SqliteProvider

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

func NewSqliteProvider

func NewSqliteProvider(db *sqlx.DB) (*SqliteProvider, error)

func (*SqliteProvider) Close

func (p *SqliteProvider) Close() error

func (*SqliteProvider) Create

func (p *SqliteProvider) Create(ctx context.Context, group *ClientGroup) error

func (*SqliteProvider) Delete

func (p *SqliteProvider) Delete(ctx context.Context, id string) error

func (*SqliteProvider) Get

func (p *SqliteProvider) Get(ctx context.Context, id string) (*ClientGroup, error)

func (*SqliteProvider) GetAll

func (p *SqliteProvider) GetAll(ctx context.Context) ([]*ClientGroup, error)

func (*SqliteProvider) List

func (p *SqliteProvider) List(ctx context.Context, options *query.ListOptions) ([]*ClientGroup, error)

func (*SqliteProvider) Update

func (p *SqliteProvider) Update(ctx context.Context, group *ClientGroup) error

Jump to

Keyboard shortcuts

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