config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: BSD-3-Clause-LBNL Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ViperGdgConfig          = "gdg"
	ViperTemplateConfig     = "template"
	DefaultOrganizationName = "Main Org."
	DefaultOrganizationId   = 1
)

Variables

This section is empty.

Functions

func InitGdgConfig added in v0.6.0

func InitGdgConfig(override, defaultConfig string)

func InitTemplateConfig added in v0.5.2

func InitTemplateConfig(override string)

Types

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"`
	RetryCount      int    `mapstructure:"retry_count" yaml:"retry_count"`
	RetryDelay      string `mapstructure:"retry_delay" yaml:"retry_delay"`
	// contains filtered or unexported fields
}

AppGlobals is the global configuration for the application

func (*AppGlobals) GetRetryTimeout added in v0.6.0

func (app *AppGlobals) GetRetryTimeout() time.Duration

GetRetryTimeout returns 100ms, by default otherwise the parsed value

type Configuration

type Configuration struct {
	// 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 changes active context

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) 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) GetGDGConfig added in v0.5.2

func (s *Configuration) GetGDGConfig() *GDGAppConfiguration

GetGDGConfig return instance of gdg app configuration

func (*Configuration) GetTemplateConfig added in v0.5.2

func (s *Configuration) GetTemplateConfig() *TemplatingConfig

GetTemplateConfig return instance of gdg app configuration

func (*Configuration) GetViperConfig added in v0.5.2

func (s *Configuration) GetViperConfig(name string) *viper.Viper

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

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, path string) (*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 GDGAppConfiguration added in v0.5.2

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

GDGAppConfiguration is the configuration for the application

func (*GDGAppConfiguration) GetAppGlobals added in v0.6.0

func (app *GDGAppConfiguration) GetAppGlobals() *AppGlobals

func (*GDGAppConfiguration) GetContext added in v0.5.2

func (app *GDGAppConfiguration) GetContext() string

func (*GDGAppConfiguration) GetContexts added in v0.5.2

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

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"`
	OrganizationName         string                `mapstructure:"organization_name" yaml:"organization_name"`
	MonitoredFoldersOverride []MonitoredOrgFolders `mapstructure:"watched_folders_override" yaml:"watched_folders_override"`
	MonitoredFolders         []string              `mapstructure:"watched" yaml:"watched"`
	ConnectionSettings       *ConnectionSettings   `mapstructure:"connections" yaml:"connections"`
	UserSettings             *UserSettings         `mapstructure:"user" yaml:"user"`
	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) GetCredentials

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

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

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) 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(orgName string) []string

GetOrgMonitoredFolders return the OrganizationMonitoredFolders that override a given Org

func (*GrafanaConfig) GetOrganizationName added in v0.6.0

func (s *GrafanaConfig) GetOrganizationName() string

GetOrganizationName 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) GetUserSettings added in v0.6.0

func (s *GrafanaConfig) GetUserSettings() *UserSettings

GetUserSettings returns configured UserSettings

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) IsGrafanaAdmin added in v0.6.0

func (s *GrafanaConfig) IsGrafanaAdmin() bool

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

func (*GrafanaConfig) SetGrafanaAdmin added in v0.6.0

func (s *GrafanaConfig) SetGrafanaAdmin(admin bool)

SetGrafanaAdmin 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 map[string]string

GrafanaConnection Default connection credentials

func (GrafanaConnection) Password added in v0.5.0

func (g GrafanaConnection) Password() string

func (GrafanaConnection) User added in v0.5.0

func (g GrafanaConnection) User() string

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 {
	OrganizationName string   `json:"organization_name" yaml:"organization_name"`
	Folders          []string `json:"folders" yaml:"folders"`
}

type RegexMatchesList

type RegexMatchesList struct {
	Rules      []MatchingRule `mapstructure:"rules" yaml:"rules,omitempty"`
	SecureData string         `mapstructure:"secure_data" yaml:"secure_data,omitempty"`
}

RegexMatchesList model wraps regex matches list for grafana

func (RegexMatchesList) GetConnectionAuth added in v0.6.0

func (r RegexMatchesList) GetConnectionAuth(path string) (*GrafanaConnection, error)

type ResourceType

type ResourceType string
const (
	ConnectionPermissionResource ResourceType = "connections-permissions"
	ConnectionResource           ResourceType = "connections"
	DashboardResource            ResourceType = "dashboards"
	FolderPermissionResource     ResourceType = "folders-permissions"
	FolderResource               ResourceType = "folders"
	LibraryElementResource       ResourceType = "libraryelements"
	OrganizationResource         ResourceType = "organizations"
	OrganizationMetaResource     ResourceType = "org"
	TeamResource                 ResourceType = "teams"
	UserResource                 ResourceType = "users"
	TemplatesResource            ResourceType = "templates"
	SecureSecretsResource        ResourceType = "secure"
)

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

type TemplateDashboardEntity added in v0.5.2

type TemplateDashboardEntity struct {
	Folder           string                 `mapstructure:"folder"`
	OrganizationName string                 `mapstructure:"organization_name"`
	DashboardName    string                 `mapstructure:"dashboard_name"`
	TemplateData     map[string]interface{} `mapstructure:"template_data"`
}

type TemplateDashboards added in v0.5.2

type TemplateDashboards struct {
	TemplateName      string                    `mapstructure:"template_name"`
	DashboardEntities []TemplateDashboardEntity `mapstructure:"output"`
}

type TemplateEntities added in v0.5.2

type TemplateEntities struct {
	Dashboards []TemplateDashboards `mapstructure:"dashboards"`
}

type TemplatingConfig added in v0.5.2

type TemplatingConfig struct {
	Entities TemplateEntities `mapstructure:"entities"`
}

func (*TemplatingConfig) GetTemplate added in v0.5.2

func (s *TemplatingConfig) GetTemplate(name string) (*TemplateDashboards, bool)

type UserSettings added in v0.6.0

type UserSettings struct {
	RandomPassword bool `mapstructure:"random_password" yaml:"random_password"`
	MinLength      int  `mapstructure:"min_length" yaml:"min_length"`
	MaxLength      int  `mapstructure:"max_length" yaml:"max_length"`
}

func (*UserSettings) GetPassword added in v0.6.0

func (u *UserSettings) GetPassword(username string) string

Jump to

Keyboard shortcuts

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