admin

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 18 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 AdminService

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

func NewService

func NewService(v Storage) *AdminService

func (*AdminService) DeleteApp

func (m *AdminService) DeleteApp(appname string) error

func (*AdminService) GetApps

func (m *AdminService) GetApps() (appNames []string)

type AppNames

type AppNames []string

type CLI

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

func NewCLI

func NewCLI(socketPath string, timeout time.Duration) (*CLI, 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) 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, adminService *AdminService, userService UserService) *Controller

func (*Controller) HandleDeleteApp

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

HandleDeleteApp handles DELETE requests

func (*Controller) HandleGetApps

func (ctrl *Controller) HandleGetApps(w http.ResponseWriter, _ *http.Request)

HandleGetApps handles GET requests

func (*Controller) UpdateUserHandler added in v0.10.0

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

type DeleteAppInput

type DeleteAppInput struct {
	Name string `json:"name"`
}

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 Storage

type Storage interface {
	GetAppNames() []string
	DeleteApp(appname string) 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