contracts

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: AGPL-3.0 Imports: 14 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

	SetMetrics(Metrics)
	Metrics() Metrics

	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) error
	ReleaseAllKubeClient() error
	LoadKubeClient(name string, kubeConfig []byte) (*K8sClient, error)
}

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

type Metrics interface {
	IncWebsocketConn()
	DecWebsocketConn()
}

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 Option

type Option func(ApplicationInterface)

type PluginInterface

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

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)
	AllDirectoryFiles(dir string) ([]FileInfo, error)
	RemoveEmptyDir(dir string) error
}

type UserInfo

type UserInfo struct {
	LogoutUrl string   `json:"logout_url"`
	Roles     []string `json:"roles"`

	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