config

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: BSD-3-Clause-LBNL Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlertNotificationResource    = "alertnotifications"
	ConnectionPermissionResource = "connections-permissions"
	ConnectionResource           = "connections"
	LegacyConnections            = "datasources"
	DashboardResource            = "dashboards"
	FolderPermissionResource     = "folders-permissions"
	FolderResource               = "folders"
	LibraryElementResource       = "libraryelements"
	OrganizationResource         = "organizations"
	OrganizationMetaResource     = "org"
	TeamResource                 = "teams"
	UserResource                 = "users"
)

Variables

This section is empty.

Functions

func InitConfig

func InitConfig(override, defaultConfig string)

Types

type AppConfig added in v0.4.5

type AppConfig struct {
	ContextName   string                       `mapstructure:"context_name" yaml:"context_name"`
	StorageEngine map[string]map[string]string `mapstructure:"storage_engine" yaml:"storage_engine"`
	Contexts      map[string]*GrafanaConfig    `mapstructure:"contexts" yaml:"contexts"`
	Global        *AppGlobals                  `mapstructure:"global" yaml:"global"`
}

AppConfig is the configuration for the application

func (*AppConfig) GetContext added in v0.4.5

func (app *AppConfig) GetContext() string

func (*AppConfig) GetContextMap added in v0.4.5

func (app *AppConfig) GetContextMap() map[string]interface{}

Temporary function

func (*AppConfig) GetContexts added in v0.4.5

func (app *AppConfig) GetContexts() map[string]*GrafanaConfig

type AppGlobals added in v0.4.5

type AppGlobals struct {
	Debug           bool `mapstructure:"debug" yaml:"debug"`
	IgnoreSSLErrors bool `mapstructure:"ignore_ssl_errors" yaml:"ignore_ssl_errors"`
}

AppGlobals is the global configuration for the application

type Configuration

type Configuration struct {
	AppConfig *AppConfig
	// contains filtered or unexported fields
}

func Config

func Config() *Configuration

func (*Configuration) ChangeContext added in v0.4.5

func (s *Configuration) ChangeContext(name string)

ChangeContext

func (*Configuration) ClearContexts added in v0.4.5

func (s *Configuration) ClearContexts()

func (*Configuration) CopyContext added in v0.4.5

func (s *Configuration) CopyContext(src, dest string)

CopyContext Makes a copy of the specified context and write to disk

func (*Configuration) DeleteContext added in v0.4.5

func (s *Configuration) DeleteContext(name string)

DeleteContext remove a given context

func (*Configuration) GetAppConfig added in v0.4.5

func (s *Configuration) GetAppConfig() *AppConfig

func (*Configuration) GetCloudConfiguration added in v0.4.5

func (s *Configuration) GetCloudConfiguration(configName string) (string, map[string]string)

GetCloudConfiguration Returns storage type and configuration

func (*Configuration) GetContexts added in v0.4.5

func (s *Configuration) GetContexts() map[string]*GrafanaConfig

GetContexts returns map of all contexts

func (*Configuration) GetDefaultGrafanaConfig added in v0.4.5

func (s *Configuration) GetDefaultGrafanaConfig() *GrafanaConfig

GetDefaultGrafanaConfig returns the default aka. selected grafana config

func (*Configuration) IgnoreSSL

func (s *Configuration) IgnoreSSL() bool

IgnoreSSL returns true if SSL errors should be ignored

func (*Configuration) IsDebug

func (s *Configuration) IsDebug() bool

IsDebug returns true if debug mode is enabled

func (*Configuration) NewContext added in v0.4.5

func (s *Configuration) NewContext(name string)

func (*Configuration) PrintContext added in v0.4.5

func (s *Configuration) PrintContext(name string)

func (*Configuration) SaveToDisk added in v0.4.5

func (s *Configuration) SaveToDisk(useViper bool) error

SaveToDisk Persists current configuration to disk

func (*Configuration) ViperConfig

func (s *Configuration) ViperConfig() *viper.Viper

ViperConfig returns the loaded configuration via a viper reference

type ConnectionFilters added in v0.5.0

type ConnectionFilters struct {
	NameExclusions  string   `yaml:"name_exclusions"`
	ConnectionTypes []string `yaml:"valid_types"`
}

ConnectionFilters model wraps connection filters for grafana

type ConnectionSettings added in v0.5.0

type ConnectionSettings struct {
	FilterRules   []MatchingRule     `mapstructure:"exclude_filters" yaml:"exclude_filters,omitempty"`
	MatchingRules []RegexMatchesList `mapstructure:"credential_rules" yaml:"credential_rules,omitempty"`
}

ConnectionSettings contains Filters and Matching Rules for Grafana

func (*ConnectionSettings) FiltersEnabled added in v0.5.0

func (ds *ConnectionSettings) FiltersEnabled() bool

FiltersEnabled returns true if the filters are enabled for the resource type

func (*ConnectionSettings) GetCredentials added in v0.5.0

func (ds *ConnectionSettings) GetCredentials(connectionEntity models.AddDataSourceCommand) (*GrafanaConnection, error)

GetCredentials returns the credentials for the connection

func (*ConnectionSettings) IsExcluded added in v0.5.0

func (ds *ConnectionSettings) IsExcluded(item interface{}) bool

IsExcluded returns true if the item should be excluded from the connection List

type CredentialRule

type CredentialRule struct {
	RegexMatchesList
	Auth *GrafanaConnection `mapstructure:"auth" yaml:"auth,omitempty"`
}

CredentialRule model wraps regex and auth for grafana

type FilterOverrides

type FilterOverrides struct {
	IgnoreDashboardFilters bool `yaml:"ignore_dashboard_filters"`
}

FilterOverrides model wraps filter overrides for grafana

type GrafanaConfig

type GrafanaConfig struct {
	Storage string `mapstructure:"storage" yaml:"storage"`

	EnterpriseSupport        bool                  `mapstructure:"enterprise_support" yaml:"enterprise_support"`
	URL                      string                `mapstructure:"url" yaml:"url"`
	APIToken                 string                `mapstructure:"token" yaml:"token"`
	UserName                 string                `mapstructure:"user_name" yaml:"user_name"`
	Password                 string                `mapstructure:"password" yaml:"password"`
	OrganizationId           int64                 `mapstructure:"organization_id" yaml:"organization_id"`
	MonitoredFoldersOverride []MonitoredOrgFolders `mapstructure:"watched_folders_override" yaml:"watched_folders_override"`
	MonitoredFolders         []string              `mapstructure:"watched" yaml:"watched"`
	DataSourceSettings       *ConnectionSettings   `mapstructure:"connections" yaml:"connections"`
	//Datasources are deprecated, please use Connections
	LegacyConnectionSettings map[string]interface{} `mapstructure:"datasources" yaml:"datasources"`
	FilterOverrides          *FilterOverrides       `mapstructure:"filter_override" yaml:"filter_override"`
	OutputPath               string                 `mapstructure:"output_path" yaml:"output_path"`
	// contains filtered or unexported fields
}

GrafanaConfig model wraps auth and watched list for grafana

func (*GrafanaConfig) GetAlertNotificationOutput

func (s *GrafanaConfig) GetAlertNotificationOutput() string

func (*GrafanaConfig) GetCredentials

func (s *GrafanaConfig) GetCredentials(dataSourceName models.AddDataSourceCommand) (*GrafanaConnection, error)

GetCredentials return credentials for a given datasource or falls back on default value

func (*GrafanaConfig) GetDashboardOutput

func (s *GrafanaConfig) GetDashboardOutput() string

GetDashboardOutput returns the path of the dashboards output

func (*GrafanaConfig) GetDataSourceOutput

func (s *GrafanaConfig) GetDataSourceOutput() string

