model

package
v2.2.12 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const Highest = 0
View Source
const Lowest = 1

Variables

This section is empty.

Functions

func SyncConfig

func SyncConfig(resourceName string, b Backend, configResources, backendResources map[string]UserGroup) error

Types

type Backend

type Backend interface {
	// Getter
	FindUserByID(int) (map[string]UserGroup, error)
	FindUserByName(string) (map[string]UserGroup, error)
	FindGroupByID(int) (map[string]UserGroup, error)
	FindGroupByName(string) (map[string]UserGroup, error)
	Users() (map[string]UserGroup, error)
	Groups() (map[string]UserGroup, error)
	HighestUserID() int
	LowestUserID() int
	HighestGroupID() int
	LowestGroupID() int

	// Setter
	CreateUser(UserGroup) error
	DeleteUser(int) error
	UpdateUser(UserGroup) error
	CreateGroup(UserGroup) error
	DeleteGroup(int) error
	UpdateGroup(UserGroup) error
}

func NewBackendDummy

func NewBackendDummy() (Backend, error)

func NewBackendNil

func NewBackendNil() (Backend, error)

type BackendDummy

type BackendDummy struct {
}

func (BackendDummy) CreateGroup

func (b BackendDummy) CreateGroup(v UserGroup) error

func (BackendDummy) CreateUser

func (b BackendDummy) CreateUser(v UserGroup) error

func (BackendDummy) DeleteGroup

func (b BackendDummy) DeleteGroup(id int) error

func (BackendDummy) DeleteUser

func (b BackendDummy) DeleteUser(id int) error

func (BackendDummy) FindGroupByID

func (b BackendDummy) FindGroupByID(id int) (map[string]UserGroup, error)

func (BackendDummy) FindGroupByName

func (b BackendDummy) FindGroupByName(name string) (map[string]UserGroup, error)

func (BackendDummy) FindUserByID

func (b BackendDummy) FindUserByID(id int) (map[string]UserGroup, error)

func (BackendDummy) FindUserByName

func (b BackendDummy) FindUserByName(name string) (map[string]UserGroup, error)

func (BackendDummy) Groups

func (b BackendDummy) Groups() (map[string]UserGroup, error)

func (BackendDummy) HighestGroupID

func (b BackendDummy) HighestGroupID() int

func (BackendDummy) HighestUserID

func (b BackendDummy) HighestUserID() int

func (BackendDummy) LowestGroupID

func (b BackendDummy) LowestGroupID() int

func (BackendDummy) LowestUserID

func (b BackendDummy) LowestUserID() int

func (BackendDummy) UpdateGroup

func (b BackendDummy) UpdateGroup(v UserGroup) error

func (BackendDummy) UpdateUser

func (b BackendDummy) UpdateUser(v UserGroup) error

func (BackendDummy) Users

func (b BackendDummy) Users() (map[string]UserGroup, error)

type BackendNil

type BackendNil struct {
}

func (BackendNil) CreateGroup

func (b BackendNil) CreateGroup(v UserGroup) error

func (BackendNil) CreateUser

func (b BackendNil) CreateUser(v UserGroup) error

func (BackendNil) DeleteGroup

func (b BackendNil) DeleteGroup(id int) error

func (BackendNil) DeleteUser

func (b BackendNil) DeleteUser(id int) error

func (BackendNil) FindGroupByID

func (b BackendNil) FindGroupByID(id int) (map[string]UserGroup, error)

func (BackendNil) FindGroupByName

func (b BackendNil) FindGroupByName(name string) (map[string]UserGroup, error)

func (BackendNil) FindUserByID

func (b BackendNil) FindUserByID(id int) (map[string]UserGroup, error)

func (BackendNil) FindUserByName

func (b BackendNil) FindUserByName(name string) (map[string]UserGroup, error)

func (BackendNil) Groups

func (b BackendNil) Groups() (map[string]UserGroup, error)

func (BackendNil) HighestGroupID

func (b BackendNil) HighestGroupID() int

func (BackendNil) HighestUserID

func (b BackendNil) HighestUserID() int

func (BackendNil) LowestGroupID

func (b BackendNil) LowestGroupID() int

func (BackendNil) LowestUserID

func (b BackendNil) LowestUserID() int

func (BackendNil) UpdateGroup

func (b BackendNil) UpdateGroup(v UserGroup) error

func (BackendNil) UpdateUser

func (b BackendNil) UpdateUser(v UserGroup) error

func (BackendNil) Users

func (b BackendNil) Users() (map[string]UserGroup, error)

type BackendRedis

type BackendRedis struct {
	*redis.Client
	// contains filtered or unexported fields
}

func NewBackendRedis

func NewBackendRedis(b Backend, logger *log.Logger, host string, port int, password string, ttl int, db int) (*BackendRedis, error)

func (*BackendRedis) CreateGroup

func (b *BackendRedis) CreateGroup(u UserGroup) error

func (*BackendRedis) CreateUser

func (b *BackendRedis) CreateUser(u UserGroup) error

func (*BackendRedis) DelCache

func (b *BackendRedis) DelCache(key string)

func (*BackendRedis) DeleteGroup

func (b *BackendRedis) DeleteGroup(id int) error

func (*BackendRedis) DeleteUser

func (b *BackendRedis) DeleteUser(id int) error

