web

package
v0.0.0-...-7eda018 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const AlertsKey string = "alerts"

Variables

View Source
var AlertCatalogNotFound = func() Alert {
	return Alert{
		Type:  "danger",
		Title: "Error loading the checks catalog",
		Text:  "Checks catalog couldn't be retrieved",
	}
}

Here some generic alerts

View Source
var AlertConnectionDataNotFound = func() Alert {
	return Alert{
		Type:  "danger",
		Title: "Error loading the connection data",
		Text:  "Connection data couldn't be retrieved.",
	}
}
View Source
var CheckResultsNotFound = func() Alert {
	return Alert{
		Type:  "danger",
		Title: "Error loading the checks result",
		Text:  "Checks result couldn't be retrieved. Check if the Trento runner is running",
	}
}
View Source
var NoCheckSelected = func() Alert {
	return Alert{
		Type:  "info",
		Title: "There is not any check selected",
		Text:  "Select the desired checks in the settings modal in order to validate the cluster configuration",
	}
}

Functions

func ApiCheckCreateSettingsByIdHandler

func ApiCheckCreateSettingsByIdHandler(s services.ChecksService) gin.HandlerFunc

ApiCheckCreateSettingsByIdHandler godoc @Summary Create the check settings @Accept json @Produce json @Param id path string true "Resource id" @Param Body body JSONChecksSettings true "Checks settings" @Success 201 {object} JSONChecksSettings @Failure 500 {object} map[string]string @Router /checks/{id}/settings [post]

func ApiCheckGetSettingsByIdHandler

func ApiCheckGetSettingsByIdHandler(s services.ClustersService) gin.HandlerFunc

ApiCheckGetSettingsByIdHandler godoc @Summary Get the check settings @Accept json @Produce json @Param id path string true "Resource id" @Success 200 {object} JSONChecksSettings @Failure 404 {object} map[string]string @Router /checks/{id}/settings [get]

func ApiChecksCatalogHandler

func ApiChecksCatalogHandler(s services.ChecksService) gin.HandlerFunc

ApiCheckCatalogHandler godoc @Summary Get the whole checks' catalog @Produce json @Success 200 {object} JSONChecksGroupedCatalog @Error 500 @Router /checks/catalog [get]

func ApiClusterCheckResultsHandler

func ApiClusterCheckResultsHandler(s services.ChecksService) gin.HandlerFunc

ApiCheckResultsHandler godoc @Summary Get a specific cluster's check results @Produce json @Param cluster_id path string true "Cluster Id" @Success 200 {object} map[string]interface{} @Failure 500 {object} map[string]string @Router /clusters/{cluster_id}/results [get]

func ApiClusterCreateTagHandler

func ApiClusterCreateTagHandler(clustersService services.ClustersService, tagsService services.TagsService) gin.HandlerFunc

ApiClusterCreateTagHandler godoc @Summary Add tag to Cluster @Accept json @Produce json @Param id path string true "Cluster id" @Param Body body JSONTag true "The tag to create" @Success 201 {object} JSONTag @Failure 404 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /clusters/{id}/tags [post]

func ApiClusterDeleteTagHandler

func ApiClusterDeleteTagHandler(clustersService services.ClustersService, tagsService services.TagsService) gin.HandlerFunc

ApiClusterDeleteTagHandler godoc @Summary Delete a specific tag that belongs to a cluster @Accept json @Produce json @Param id path string true "Cluster id" @Param tag path string true "Tag" @Success 204 {object} map[string]interface{} @Router /clusters/{id}/tags/{tag} [delete]

func ApiCollectDataHandler

func ApiCollectDataHandler(collectorService services.CollectorService) gin.HandlerFunc

ApiCollectDataHandler handles the request to collect agent data from the API

func ApiCreateChecksCatalogHandler

func ApiCreateChecksCatalogHandler(s services.ChecksService) gin.HandlerFunc

ApiCreateChecksCatalogHandler godoc @Summary Create/Updates the checks catalog @Produce json @Param Body body JSONChecksCatalog true "Checks catalog" @Success 200 {object} JSONChecksCatalog @Failure 500 {object} map[string]string @Router /checks/catalog [put]

func ApiCreateChecksResultHandler

func ApiCreateChecksResultHandler(s services.ChecksService) gin.HandlerFunc

