dynamic

package
v0.11.4 Latest Latest
Warning

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

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

Documentation

Overview

Package dynamic contains the HCL function, types, and logic for implementing dynamic config sourcing HCL configuration. This doesn't implement the actual logic behind configuration fetching (see `internal/appconfig`), only the declaration in an HCL file.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Func implements the configdynamic() HCL function.
	Func = function.New(&function.Spec{
		Params: []function.Parameter{
			{
				Name: "from",
				Type: cty.String,
			},

			{
				Name: "config",
				Type: cty.Map(cty.String),
			},
		},
		Type: function.StaticReturnType(Type),
		Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
			var config map[string]string
			if err := gocty.FromCtyValue(args[1], &config); err != nil {
				return cty.NilVal, err
			}

			return cty.CapsuleVal(Type, &pb.ConfigVar_DynamicVal{
				From:   args[0].AsString(),
				Config: config,
			}), nil
		},
	})

	// Type is the encapsulated type that is returned by `Func`.
	// Encapsulated types are opaque in HCL and can be decoded
	// in Go to native Go types.
	Type = cty.Capsule("configval",
		reflect.TypeOf((*pb.ConfigVar_DynamicVal)(nil)).Elem())
)

Functions

func Register

func Register(m map[string]function.Function) map[string]function.Function

Register registers the configdynamic function calls to the given map of HCL functions that can be used for an hcl.EvalContext. This function ensures that we can change the function name easily and consistently or add new dynamic-related functions.

Types

This section is empty.

Jump to

Keyboard shortcuts

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