exohcl

package
v0.0.0-...-1fa5987 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const LatestMajor = 0
View Source
const LatestMinor = 1

Variables

View Source
var Latest = fmt.Sprintf("%d.%d", LatestMajor, LatestMinor)
View Source
var Starter = fmt.Sprintf(`# See https://docs.deref.io/exo for details.

exo = "%s"
`, Latest)

Functions

func Analyze

func Analyze(ctx context.Context, ana Analyzer) hcl.Diagnostics

func AnalyzeString

func AnalyzeString(ctx *AnalysisContext, x hcl.Expression) (s string, ok bool)

func IsValidName

func IsValidName(name string) bool

Names are restricted to be valid domain names.

func MangleName

func MangleName(name string) string

func NewRenameWarning

func NewRenameWarning(originalName, newName string, subject *hcl.Range) *hcl.Diagnostic

func NewUnsupportedFeatureWarning

func NewUnsupportedFeatureWarning(featureName, explanation string, subject *hcl.Range) *hcl.Diagnostic

func RewriteComponent

func RewriteComponent(re Rewrite, c *Component) *hclgen.Block

func RewriteComponents

func RewriteComponents(re Rewrite, cs *ComponentSet) *hclgen.Block

func RewriteEnvironment

func RewriteEnvironment(re Rewrite, env *Environment) *hclgen.Block

func RewriteManifest

func RewriteManifest(re Rewrite, m *Manifest) *hclgen.File

func RewriteSecrets

func RewriteSecrets(re Rewrite, s *Secrets) *hclgen.Block

func Validate

func Validate(ctx *AnalysisContext, m *Manifest)

Validate deeply analyzes the manifest, collecting all diagnostics eagerly.

func ValidateName

func ValidateName(name string) error

Types

type AnalysisContext

type AnalysisContext struct {
	context.Context
	Diagnostics hcl.Diagnostics
}

func (*AnalysisContext) AppendDiags

func (ctx *AnalysisContext) AppendDiags(diags ...*hcl.Diagnostic)

type Analyzer

type Analyzer interface {
	Analyze(*AnalysisContext)
}

type AppendSecrets

type AppendSecrets struct {
	context.Context
	RewriteBase

	Source string
}

func (AppendSecrets) RewriteEnvironment

func (args AppendSecrets) RewriteEnvironment(re Rewrite, env *Environment) *hclgen.Block

type Builder

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

func NewBuilder

func NewBuilder(src []byte) *Builder

If provided, src is the original source code used to build a new Exo manifest file. The actual format of the source code doesn't matter, since diagnostics will be reported in terms of this source code when available, not the constructed manifest file.

func (*Builder) AddComponentBlock

func (b *Builder) AddComponentBlock(block *hclgen.Block)

func (*Builder) Build

func (b *Builder) Build() *hcl.File

func (*Builder) EnsureComponentBlock

func (b *Builder) EnsureComponentBlock() *hclgen.Block

type Component

type Component struct {
	Source *hclsyntax.Block

	Expansion *hclsyntax.Block
	Type      string
	Name      string
	Spec      string
	DependsOn []string
}

func NewComponent

func NewComponent(block *hclsyntax.Block) *Component

func (*Component) Analyze

func (c *Component) Analyze(ctx *AnalysisContext)

type ComponentSet

type ComponentSet struct {
	// Analysis inputs.
	Blocks hcl.Blocks

	// Analysis outputs.
	Components []*Component
}

func NewComponentSet

func NewComponentSet(m *Manifest) *ComponentSet

func (*ComponentSet) Analyze

func (cs *ComponentSet) Analyze(ctx *AnalysisContext)

type Environment

type Environment struct {
	// Analysis inputs.
	Blocks hcl.Blocks

	// Analysis outputs.
	Attributes []*hclgen.Attribute
	Variables  map[string]string
	Secrets    []*Secrets // TODO: Should analysis be lazier here?
}