ApiCreateChecksResultHandler godoc @Summary Create a checks result entry @Produce json @Param id path string true "Resource Id" @Param Body body JSONChecksResult true "Checks result" @Success 201 {object} JSONChecksResult @Failure 500 {object} map[string]string @Router /checks/{id}/results [post]

func ApiDatabaseCreateTagHandler

func ApiDatabaseCreateTagHandler(sapSystemsService services.SAPSystemsService, tagsService services.TagsService) gin.HandlerFunc

ApiDatabaseCreateTagHandler godoc @Summary Add tag to a HANA database @Accept json @Produce json @Param id path string true "Database id" @Param Body body JSONTag true "The tag to create" @Success 201 {object} JSONTag @Failure 404 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /databases/{id}/tags [post]

func ApiDatabaseDeleteTagHandler

func ApiDatabaseDeleteTagHandler(sapSystemsService services.SAPSystemsService, tagsService services.TagsService) gin.HandlerFunc

ApiDatabaseDeleteTagHandler godoc @Summary Delete a specific tag that belongs to a HANA database @Accept json @Produce json @Param id path string true "Database id" @Param tag path string true "Tag" @Success 204 {object} map[string]interface{} @Router /databases/{id}/tags/{tag} [delete]

func ApiGetClustersSettingsHandler

func ApiGetClustersSettingsHandler(clusters services.ClustersService) gin.HandlerFunc

ApiGetClustersSettingsHandler godoc @Summary Retrieve Settings for all the clusters. Cluster's Selected checks and Hosts connection settings @Accept json @Produce json @Success 200 {object} ClustersSettingsResponse @Failure 500 {object} map[string]string @Router /clusters/settings [get]

func ApiGetPrometheusHttpSdTargets

func ApiGetPrometheusHttpSdTargets(s services.PrometheusService) gin.HandlerFunc

ApiGetPrometheusHttpSdTargets godoc @Summary Get prometheus HTTP SD targets @Produce json @Success 200 {object} TargetsList @Error 500 @Router /prometheus/targets [get]

func ApiHostCreateTagHandler

func ApiHostCreateTagHandler(hostsService services.HostsService, tagsService services.TagsService) gin.HandlerFunc

ApiHostCreateTagHandler godoc @Summary Add tag to host @Accept json @Produce json @Param id path string true "Host id" @Param Body body JSONTag true "The tag to create" @Success 201 {object} JSONTag @Failure 404 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /hosts/{id}/tags [post]

func ApiHostDeleteTagHandler

func ApiHostDeleteTagHandler(hostsService services.HostsService, tagsService services.TagsService) gin.HandlerFunc

ApiHostDeleteTagHandler godoc @Summary Delete a specific tag that belongs to a host @Accept json @Produce json @Param id path string true "Host id" @Param tag path string true "Tag" @Success 204 {object} map[string]interface{} @Router /hosts/{id}/tags/{tag} [delete]

func ApiHostHeartbeatHandler

func ApiHostHeartbeatHandler(hostService services.HostsService) gin.HandlerFunc

func ApiListTag

func ApiListTag(tagsService services.TagsService) gin.HandlerFunc

ApiListTag godoc @Summary List all the tags in the system @Accept json @Produce json @Param resource_type query string false "Filter by resource type" @Success 200 {object} []string @Failure 500 {object} map[string]string @Router /tags [get]

func ApiPingHandler

func ApiPingHandler(c *gin.Context)

func ApiSAPSystemCreateTagHandler

func ApiSAPSystemCreateTagHandler(sapSystemsService services.SAPSystemsService, tagsService services.TagsService) gin.HandlerFunc

ApiSAPSystemCreateTagHandler godoc @Summary Add tag to SAPSystem @Accept json @Produce json @Param id path string true "SAPSystem id" @Param Body body JSONTag true "The tag to create" @Success 201 {object} JSONTag @Failure 404 {object} map[string]string @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /sapsystems/{id}/tags [post]

func ApiSAPSystemDeleteTagHandler

func ApiSAPSystemDeleteTagHandler(sapSystemsService services.SAPSystemsService, tagsService services.TagsService) gin.HandlerFunc

