config

package
v0.14.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceJSON = "json"
	SourceHCL  = "hcl"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudQuery

type CloudQuery struct {
	PluginDirectory string              `hcl:"plugin_directory,optional"`
	PolicyDirectory string              `hcl:"policy_directory,optional"`
	Logger          *logging.Config     `hcl:"logging,block"`
	Providers       []*RequiredProvider `hcl:"provider,block"`
	Connection      *Connection         `hcl:"connection,block"`
}

type Config

type Config struct {
	CloudQuery CloudQuery  `hcl:"cloudquery,block"`
	Providers  []*Provider `hcl:"provider,block"`
}

func (Config) GetProvider

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

type Configuration added in v0.13.8

type Configuration struct {
	Providers []*PolicyProvider `hcl:"provider,block"`
}

type Connection

type Connection struct {
	DSN string `hcl:"dsn,attr"`
}

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(fs afero.Fs) *Parser

NewParser creates and returns a new Parser that reads files from the given filesystem. If a nil filesystem is passed then the system's "real" filesystem will be used, via afero.OsFs.

func (*Parser) DecodePolicies added in v0.13.8

func (p *Parser) DecodePolicies(body hcl.Body, diags hcl.Diagnostics, basePath string) (*PolicyWrapper, hcl.Diagnostics)

func (*Parser) LoadConfigFile

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

func (*Parser) LoadConfigFromJson added in v0.13.3

func (p *Parser) LoadConfigFromJson(name string, data []byte) (*Config, hcl.Diagnostics)

func (*Parser) LoadConfigFromSource

func (p *Parser) LoadConfigFromSource(name string, data []byte) (*Config, hcl.Diagnostics)

func (*Parser) LoadHCLFile

func (p *Parser) LoadHCLFile(path string) (hcl.Body, hcl.Diagnostics)

LoadHCLFile is a low-level method that reads the file at the given path, parses it, and returns the hcl.Body representing its root. In many cases it is better to use one of the other Load*File methods on this type, which additionally decode the root body in some way and return a higher-level construct.

If the file cannot be read at all -- e.g. because it does not exist -- then this method will return a nil body and error diagnostics. In this case callers may wish to ignore the provided error diagnostics and produce a more context-sensitive error instead.

The file will be parsed using the HCL native syntax unless the filename ends with ".json", in which case the HCL JSON syntax will be used.

type Policy

type Policy struct {
	Name        string         `hcl:"name,label"`
	Description string         `hcl:"description,optional"`
	Config      *Configuration `hcl:"configuration,block"`

	Policies []*Policy `hcl:"policy,block"`
	Queries  []*Query  `hcl:"query,block"`
	Views    []*View   `hcl:"view,block"`
}

type PolicyProvider added in v0.13.8

type PolicyProvider struct {
	Type    string `hcl:"type,label"`
	Version string `hcl:"version,optional"`
}

type PolicyWrapper added in v0.13.8

type PolicyWrapper struct {
	Policies []*Policy `hcl:"policy,block"`
}

type Provider

type Provider struct {
	Name          string   `hcl:"name,label"`
	Alias         string   `hcl:"alias,optional"`
	Resources     []string `hcl:"resources,optional"`
	Env           []string `hcl:"env,optional"`
	Configuration hcl.Body `hcl:"configuration,body"`
}

type Query added in v0.13.8

type Query struct {
	Name         string `hcl:"name,label"`
	Description  string `hcl:"description,optional"`
	ExpectOutput bool   `hcl:"expect_output,optional"`
	Query        string `hcl:"query"`
}

type RequiredProvider

type RequiredProvider struct {
	Name    string `hcl:"name,label"`
	Source  string `hcl:"source,optional"`
	Version string `hcl:"version"`
}

func (RequiredProvider) String added in v0.13.7

func (r RequiredProvider) String() string

type SourceType

type SourceType string

type View added in v0.13.8

type View struct {
	Name        string `hcl:"name,label"`
	Description string `hcl:"description,optional"`

	Query *Query `hcl:"query,block"`
}

Directories

Path Synopsis
Package convert is taken from github.com/tmccombs/hcl2json added support to convert hcl.Body
Package convert is taken from github.com/tmccombs/hcl2json added support to convert hcl.Body

Jump to

Keyboard shortcuts

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