admin

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHTTPClientCreation = errors.New("failed to create http over uds client")
	ErrMakingRequest      = errors.New("failed to make a request")
	ErrStatusCodeNotOK    = errors.New("failed to get a response with a valid status code")
	ErrDecodingResponse   = errors.New("error while decoding a (assumed) json response")
	ErrMarshalingPayload  = errors.New("error while marshalling the payload")
)
View Source
var (
	// ErrSocketStillResponding refers to when
	// a) an instance of the server is still running normally; or
	// b) server was not closed properly
	ErrSocketStillResponding = errors.New("a server is still running and responding to socket")
	// ErrInvalidSocketPathname refers to when the socket filepath is obviously invalid (eg empty string)
	ErrInvalidSocketPathname = errors.New("the socket filepath is invalid")
	// ErrListenerBind refers to generic errors
	ErrListenerBind = errors.New("could not listen on socket")

	// Anything works here
	SocketHTTPAddress = "http://pyroscope"
	HealthAddress     = SocketHTTPAddress + "/health"
)

Functions

func NewHTTPOverUDSClient

func NewHTTPOverUDSClient(socketAddr string, opts ...ClientOption) (*http.Client, error)

NewHTTPOverUDSClient creates a http client that communicates via UDS (unix domain sockets)

Types

type AppNames

type AppNames []string

type ApplicationListerAndDeleter added in v0.34.1

type ApplicationListerAndDeleter interface {
	List(ctx context.Context) (apps []appmetadata.ApplicationMetadata, err error)
	Delete(ctx context.Context, name string) error
}

type CLI

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

func NewCLI

func NewCLI(socketPath string, timeout time.Duration) (*CLI, error)

func (*CLI) CleanupStorage added in v0.12.0

func (c *CLI) CleanupStorage() error

func (*CLI) CompleteApp

func (c *CLI) CompleteApp(_ string) (appNames []string, err error)

CompleteApp returns the list of apps it's meant for cobra's autocompletion TODO use the parameter for fuzzy search?

func (*CLI) DeleteApp

func (c *CLI) DeleteApp(appname string, skipVerification bool) error

DeleteApp deletes an app if a matching app exists

func (*CLI) GetAppsNames

func (c *CLI) GetAppsNames() error

GetAppsNames returns the list of all apps

func (*CLI) ResetUserPassword added in v0.10.0

func (c *CLI) ResetUserPassword(username, password string, enable bool) error

type CLIError

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

func (CLIError) Error

func (e CLIError) Error() string

type Client

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

func NewClient

func NewClient(socketAddr string, timeout time.Duration) (*Client, error)

func (*Client) CleanupStorage added in v0.12.0

func (c *Client) CleanupStorage() error

func (*Client) DeleteApp

func (c *Client) DeleteApp(name string) (err error)

func (*Client) GetAppsNames

func (c *Client) GetAppsNames() (names AppNames, err error)

func (*Client) ResetUserPassword added in v0.10.0

func (c *Client) ResetUserPassword(username, password string, enable bool) error

type ClientOption

type ClientOption func(*http.Client)

func WithTimeout

func WithTimeout(d time.Duration) ClientOption

type Controller

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

func NewController

func NewController(
	log *logrus.Logger,
	appService ApplicationListerAndDeleter,
	userService UserService,
	storageService StorageService) *Controller

func (*Controller) StorageCleanupHandler added in v0.12.0

func (ctrl *Controller) StorageCleanupHandler(w http.ResponseWriter, r *http.Request)

func (*Controller) UpdateUserHandler added in v0.10.0

func (ctrl *Controller) UpdateUserHandler(w http.ResponseWriter, r *http.Request)

type HTTPClient

type HTTPClient interface {
	Get(url string) (resp *http.Response, err error)
}

type HTTPServer

type HTTPServer interface {
	Start(http.Handler) error
	Stop() error
}

type Server

type Server struct {
	Handler http.Handler

	HTTPServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(logger *logrus.Logger, ctrl *Controller, httpServer HTTPServer) (*Server, error)

NewServer creates an AdminServer and returns an error Is also does basic verifications: - Checks if the SocketAddress is non empty

func (*Server) Start

func (as *Server) Start() error

func (*Server) Stop

func (as *Server) Stop() error

type StorageService added in v0.12.0

type StorageService interface {
	Cleanup(ctx context.Context) error
}

type UdsHTTPServer

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

func NewUdsHTTPServer

func NewUdsHTTPServer(socketAddr string, httpClient HTTPClient) (*UdsHTTPServer, error)

NewUdsHTTPServer creates a http server that responds over UDS (unix domain socket)

func (*UdsHTTPServer) Start

func (u *UdsHTTPServer) Start(handler http.Handler) error

func (*UdsHTTPServer) Stop

func (u *UdsHTTPServer) Stop() error

type UpdateUserRequest added in v0.10.0

type UpdateUserRequest struct {
	Password   *string `json:"password"`
	IsDisabled *bool   `json:"isDisabled"`
}

func (*UpdateUserRequest) SetIsDisabled added in v0.10.0

func (r *UpdateUserRequest) SetIsDisabled(v bool)

type UserService added in v0.10.0

type UserService interface {
	UpdateUserByName(ctx context.Context, name string, params model.UpdateUserParams) (model.User, error)
}

Jump to

Keyboard shortcuts

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