ApiSAPSystemDeleteTagHandler godoc @Summary Delete a specific tag that belongs to a SAPSystem @Accept json @Produce json @Param id path string true "SAPSystem id" @Param tag path string true "Tag" @Success 204 {object} map[string]interface{} @Router /sapsystems/{id}/tags/{tag} [delete]

func ApiSAPSystemsHealthSummaryHandler

func ApiSAPSystemsHealthSummaryHandler(healthSummaryService services.HealthSummaryService) gin.HandlerFunc

ApiSAPSystemsHealthSummaryHandler godoc @Summary Retrieve SAP Systems Health Summary @Accept json @Produce json @Success 200 {object} models.HealthSummary @Failure 500 {object} map[string]string @Router /sapsystems/health [get]

func ErrorHandler

func ErrorHandler(c *gin.Context)

func EulaAcceptHandler

func EulaAcceptHandler(settings services.SettingsService) gin.HandlerFunc

func EulaMiddleware

func EulaMiddleware(premiumDetection services.PremiumDetectionService) gin.HandlerFunc

func EulaShowHandler

func EulaShowHandler() gin.HandlerFunc

func HomeHandler

func HomeHandler(c *gin.Context)

func InitAlerts

func InitAlerts()

func MigrateDB

func MigrateDB(db *gorm.DB) error

func NewChecksCatalogHandler

func NewChecksCatalogHandler(s services.ChecksService) gin.HandlerFunc

func NewClusterHandler

func NewClusterHandler(clusterService services.ClustersService) gin.HandlerFunc

func NewClusterListHandler

func NewClusterListHandler(clustersService services.ClustersService) gin.HandlerFunc

func NewHANADatabaseListHandler

func NewHANADatabaseListHandler(sapSystemsService services.SAPSystemsService) gin.HandlerFunc

func NewHostHandler

func NewHostHandler(hostsService services.HostsService, subsService services.SubscriptionsService, monitoringURL string) gin.HandlerFunc

func NewHostListHandler

func NewHostListHandler(hostsService services.HostsService) gin.HandlerFunc

func NewLogHandler

func NewLogHandler(instance string, logger *log.Logger) gin.HandlerFunc

func NewNamedEngine

func NewNamedEngine(instance string) *gin.Engine

func NewSAPResourceHandler

func NewSAPResourceHandler(hostsService services.HostsService, sapSystemsService services.SAPSystemsService) gin.HandlerFunc

func NewSAPSystemListHandler

func NewSAPSystemListHandler(sapSystemsService services.SAPSystemsService) gin.HandlerFunc

func StoreAlert

func StoreAlert(c *gin.Context, a Alert)

Types

type Alert

type Alert struct {
	Type  string
	Title string
	Text  string
}

func GetAlerts

func GetAlerts(c *gin.Context) []Alert

func (*Alert) GetIcon

func (a *Alert) GetIcon() string

type App

type App struct {
	InstallationID uuid.UUID

	Dependencies
	// contains filtered or unexported fields
}

func NewApp

func NewApp(ctx context.Context, config *Config) (*App, error)

shortcut to use default dependencies

func NewAppWithDeps

func NewAppWithDeps(config *Config, deps Dependencies) (*App, error)

func (*App) Start

func (a *App) Start(ctx context.Context) error

type ClustersSettingsResponse

type ClustersSettingsResponse models.ClustersSettings

type Config

type Config struct {
	Host          string
	Port          int
	CollectorPort int
	EnablemTLS    bool
	Cert          string
	Key           string
	CA            string
	DBConfig      *trentoDB.Config
	GrafanaConfig *grafana.Config
	PrometheusURL string
}

type Dependencies

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

func DefaultDependencies

func DefaultDependencies(ctx context.Context, config *Config) Dependencies

type HealthContainer

type HealthContainer struct {
	PassingCount  int
	WarningCount  int
	CriticalCount int
	Layout        string
}

func NewClustersHealthContainer

func NewClustersHealthContainer(clusterList models.ClusterList) *HealthContainer

func NewHostsHealthContainer

func NewHostsHealthContainer(hostList models.HostList) *HealthContainer

type HomeData

type HomeData struct {
	Title string
}

type HttpError

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

func BadRequestError

func BadRequestError(msg string) *HttpError

func InternalServerError

func InternalServerError(msg string) *HttpError

func NotFoundError

