You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to propose an enhancement that would allow me to use this library and extend with custom functionality in my own projects.
I would like to define 2 marshaler interfaces in the library that I can implement in my own project:
// ExpressionMarshaler defines an interface for marshaling a field type as an HCL expression.
type ExpressionMarshaler interface {
MarshalExpression() (*hclwrite.Expression, error)
}
// BlockMarshaler defines an interface for marshalling a type to an *hclwrite.Block
// It can be used to implement custom hcl block writing for structs and types, including
// when used as fields with the block tag
type BlockMarshaler interface {
MarshalBlock(blockType string) *hclwrite.Block
}
In the EncodeAsBlock and populateBody functions, I'd like to then check if the interface{} passed in implements these respective interfaces and if it does, just call the function.
This would allow other consumers of this library to extend/customize the marshalling behavior when using hclwrite for custom types and structs.
I have a working fork of this and happy to open a PR, but wanted to start a discussion here first if you are okay with this approach.
The text was updated successfully, but these errors were encountered:
Hello -
I'd like to propose an enhancement that would allow me to use this library and extend with custom functionality in my own projects.
I would like to define 2 marshaler interfaces in the library that I can implement in my own project:
In the EncodeAsBlock and populateBody functions, I'd like to then check if the
interface{}
passed in implements these respective interfaces and if it does, just call the function.This would allow other consumers of this library to extend/customize the marshalling behavior when using
hclwrite
for custom types and structs.I have a working fork of this and happy to open a PR, but wanted to start a discussion here first if you are okay with this approach.
The text was updated successfully, but these errors were encountered: