config

package
v0.4.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	UserResource              = "users"
	TeamResource              = "teams"
	DashboardResource         = "dashboards"
	DataSourceResource        = "datasources"
	FolderResource            = "folders"
	FolderPermissionResource  = "folders-permissions"
	AlertNotificationResource = "alertnotifications"
	LibraryElementResource    = "libraryelements"
)

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"`
}

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"`
}

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 CredentialRule

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

type DataSourceFilters

type DataSourceFilters struct {
	NameExclusions  string   `yaml:"name_exclusions"`
	DataSourceTypes []string `yaml:"valid_types"`
	// contains filtered or unexported fields
}

type DataSourceSettings

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

func (*DataSourceSettings) FiltersEnabled

func (ds *DataSourceSettings) FiltersEnabled() bool

func (*DataSourceSettings) GetCredentials

func (ds *DataSourceSettings) GetCredentials(dataSourceName models.AddDataSourceCommand) (*GrafanaDataSource, error)

func (*DataSourceSettings) IsExcluded

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

type FilterOverrides

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

type GrafanaConfig

type GrafanaConfig struct {
	Storage            string              `yaml:"storage"`
	AdminEnabled       bool                `yaml:"-"`
	URL                string              `yaml:"url"`
	APIToken           string              `yaml:"token"`
	UserName           string              `yaml:"user_name"`
	Password           string              `yaml:"password"`
	Organization       string              `yaml:"organization"`
	MonitoredFolders   []string            `yaml:"watched"`
	DataSourceSettings *DataSourceSettings `yaml:"datasources"`
	FilterOverrides    *FilterOverrides    `yaml:"filter_override"`
	OutputPath         string              `yaml:"output_path"`
}

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) (*GrafanaDataSource, error)

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

func (*GrafanaConfig) GetDashboardOutput

func (s *GrafanaConfig) GetDashboardOutput() string

func (*GrafanaConfig) GetDataSourceOutput

func (s *GrafanaConfig) GetDataSourceOutput() string

func (*GrafanaConfig) GetDataSourceSettings

func (s *GrafanaConfig) GetDataSourceSettings() *DataSourceSettings

func (*GrafanaConfig) GetFilterOverrides

func (s *GrafanaConfig) GetFilterOverrides() *FilterOverrides

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) GetPath

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

func (*GrafanaConfig) GetTeamOutput

func (s *GrafanaConfig) GetTeamOutput() string

func (*GrafanaConfig) GetUserOutput

func (s *GrafanaConfig) GetUserOutput() string

type GrafanaDataSource

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

GrafanaDataSource Default datasource credentials

type MatchingRule

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

type RegexMatchesList

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

type ResourceType

type ResourceType string

func (*ResourceType) GetPath

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

func (*ResourceType) String

func (s *ResourceType) String() string

Jump to

Keyboard shortcuts

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