hashicorp / hashicorp/hcl

Advertise the encoding layer in hclsimple and gohcl

Open
#353 0 comments 10 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
5.8k
Forks
657
Avg merge
20h 36m
Merged PRs (30d)
6

Description

### References

Currently the `gohcl` package has a layer that supports Encoding of go structs into HCL. However there are no relevant functions available in `hclsimple` to use these functions. Just like we have wrappers for "decoding" in `hclsimple`, we should have relevant wrappers for encoding as well. We can then go ahead and have equivalent documentation as well. This would make `hclsimple` more end-to-end - (as in opinionated Decoding and Encoding of hcl). Currently it only focuses on Decoding.
You can refer to this repl as an example -> https://repl.it/@ishankhare07/QuizzicalSpicyDirectory

I would suggest we add 2 functions in [`hclsimple.go`](https://github.com/hashicorp/hcl/blob/hcl2/hclsimple/hclsimple.go), with roughly the following signatures:

```golang
Encode(source interface{}) (*hclwrite.File, error)
```

```golang
EncodeToFile(source interface{}, filename string) (error)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in hclsimple/hclsimple.go and compare its decoding wrappers with the encoding layer in gohcl; the linked repl shows an example of the desired use. Add the requested Encode and EncodeToFile wrappers and provide equivalent documentation, then verify that hclsimple supports both opinionated decoding and encoding.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.