config

package
v0.32.12 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const EnvVarPrefix = "CQ_VAR_"

EnvVarPrefix is a prefix for environment variable names to be exported for HCL substitution.

Variables

This section is empty.

Functions

func FormatVersion

func FormatVersion(version *semver.Version) string

func ParseVersion

func ParseVersion(version string) (*semver.Version, error)

func ProcessConfig

func ProcessConfig(config *Config) diag.Diagnostics

ProcessConfig handles the configuration after it was loaded and parsed 1. Assigns defaults after decoding the raw configuration format 2. Overrides configuration values from CLI flags 3. Validates the configuration provided by the user 4. Normalizes the configuration to make it easier to use

Types

type CloudQuery

type CloudQuery struct {
	Logger     *logging.Config   `yaml:"logging,omitempty" json:"logging,omitempty"`
	Providers  RequiredProviders `yaml:"providers,omitempty" json:"providers,omitempty"`
	Connection *Connection       `yaml:"connection,omitempty" json:"connection,omitempty"`
	Policy     *Policy           `yaml:"policy,omitempty" json:"policy,omitempty"`

	// Used internally
	PluginDirectory string `yaml:"-" json:"-"`
	PolicyDirectory string `yaml:"-" json:"-"`
}

func (CloudQuery) GetRequiredProvider

func (c CloudQuery) GetRequiredProvider(name string) (*RequiredProvider, error)

type Config

type Config struct {
	CloudQuery CloudQuery `yaml:"cloudquery" json:"cloudquery"`
	Providers  Providers  `yaml:"providers" json:"providers"`
}

func (Config) GetProvider

func (c Config) GetProvider(name string) (*Provider, error)

type Connection

type Connection struct {
	DSN string `yaml:"dsn,omitempty" json:"dsn,omitempty"`

	DSNFile string `yaml:"dsn_file,omitempty" json:"dsn_file,omitempty"`

	Type     string   `yaml:"type,omitempty" json:"type,omitempty"`
	Username string   `yaml:"username,omitempty" json:"username,omitempty"`
	Password string   `yaml:"password,omitempty" json:"password,omitempty"`
	Host     string   `yaml:"host,omitempty" json:"host,omitempty"`
	Port     int      `yaml:"port,omitempty" json:"port,omitempty"`
	Database string   `yaml:"database,omitempty" json:"database,omitempty"`
	SSLMode  string   `yaml:"sslmode,omitempty" json:"sslmode,omitempty"`
	Schema   string   `yaml:"schema,omitempty" json:"schema,omitempty"`
	Extras   []string `yaml:"extras,omitempty" json:"extras,omitempty"`
}

func (*Connection) BuildFromConnParams

func (c *Connection) BuildFromConnParams()

func (Connection) IsAnyConnParamsSet

func (c Connection) IsAnyConnParamsSet() bool

type Option

type Option func(*Parser)

func WithEnvironmentVariables

func WithEnvironmentVariables(prefix string, vars []string) Option

WithEnvironmentVariables fills hcl.Context with values of environment variables given in vars. Only variables that start with given prefix are considered. Prefix is removed from the name and the name is lower cased then.

func WithFS

func WithFS(aferoFs afero.Fs) Option

type Parser

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

Parser is the main interface to read configuration files and other related files from disk.

It retains a cache of all files that are loaded so that they can be used to create source code snippets in diagnostics, etc.

func NewParser

func NewParser(options ...Option) *Parser

NewParser creates and returns a new Parser.

func (*Parser) LoadConfigFile

func (p *Parser) LoadConfigFile(path string) (*Config, diag.Diagnostics)

func (*Parser) LoadConfigFromSource

func (p *Parser) LoadConfigFromSource(data []byte) (*Config, diag.Diagnostics)

func (*Parser) LoadFile

func (p *Parser) LoadFile(path string) ([]byte, diag.Diagnostics)

LoadFile is a low-level method that reads the file at the given path

type Policy

type Policy struct {
	DBPersistence bool `yaml:"db_persistence,omitempty" json:"db_persistence,omitempty"`
}

type Provider

type Provider struct {
	Name                          string   `yaml:"name,omitempty" json:"name,omitempty"`
	Alias                         string   `yaml:"alias,omitempty" json:"alias,omitempty"`
	Resources                     []string `yaml:"resources,omitempty" json:"resources,omitempty"`
	SkipResources                 []string `yaml:"skip_resources,omitempty" json:"skip_resources,omitempty"`
	Env                           []string `yaml:"env,omitempty" json:"env,omitempty"`
	ConfigBytes                   []byte   `yaml:"-" json:"-"`
	MaxParallelResourceFetchLimit uint64   `yaml:"max_parallel_resource_fetch_limit,omitempty" json:"max_parallel_resource_fetch_limit,omitempty"`
	MaxGoroutines                 uint64   `yaml:"max_goroutines,omitempty" json:"max_goroutines,omitempty"`
	ResourceTimeout               uint64   `yaml:"resource_timeout,omitempty" json:"resource_timeout,omitempty"`

	// Configuration is only used temporarily for provider-specific configuration when decoding YAML
	Configuration map[string]interface{} `yaml:"configuration,omitempty" json:"configuration,omitempty"`
}

type Providers

type Providers []*Provider

func (Providers) Names

func (pp Providers) Names() []string

type RequiredProvider

type RequiredProvider struct {
	Name    string  `yaml:"name,omitempty" json:"name,omitempty"`
	Source  *string `yaml:"source,omitempty" json:"source,omitempty"`
	Version string  `yaml:"version,omitempty" json:"version,omitempty"`
}

func (RequiredProvider) String

func (r RequiredProvider) String() string

type RequiredProviders

type RequiredProviders []*RequiredProvider

func (RequiredProviders) Distinct

func (r RequiredProviders) Distinct() RequiredProviders

Distinct returns one name per provider

func (RequiredProviders) Get

func (RequiredProviders) Names

func (r RequiredProviders) Names() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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