config

package
v0.0.0-...-61a96ab Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidPrivateKey is returned if the given private key is not valid.
	ErrInvalidPrivateKey = errors.New("invalid private key")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	SystemConfig
	UserConfig
}

Config represents a config structure for the application.

func NewConfig

func NewConfig(ctx context.Context, sysCfg SystemConfig, userCfg UserConfig) (*Config, error)

NewConfig returns a new instance of Config object.

func (*Config) ComponentPath

func (c *Config) ComponentPath(component types.Component, team, project string, id int) string

ComponentPath returns a path to a component json representation.

type MetaData

type MetaData struct {
	Team    string
	Project string
	Slack   string

	FilePath string
}

MetaData is a field which holds a user provided metadata. Team is a name of a team responsible for a config. Project is an name of a project, used in component name, optional.

type SystemConfig

type SystemConfig interface {
	// config accessors
	GetDatadogDataPath() string
	GetDatadogAPIKey() string
	GetDatadogAPPKey() string
	GetDatadogPollingScheduler() string
	GetDatadogPollingInterval() time.Duration
	GetGithubDatadogDataPath() string
	GetGithubBaseURL() string
	GetGithubProjectOwner() string
	GetGithubRepo() string
	GetGithubIntegrationID() int
	GetGithubAppInstallationID() int
	GetGithubWebhookSecret() string
	GetLoggingLevel() string
	GetLoggingJSON() bool
	GetIgnoreKnownHosts() bool

	// GithubAPIURL returns a path to github API endpoint. This is useful for enterprise github, where API url
	// is different from the github.com.
	GithubAPIURL() string

	// GitURL returns a URL to git repository. The git repository is used to store datadog configs.
	GitURL() string

	// GithubAppPrivateKeyBytes returns a private key in bytes
	GithubAppPrivateKeyBytes() []byte

	// GetHTTPSecret returns a http secret used to auth a user performing API requests.
	GetHTTPSecret() string

	// GetHTTPPort returns a port to listen on.
	GetHTTPPort() int

	GitUser() string
	GitEmail() string

	GetSlackToken() string

	// PullRequestBodyExtra returns a string to append to an automatically created pull request.
	PullRequestBodyExtra() string
}

SystemConfig is an interface which describes the application system config. System config is a basic parameters (required or optional) for running the service. In this config we use use git command to create commits, push to remote branch as well as github API to open/manage pull requests, reviews etc.

func NewSystemConfig

func NewSystemConfig() (SystemConfig, error)

NewSystemConfig creates a new instance of system config.

type UserConfig

type UserConfig interface {
	// Reload the user config if the config as updated
	Reload() error

	// UserConfigFilesByComponentID takes a component, id and returns a list of user config files
	// which contain this data.
	UserConfigFilesByComponentID(component types.Component, id int) []*UserConfigFile

	// UserConfigFiles returns a slice of user config files.
	UserConfigFiles() []*UserConfigFile

	// GetUserConfigBasePath returns a base path of user config
	GetUserConfigBasePath() string

	// UserConfigFromFile reads a file from filesystem and returns a UserConfigFile object.
	UserConfigFromFile(path string, pullMaster bool) (*UserConfigFile, error)
}

UserConfig defines an interface to load the user configuration.

func NewUserConfigFromGit

func NewUserConfigFromGit(ctx context.Context) (UserConfig, error)

NewUserConfigFromGit returns a new instance of a user config from a git repository.

type UserConfigFile

type UserConfigFile struct {
	Meta MetaData

	Dashboards   []int
	Monitors     []int
	Downtimes    []int
	ScreenBoards []int
}

UserConfigFile represents a watchdog config file by a user.

func (UserConfigFile) Components

func (u UserConfigFile) Components() map[types.Component][]int

Components return a mapping of a component to its IDs from a user config file.

Jump to

Keyboard shortcuts

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