contracts

package
v0.0.86 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const Expired = 8 * time.Hour

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationInterface

type ApplicationInterface interface {
	IsDebug() bool

	Auth() AuthInterface
	SetAuth(AuthInterface)

	SetUploader(Uploader)
	Uploader() Uploader

	Bootstrap() error
	Config() *config.Config

	DBManager() DBManager

	Oidc() OidcConfig
	SetOidc(OidcConfig)

	AddServer(Server)
	Run() context.Context
	Shutdown()

	Done() <-chan struct{}

	BeforeServerRunHooks(Callback)
	RegisterBeforeShutdownFunc(Callback)
	RegisterAfterShutdownFunc(Callback)

	EventDispatcher() DispatcherInterface
	SetEventDispatcher(DispatcherInterface)

	SetPlugins(map[string]PluginInterface)
	GetPlugins() map[string]PluginInterface
	GetPluginByName(string) PluginInterface

	ReleaseKubeClient(name string, namespace string) error
	ReleaseAllKubeClient() error
	LoadKubeClient(name string, kubeConfig []byte, namespace string) (K8s, error)

	ProxyManager() ProxyManagerInterface
	SetProxyManager(ProxyManagerInterface)
}

type AuthInterface

type AuthInterface interface {
	VerifyToken(string) (*JwtClaims, bool)
	Sign(*UserInfo) (*SignData, error)
}

type AuthorizeInterface

type AuthorizeInterface interface {
	Authorize(ctx context.Context, fullMethodName string) (context.Context, error)
}

type Bootstrapper

type Bootstrapper interface {
	Bootstrap(ApplicationInterface) error
}

type Callback

type Callback func(ApplicationInterface)

type ClaimUserInfo added in v0.0.59

type ClaimUserInfo struct {
	LogoutUrl string `json:"logout_url"`
	OpenIDClaims
}

func (ClaimUserInfo) ToUserInfo added in v0.0.59

func (c ClaimUserInfo) ToUserInfo() UserInfo

type DBManager

type DBManager interface {
	DB() *gorm.DB
	SetDB(*gorm.DB)

	AutoMigrate(dst ...any) error
}

type DispatcherInterface

type DispatcherInterface interface {
	// Listen Register an event listener with the dispatcher.
	Listen(Event, Listener)

	// HasListeners Determine if a given event has listeners.
	HasListeners(Event) bool

	// Dispatch Fire an event and call the listeners.
	Dispatch(Event, any) error

	// Forget Remove a set of listeners from the dispatcher.
	Forget(Event)

	GetListeners(Event) []Listener
}

type Event

type Event string

func (Event) Is

func (e Event) Is(event Event) bool

func (Event) String

func (e Event) String() string

type FileInfo

type FileInfo interface {
	Path() string
	Size() uint64
}

type JwtClaims

type JwtClaims struct {
	*jwt.StandardClaims
	*UserInfo
}

type K8s added in v0.0.10

type K8s interface {
	Client() kubernetes.Interface
	MetricsClient() versioned.Interface
	RestConfig() *restclient.Config
	Informer() informers.SharedInformerFactory
	Done() chan struct{}
	PodLister() v1.PodLister
	PodListerSynced() func() bool
	DeploymentLister() appsv1.DeploymentLister
	DeploymentListerSynced() func() bool
	StatefulSetLister() appsv1.StatefulSetLister
	StatefulSetListerSynced() func() bool
	JobLister() corev1.JobLister
}

type K8sClient

type K8sClient struct {
	Client                  kubernetes.Interface
	MetricsClient           versioned.Interface
	RestConfig              *restclient.Config
	Informer                informers.SharedInformerFactory
	Done                    chan struct{}
	PodLister               v1.PodLister
	PodListerSynced         func() bool
	DeploymentLister        appsv1.DeploymentLister
	DeploymentListerSynced  func() bool
	StatefulSetLister       appsv1.StatefulSetLister
	StatefulSetListerSynced func() bool
}

type Listener

type Listener func(any, Event) error

type LoggerInterface

type LoggerInterface interface {
	Debug(v ...any)
	Debugf(format string, v ...any)
	Warning(v ...any)
	Warningf(format string, v ...any)
	Info(v ...any)
	Infof(format string, v ...any)
	Error(v ...any)
	Errorf(format string, v ...any)
	Fatal(v ...any)
	Fatalf(format string, v ...any)
}

type OidcConfig

type OidcConfig map[string]OidcConfigItem

type OidcConfigItem

type OidcConfigItem struct {
	Provider           *oidc.Provider
	Config             oauth2.Config
	EndSessionEndpoint string
}

type OpenIDClaims

type OpenIDClaims struct {
	Sub                 string         `json:"sub"`
	Name                string         `json:"name"`
	GivenName           string         `json:"given_name"`
	FamilyName          string         `json:"family_name"`
	MiddleName          string         `json:"middle_name"`
	Nickname            string         `json:"nickname"`
	PreferredUsername   string         `json:"preferred_username"`
	Profile             string         `json:"profile"`
	Picture             string         `json:"picture"`
	Website             string         `json:"website"`
	Email               string         `json:"email"`
	EmailVerified       bool           `json:"email_verified"`
	Gender              string         `json:"gender"`
	Birthdate           string         `json:"birthdate"`
	Zoneinfo            string         `json:"zoneinfo"`
	Locale              string         `json:"locale"`
	PhoneNumber         string         `json:"phone_number"`
	PhoneNumberVerified bool           `json:"phone_number_verified"`
	Address             map[string]any `json:"address"`
	UpdatedAt           int            `json:"updated_at"`
}

type PluginInterface

type PluginInterface interface {
	Name() string
	Initialize(args map[string]any) error
	Destroy() error
}

type ProxyManagerInterface added in v0.0.56

type ProxyManagerInterface interface {
	Add(ProxyPod) (string, bool, error)
	GetPortByID(id string) (string, error)

	Visit(id string)
	Check()
	CloseAll() error
}

type ProxyPod added in v0.0.56

type ProxyPod struct {
	ClusterId int64
	Namespace string
	Pod       string
	Port      string
}

func (ProxyPod) Url added in v0.0.56

func (p ProxyPod) Url() string

type Server

type Server interface {
	Run(context.Context) error
	Shutdown(context.Context) error
}

type SignData

type SignData struct {
	Token     string
	ExpiredIn int64
}

type Uploader

type Uploader interface {
	Disk(string) Uploader
	DeleteDir(dir string) error
	DirSize(dir string) (int64, error)
	Delete(path string) error
	Exists(path string) bool
	MkDir(path string, recursive bool) error
	AbsolutePath(path string) string
	Put(path string, content io.Reader) (FileInfo, error)
	NewFile(path string) (*os.File, error)
	AllDirectoryFiles(dir string) ([]FileInfo, error)
	RemoveEmptyDir(dir string) error
}

type UserInfo

type UserInfo struct {
	LogoutUrl   string             `json:"logout_url"`
	Roles       []string           `json:"roles"`
	Permissions []*auth.Permission `json:"permissions"`

	OpenIDClaims
}

func (UserInfo) GetID

func (ui UserInfo) GetID() string

func (UserInfo) IsAdmin

func (ui UserInfo) IsAdmin() bool

Jump to

Keyboard shortcuts

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