hcl

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHCLConfigFile

func CreateHCLConfigFile(ctx context.Context, tr it.Transport, req *CreateHCLConfigFileRequest) error

CreateHCLConfigFile takes a context, transport, and create request and creates the config file.

Types

type Builder

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

Builder can be used to build structured hcl content, supporting appending attributes and blocks.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new Builder.

func (*Builder) AppendAttribute

func (h *Builder) AppendAttribute(key string, value interface{}) *Builder

AppendAttribute appends a new attribute to the current block, returning the Builder for that block.

func (*Builder) AppendAttributes

func (h *Builder) AppendAttributes(attributes map[string]interface{}) *Builder

AppendAttributes appends the provided attributes to the current block and returns the Builder for the current block.

func (*Builder) AppendBlock

func (h *Builder) AppendBlock(name string, labels []string) *Builder

AppendBlock constructs a new block given the provided name and labels, appends it to current block and returns the Builder for the new block.

func (*Builder) BuildHCL

func (h *Builder) BuildHCL() (string, error)

BuildHCL builds an HCL document for the Builder using hclwrite.

type CreateHCLConfigFileOpt

type CreateHCLConfigFileOpt func(*CreateHCLConfigFileRequest) *CreateHCLConfigFileRequest

CreateHCLConfigFileOpt is a functional option for a config create request.

func WithHCLConfigChmod

func WithHCLConfigChmod(chmod string) CreateHCLConfigFileOpt

WithHCLConfigChmod sets config file permissions.

func WithHCLConfigChown

func WithHCLConfigChown(chown string) CreateHCLConfigFileOpt

WithHCLConfigChown sets config file ownership.

func WithHCLConfigFile

func WithHCLConfigFile(unit *Builder) CreateHCLConfigFileOpt

WithHCLConfigFile sets the config file to use.

func WithHCLConfigFilePath

func WithHCLConfigFilePath(path string) CreateHCLConfigFileOpt

WithHCLConfigFilePath sets the config file path.

type CreateHCLConfigFileRequest

type CreateHCLConfigFileRequest struct {
	HCLConfig *Builder
	FilePath  string
	Chmod     string
	Chown     string
}

CreateHCLConfigFileRequest is an HCL config create request.

func NewCreateHCLConfigFileRequest

func NewCreateHCLConfigFileRequest(opts ...CreateHCLConfigFileOpt) *CreateHCLConfigFileRequest

NewCreateHCLConfigFileRequest takes functional options and returns a new config file request.

Jump to

Keyboard shortcuts

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