alecthomas / hcl Goto Github PK
View Code? Open in Web Editor NEWParsing, encoding and decoding of HCL to and from Go types and an AST.
License: MIT License
Parsing, encoding and decoding of HCL to and from Go types and an AST.
License: MIT License
How do I convert terraform files in the directory an convert it to json files( output it to output.json ) using this library?
For compatibility, eg.
"foo ${firstName("User Name")}"
See this playground for an example.
The unmarshalled struct has the field NegativeInt
set to -1
Parser fails to parse the number.
I think this is happening because there's no word boundary at the beginning of the number for this lexer rule to match. The negative sign might be messing with it. If I take the negative sign out it works, and if I test the regex without the beginning \b
it also works.
Hi,
We have a Terraform template with some logic that is becoming hard to understand. We'd like to move the logic to Go and provide the processed data as variable in the struct to be generated as HCL. In order to simplify logic inside Terraform template and move it over to Go but would like to have derived attributes that are used only in the HCL output. Does this already exist?
Go struct:
type MyStruct struct {
Val string `json:"val,omitempty" hcl:"val"`
Roles string `json:"roles,omitempty" hcl:"roles,optional,output"`
}
output
doesn't exist, just to show the intention or how this could be likely used. Roles
value is the result of processing Val
.
input hcl
val = "a"
output hcl
v := &MyStruct{
val: "a",
}
val = "a"
roles = "a,a_owners"
We'd like to construct schema from third party type tagged with json. Constructing the schema fails currently:
panic: struct v1alpha1.TiKVServerConfig used as attribute, is it missing a "block" tag?
Example structure: https://github.com/pingcap/tidb-operator/blob/master/pkg/apis/pingcap/v1alpha1/tikv_config.go
Hello,
To begin with, thanks for your work on this package. It's great you have comment & time.Duration support !
I tried to use it as a replacement of hashicorp/hcl
in one of my project. But based on my unit tests, default
annotation (such as hcl:"connection_string" default:"postgresql://user:password@localhost:5432/postgres"
) stopped working between v0.1.8 & v0.1.9.
When using v0.1.8
of this package, tests are successful, default values are correctly set. link to PR & link to CI
github.com/Stoakes/go-pkg/config [no test files]
=== RUN Test_FileExportCommand
--- PASS: Test_FileExportCommand (0.00s)
PASS
coverage: 86.1% of statements
ok github.com/Stoakes/go-pkg/config/cmd 0.004s coverage: 86.1% of statements
When using v0.1.9 or higher, tests fails, default values aren't set anymore. link to PR & link to CI
github.com/Stoakes/go-pkg/config [no test files]
=== RUN Test_FileExportCommand
builder_test.go:115: hcl test error. Expected "mode = false
Local {
connection_string = "***localhost:5432/postgres"
}
remote {
address = ""
useTLS = false
}
" got "Local {
}
remote {
address = ""
}
"
--- FAIL: Test_FileExportCommand (0.00s)
FAIL
coverage: 86.1% of statements
FAIL github.com/Stoakes/go-pkg/config/cmd 0.005s
FAIL
Tell me if I can help.
I ran into an issue when trying to obtain remaining fields for the example below, the second nested
field (your) was returned as part of remaining fields.
HCL:
name = "hello"
nested {
name = "my"
}
nested {
name = "your"
}
message1 = "wonderful"
message2 = world
type remainStruct struct {
Name string `hcl:"name"`
Nested []*remainNested `hcl:"nested,optional"`
Remain []*Entry `hcl:",remain"`
}
type remainNested struct {
Name string `hcl:"name"`
}
The image below shows the third remaining field in the unmarshalled object:
For my HCL config files it would be easier for the end users if the help comments were also written to the output of Marshal. There already is a marshal option withSchema that allows that but it is not exported. Please consider exporting this marshal option.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.