func (*GrafanaConfig) GetDataSourceSettings

func (s *GrafanaConfig) GetDataSourceSettings() *ConnectionSettings

GetDataSourceSettings returns the datasource settings for the connection

func (*GrafanaConfig) GetFilterOverrides

func (s *GrafanaConfig) GetFilterOverrides() *FilterOverrides

GetFilterOverrides returns the filter overrides for the connection

func (*GrafanaConfig) GetFolderOutput

func (s *GrafanaConfig) GetFolderOutput() string

func (*GrafanaConfig) GetMonitoredFolders

func (s *GrafanaConfig) GetMonitoredFolders() []string

GetMonitoredFolders return a list of the monitored folders alternatively returns the "General" folder.

func (*GrafanaConfig) GetOrgMonitoredFolders added in v0.5.1

func (s *GrafanaConfig) GetOrgMonitoredFolders(orgId int64) []string

GetOrgMonitoredFolders return the OrganizationMonitoredFolders that override a given Org

func (*GrafanaConfig) GetOrganizationId added in v0.5.0

func (s *GrafanaConfig) GetOrganizationId() int64

GetOrganizationId returns the id of the organization (defaults to 1 if unset)

func (*GrafanaConfig) GetPath

func (s *GrafanaConfig) GetPath(r ResourceType) string

GetPath returns the path of the resource type

func (*GrafanaConfig) GetTeamOutput

func (s *GrafanaConfig) GetTeamOutput() string

func (*GrafanaConfig) GetUserOutput

func (s *GrafanaConfig) GetUserOutput() string

func (*GrafanaConfig) IsAdminEnabled added in v0.5.0

func (s *GrafanaConfig) IsAdminEnabled() bool

IsAdminEnabled returns true if the admin is set, represents a GrafanaAdmin

func (*GrafanaConfig) IsBasicAuth added in v0.5.0

func (s *GrafanaConfig) IsBasicAuth() bool

IsBasicAuth returns true if user has basic auth enabled

func (*GrafanaConfig) IsEnterprise added in v0.5.0

func (s *GrafanaConfig) IsEnterprise() bool

IsEnterprise Returns true when enterprise is enabled

func (*GrafanaConfig) SetAdmin added in v0.5.0

func (s *GrafanaConfig) SetAdmin(admin bool)

SetAdmin sets true if user has admin permissions

func (*GrafanaConfig) Validate added in v0.5.0

func (s *GrafanaConfig) Validate()

Validate will return terminate if any deprecated configuration is found.

type GrafanaConnection added in v0.5.0

type GrafanaConnection struct {
	User     string `yaml:"user"`
	Password string `yaml:"password"`
}

GrafanaConnection Default connection credentials

type MatchingRule

type MatchingRule struct {
	Field     string `yaml:"field,omitempty"`
	Regex     string `yaml:"regex,omitempty"`
	Inclusive bool   `yaml:"inclusive,omitempty"`
}

MatchingRule defines a single matching rule for Grafana Connections

type MonitoredOrgFolders added in v0.5.1

type MonitoredOrgFolders struct {
	OrganizationId int64    `json:"organization_id" yaml:"organization_id"`
	Folders        []string `json:"folders" yaml:"folders"`
}

type RegexMatchesList

type RegexMatchesList struct {
	Rules []MatchingRule     `mapstructure:"rules" yaml:"rules,omitempty"`
	Auth  *GrafanaConnection `mapstructure:"auth" yaml:"auth,omitempty"`
}

RegexMatchesList model wraps regex matches list for grafana

type ResourceType

type ResourceType string

func (*ResourceType) GetPath

func (s *ResourceType) GetPath(basePath string) string

GetPath returns the path of the resource type, if Namespaced, will delimit the path by org Id

func (*ResourceType) String

func (s *ResourceType) String() string

String returns the string representation of the resource type

Jump to

Keyboard shortcuts

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