func NotFoundError(msg string) *HttpError

func (*HttpError) Code

func (e *HttpError) Code() int

func (*HttpError) Error

func (e *HttpError) Error() string

func (*HttpError) Template

func (e *HttpError) Template() string

type JSONCheck

type JSONCheck struct {
	ID             string `json:"id,omitempty" binding:"required"`
	Name           string `json:"name,omitempty" binding:"required"`
	Group          string `json:"group,omitempty" binding:"required"`
	Description    string `json:"description,omitempty"`
	Remediation    string `json:"remediation,omitempty"`
	Implementation string `json:"implementation,omitempty"`
	Labels         string `json:"labels,omitempty"`
	Premium        bool   `json:"premium,omitempty"`
}

type JSONCheckResult

type JSONCheckResult struct {
	ID          string                `json:"id,omitempty"`
	Hosts       map[string]*JSONHosts `json:"hosts,omitempty"`
	Group       string                `json:"group,omitempty"`
	Description string                `json:"description,omitempty"`
}

type JSONChecksCatalog

type JSONChecksCatalog []*JSONCheck

type JSONChecksGroup

type JSONChecksGroup struct {
	Group  string          `json:"group"`
	Checks []*models.Check `json:"checks"`
}

type JSONChecksGroupedCatalog

type JSONChecksGroupedCatalog []*JSONChecksGroup

type JSONChecksResult

type JSONChecksResult struct {
	Hosts  map[string]*JSONHosts       `json:"hosts,omitempty" binding:"required"`
	Checks map[string]*JSONCheckResult `json:"checks,omitempty" binding:"required"`
}

type JSONChecksSettings

type JSONChecksSettings struct {
	SelectedChecks     []string          `json:"selected_checks" binding:"required"`
	ConnectionSettings map[string]string `json:"connection_settings" binding:"required"`
	Hostnames          []string          `json:"hostnames"`
}

type JSONHosts

type JSONHosts struct {
	Result    string `json:"result,omitempty"`
	Reachable bool   `json:"reachable,omitempty"`
	Msg       string `json:"msg,omitempty"`
}

type JSONTag

type JSONTag struct {
	Tag string `json:"tag" binding:"required"`
}

type LayoutData

type LayoutData struct {
	Title     string
	Copyright string
	Version   string
	Flavor    string
	Submenu   Submenu
	Content   interface{}
}

type LayoutHTML

type LayoutHTML struct {
	Templates    map[string]*template.Template
	TemplateName string
	Data         interface{}
}

func (LayoutHTML) Render

func (r LayoutHTML) Render(w http.ResponseWriter) error

func (LayoutHTML) RenderErrorPage

func (r LayoutHTML) RenderErrorPage(e *HttpError, w http.ResponseWriter)

func (LayoutHTML) WriteContentType

func (r LayoutHTML) WriteContentType(w http.ResponseWriter)

type LayoutRender

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

LayoutRender wraps user templates into a root one which has it's own data and a bunch of inner blocks

func NewLayoutRender

func NewLayoutRender(templatesFS fs.FS, templates ...string) *LayoutRender

The default constructor expects an FS, some data, and user templates; user templates are the ones that can be referenced by the Gin context.

func (*LayoutRender) Instance

func (r *LayoutRender) Instance(name string, data interface{}) render.Render

Instance returns a render.HTML instance with the associated named Template

type Page

type Page struct {
	Index  int
	Active bool
}

type Pagination

type Pagination struct {
	ItemCount int
	PageIndex int
	PerPage   int
	PageCount int
}

func NewPagination

func NewPagination(items, page, perPage int) *Pagination

func (*Pagination) GetCurrentPages

func (p *Pagination) GetCurrentPages() []*Page

func (*Pagination) GetPerPages

func (p *Pagination) GetPerPages() []int

func (*Pagination) GetSliceNumbers

func (p *Pagination) GetSliceNumbers() (int, int)

Function to get the 1st and last indexes using the current pagination

type Submenu []SubmenuItem
type SubmenuItem struct {
	Label string
	URL   string
}

type Targets

type Targets struct {
	Targets []string          `json:"targets,omitempty"`
	Labels  map[string]string `json:"labels,omitempty"`
}

type TargetsList

type TargetsList []*Targets

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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