func NewEnvironment

func NewEnvironment(m *Manifest) *Environment

func (*Environment) Analyze

func (env *Environment) Analyze(ctx *AnalysisContext)

func (*Environment) EnvironmentSource

func (env *Environment) EnvironmentSource() string

func (*Environment) ExtendEnvironment

func (env *Environment) ExtendEnvironment(b environment.Builder) error

type Expand

type Expand struct {
	context.Context
	RewriteBase
}

func (Expand) RewriteComponent

func (_ Expand) RewriteComponent(re Rewrite, c *Component) *hclgen.Block

type FormatVersion

type FormatVersion struct {
	// Analysis inputs.
	Attribute *hcl.Attribute

	// Analysis outputs.
	Major int
	Minor int
}

func NewFormatVersion

func NewFormatVersion(m *Manifest) *FormatVersion

func (*FormatVersion) Analyze

func (ver *FormatVersion) Analyze(ctx *AnalysisContext)

type Importer

type Importer struct {
	Filename string
}

func (*Importer) Import

func (imp *Importer) Import(ctx *AnalysisContext, bs []byte) *hcl.File

type Manifest

type Manifest struct {
	// Analysis inputs.
	Filename string
	File     *hcl.File

	// Analysis outputs.
	Content       *hcl.BodyContent
	FormatVersion *FormatVersion
	Environment   hcl.Blocks
	Components    hcl.Blocks
}

func NewManifest

func NewManifest(filename string, file *hcl.File) *Manifest

func (*Manifest) Analyze

func (m *Manifest) Analyze(ctx *AnalysisContext)

type Normalize

type Normalize struct {
	context.Context
	RewriteBase
}

Normalize lifts RewriteBase to fully satisfy the Rewrite interface.

type RemoveSecrets

type RemoveSecrets struct {
	context.Context
	RewriteBase

	Source string
}

func (RemoveSecrets) RewriteSecrets

func (args RemoveSecrets) RewriteSecrets(re Rewrite, s *Secrets) *hclgen.Block

type Rewrite

type Rewrite interface {
	context.Context
	RewriteManifest(Rewrite, *Manifest) *hclgen.File
	RewriteEnvironment(Rewrite, *Environment) *hclgen.Block
	RewriteSecrets(Rewrite, *Secrets) *hclgen.Block
	RewriteComponents(Rewrite, *ComponentSet) *hclgen.Block
	RewriteComponent(Rewrite, *Component) *hclgen.Block
}

type RewriteBase

type RewriteBase struct{}

RewriteBase is intended embedded in Rewrite implementations to provide default method implementations. The default implementations rewrite structures in to normal form.

func (RewriteBase) RewriteComponent

func (_ RewriteBase) RewriteComponent(re Rewrite, c *Component) *hclgen.Block

func (RewriteBase) RewriteComponents

func (_ RewriteBase) RewriteComponents(re Rewrite, cs *ComponentSet) *hclgen.Block

func (RewriteBase) RewriteEnvironment

func (_ RewriteBase) RewriteEnvironment(re Rewrite, env *Environment) *hclgen.Block

func (RewriteBase) RewriteManifest

func (_ RewriteBase) RewriteManifest(re Rewrite, m *Manifest) *hclgen.File

func (RewriteBase) RewriteSecrets

func (_ RewriteBase) RewriteSecrets(re Rewrite, s *Secrets) *hclgen.Block

type Secrets

type Secrets struct {
	// Analysis inputs.
	Block *hclsyntax.Block

	// Analysis outputs.
	Source string
}

func NewSecrets

func NewSecrets(block *hclsyntax.Block) *Secrets

func (*Secrets) Analyze

func (s *Secrets) Analyze(ctx *AnalysisContext)

Directories

Path Synopsis
Package hclgen generates formatted HCL from ASTs.
Package hclgen generates formatted HCL from ASTs.

Jump to

Keyboard shortcuts

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