func (*BackendRedis) FindGroupByID

func (b *BackendRedis) FindGroupByID(id int) (map[string]UserGroup, error)

func (*BackendRedis) FindGroupByName

func (b *BackendRedis) FindGroupByName(name string) (map[string]UserGroup, error)

func (*BackendRedis) FindUserByID

func (b *BackendRedis) FindUserByID(id int) (map[string]UserGroup, error)

func (*BackendRedis) FindUserByName

func (b *BackendRedis) FindUserByName(name string) (map[string]UserGroup, error)

func (*BackendRedis) GetCache

func (b *BackendRedis) GetCache(key string) string

func (*BackendRedis) Groups

func (b *BackendRedis) Groups() (map[string]UserGroup, error)

func (*BackendRedis) HighestGroupID

func (b *BackendRedis) HighestGroupID() int

func (*BackendRedis) HighestUserID

func (b *BackendRedis) HighestUserID() int

func (*BackendRedis) LowestGroupID

func (b *BackendRedis) LowestGroupID() int

func (*BackendRedis) LowestUserID

func (b *BackendRedis) LowestUserID() int

func (*BackendRedis) SetCache

func (b *BackendRedis) SetCache(key string, src interface{})

func (*BackendRedis) UpdateGroup

func (b *BackendRedis) UpdateGroup(us UserGroup) error

func (*BackendRedis) UpdateUser

func (b *BackendRedis) UpdateUser(us UserGroup) error

func (*BackendRedis) Users

func (b *BackendRedis) Users() (map[string]UserGroup, error)

type BackendTomlFile

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

func NewBackendTomlFile

func NewBackendTomlFile(u *Users, g *Groups) (*BackendTomlFile, error)

func (BackendTomlFile) CreateGroup

func (t BackendTomlFile) CreateGroup(UserGroup) error

func (BackendTomlFile) CreateUser

func (t BackendTomlFile) CreateUser(UserGroup) error

func (BackendTomlFile) DeleteGroup

func (t BackendTomlFile) DeleteGroup(int) error

func (BackendTomlFile) DeleteUser

func (t BackendTomlFile) DeleteUser(int) error

func (BackendTomlFile) FindGroupByID

func (t BackendTomlFile) FindGroupByID(id int) (map[string]UserGroup, error)

func (BackendTomlFile) FindGroupByName

func (t BackendTomlFile) FindGroupByName(name string) (map[string]UserGroup, error)

func (BackendTomlFile) FindUserByID

func (t BackendTomlFile) FindUserByID(id int) (map[string]UserGroup, error)

func (BackendTomlFile) FindUserByName

func (t BackendTomlFile) FindUserByName(name string) (map[string]UserGroup, error)

func (BackendTomlFile) Groups

func (t BackendTomlFile) Groups() (map[string]UserGroup, error)

func (BackendTomlFile) HighestGroupID

func (t BackendTomlFile) HighestGroupID() int

func (BackendTomlFile) HighestUserID

func (t BackendTomlFile) HighestUserID() int

func (BackendTomlFile) LowestGroupID

func (t BackendTomlFile) LowestGroupID() int

func (BackendTomlFile) LowestUserID

func (t BackendTomlFile) LowestUserID() int

func (BackendTomlFile) UpdateGroup

func (t BackendTomlFile) UpdateGroup(UserGroup) error

func (BackendTomlFile) UpdateUser

func (t BackendTomlFile) UpdateUser(UserGroup) error

func (BackendTomlFile) Users

func (t BackendTomlFile) Users() (map[string]UserGroup, error)

type Base

type Base struct {
	ID   int    `toml:"id" json:"id" yaml:"id" validate:"required,gte=0"`
	Name string `toml:"name" json:"name" yaml:"name" validate:"required"`
}

func (*Base) GetID

func (b *Base) GetID() int

func (*Base) GetName

func (b *Base) GetName() string

type Group

type Group struct {
	Base       `yaml:",inline"`
	Users      []string `toml:"users" json:"users"`
	LinkGroups []string `toml:"link_groups" yaml:"link_groups" json:"-"`
}

type Groups

type Groups map[string]*Group

func (*Groups) ToUserGroup

func (gs *Groups) ToUserGroup() map[string]UserGroup

type NotFoundError

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

func NewNotFoundError

func NewNotFoundError(r string, v interface{}) NotFoundError

func (NotFoundError) Error

func (e NotFoundError) Error() string

type User

type User struct {
	Base      `yaml:",inline"`
	Password  string   `toml:"password" yaml:"password" json:"password"`
	GroupID   int      `toml:"group_id" yaml:"group_id" json:"group_id"`
	Directory string   `toml:"directory" yaml:"directory" json:"directory"`
	Shell     string   `toml:"shell" yaml:"shell" json:"shell"`
	Gecos     string   `toml:"gecos" yaml:"gecos" json:"gecos"`
	Keys      []string `toml:"keys" yaml:"keys" json:"keys"`
	LinkUsers []string `toml:"link_users" yaml:"link_users" json:"-"`
}

type UserGroup

type UserGroup interface {
	GetID() int
	GetName() string
	// contains filtered or unexported methods
}

type Users

type Users map[string]*User

func (*Users) ToUserGroup

func (us *Users) ToUserGroup() map[string]UserGroup

Jump to

Keyboard shortcuts

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