summaryrefslogtreecommitdiff
path: root/go.mod
AgeCommit message (Collapse)Author
2024-05-09hcldec: Allow body-derived values to be markedMartin Atkins
Similar to the previously-added UnknownBody, the new optional interface MarkedBody allows hcl.Body implementations to suggest a set of marks that ought to be applied to any value that's generated to represent the content of that body. The dynblock extension then uses this to get hcldec to mark the whole object representing any block that was generated by a dynamic block whose for_each was marked, for a better representation of the fact that a block's existence was decided based on a marked value.
2024-03-14Standardize on only two value dumping/diffing librariesMartin Atkins
Due to the quite messy heritage of this codebase -- including a large part of it being just a fork of my earlier personal project ZCL -- there were many different conventions for how to pretty-print and diff values in the tests in different parts of the codebase. To reduce the dependency sprawl, this commit now standardizes on: - github.com/davecgh/go-spew for pretty-printing - github.com/google/go-cmp for diffing These two dependencies were already present anyway, are the most general out of all of the candidates, and are also already in use by at least some of HCL's most significant callers, such as HashiCorp Terraform. The version of go-cmp we were previously using seems to have a bug that causes the tests to crash when run under the Go race detector, so I've also upgraded that dependency to latest here to clear that bug.
2024-02-16deps: Track stringer@v0.6.0 as 'tools' dependencyRadek Simko
In theory we could use the latest (v0.18.0) version of the x/tools module but that would also bring upgrade of x/sys (transitive dependency of go-cty) from current v0.5.0 and full understanding of implications of that upgrade.
2023-08-30Use Unicode 15 tables for unicode normalization and segmentationMartin Atkins
To match with the Unicode support in Go 1.21, we'll now use the Unicode 15 tables when we're normalizing Unicode strings and when counting user-perceived characters ("grapheme clusters") for source position purposes.
2023-05-31go.mod: Use cty v1.13.0, with support for refined unknown valuesMartin Atkins
This new concept allows constraining the range of an unknown value beyond what can be captured in a type constraint. We'll make more use of this in subsequent commits.
2022-11-09Strip optional metadata from empty default collections (#568)Liam Cervante
* add test cases that verify the downstream go-cty fix has worked * update go-cty
2022-10-31Update go-cty and improve documentation for optional and default attributesLiam Cervante
2022-06-22hcl: Allow individual diagnostics to carry extra informationMartin Atkins
The primary goal of the diagnostics design in HCL is to return high-quality diagnostics messages primarily for human consumption, and so their regular structure is only machine-processable in a general sense where we treat all diagnostics as subject to the same processing. A few times now we've ended up wanting to carry some additional optional contextual information along with the diagnostic, for example so that a more advanced diagnostics renderer might optionally annotate a diagnostic with extra notes to help the reader debug. We got pretty far with our previous extension of hcl.Diagnostic to include the Expression and EvalContext fields, which allow an advanced diagnostic renderer to offer hints about what values contributed to the expression that failed, but some context is even more specific than that, or is defined by the application itself and therefore not appropriate to model directly here in HCL. As a pragmatic compromise then, here we introduce one more field Extra to hcl.Diagnostic, which comes with a documented convention of placing into it situation-specific values that implement particular interfaces, and therefore a diagnostics renderer or other consumer can potentially "sniff" this field for particular interfaces it knows about and treat them in a special way if present. Since there is only one field here that might end up being asked to capture multiple extra values as the call stack unwinds, there is also a simple predefined protocol for "unwrapping" extra values in order to find nested implementations within. For callers that are prepared to require Go 1.18, the helper function hcl.DiagnosticExtra provides a type-assertion-like mechanism for sniffing for a particular interface type while automatically respecting the nesting protocol. For the moment that function lives behind a build constraint so that callers which are not yet ready to use Go 1.18 can continue to use other parts of HCL, and can implement a non-generic equivalent of this function within their own codebase if absolutely necessary. As an initial example to demonstrate the idea I've also implemented some extra information for error diagnostics returned from FunctionCallExpr, which gives the name of the function being called and, if the diagnostic is describing an error returned by the function itself, a direct reference to the raw error value returned from the function call. I anticipate a diagnostic renderer sniffing for hclsyntax.FunctionCallDiagExtra to see if a particular diagnostic is related to a function call, and if so to include additional context about the signature of that function in the diagnostic messages (by correlating with the function in the EvalContext functions table). For example: While calling: join(separator, list) An example application-specific "extra value" could be for Terraform to annotate diagnostics that relate to situations where an unknown value is invalid, or where a "sensitive" value (a Terraform-specific value mark) is invalid, so that the diagnostic renderer can avoid distracting users with "red herring" commentary about unknown or sensitive values unless they seem likely to be relevant to the error being printed.
2022-06-14go.mod: Specify that we use the Go 1.17 language in this moduleMartin Atkins
The main motivation here is that we were apparently using bit shifting with signed shift amounts even though modern Go toolchains seem to raise that as an error if the go.mod file selects a language version less than Go 1.13. Go 1.17 is therefore newer than we strictly need to solve that particular problem, but gets us caught up with a relatively release of the language. This alone doesn't break compatibility for anyone using older versions of Go with HCL, since the Go toolchain will still attempt to compile modules targeting later versions and will only mention the newer language version if compilation would already have failed for some other reason.
2022-05-17deps: update crypto dependency for macOS supportSeth Hoenig
Not sure if this is M1 specific or just newer versions of macOS altogether, but hclfmt cannot be installed with the transitive dependency on `golang.org/x/sys@v0.0.0-20190502175342-a43fa875dd82` caused by the dependency on `golang.org/x/crypto`. Update the crypto library so that a newer version of sys gets pulled in, which compiles fine.
2021-02-23specsuite: Fix some regressionsMartin Atkins
Lately we've made some changes that have affected the behavior of the specsuite tests, causing them to fail. Much of this was caused by changes to the harness itself (based on hcldec), although one break in particular here was an intentional change to the implementation of modulo in upstream cty to make it produce a more accurate result when used with a fractional divisor.
2021-02-23Use Unicode 13 text segmentation rulesMartin Atkins
HCL uses a number of upstream libraries that implement algorithms defined in Unicode. This commit is updating those libraries all to versions that have Unicode 13 support. The main implication of this for HCL directly is that when it returns column numbers in source locations it will count characters using the Unicode 13 definition of "character", which includes various new multi-codeunit characters added in Unicode 13. These new version dependencies will also make Unicode 13 support available for other functionality that HCL callers might use, such as the stdlib functions in upstream cty, even though HCL itself does not directly use those.
2020-03-09Use Unicode 12.0.0 grapheme cluster segmentation rulesMartin Atkins
HCL uses grapheme cluster segmentation to produce accurate "column" indications in diagnostic messages and other human-oriented source location information. Each new major version of Unicode introduces new codepoints, some of which are defined to combine with other codepoints to produce a single visible character (grapheme cluster). We were previously using the rules from Unicode 9.0.0. This change switches to using the segmentation rules from Unicode 12.0.0, which is the latest version at the time of this commit and is also the version of Unicode used for other purposes by the Go 1.14 runtime. HCL does not use text segmentation results for any purpose that would affect the meaning of decoded data extracted from HCL files, so this change will only affect the human-oriented source positions generated for files containing characters that were newly-introduced in Unicode 10, 11, or 12. (Machine-oriented uses of source location information are based on byte offsets and not affected by text segmentation.)
2019-12-17go get github.com/zclconf/go-cty@v1.2.0Martin Atkins
This includes a new feature to allow extension properties associated with capsule types, which HCL can in turn use to allow certain capsule types to opt in to special handing at the HCL layer. (There are no such hooks in use as of this commit, however.)
2019-12-06dependencies: go get github.com/zclconf/go-cty@v1.1.1Martin Atkins
This patch release includes a couple small bug fixes that don't affect HCL directly, and a slight improvement to error messages for failed conversions from boolean to string. The primary goal of this upgrade is to ratchet dependents on HCL up to the newer version of cty in order to get those improved error messages, but during upgrading they may also benefit from the other bug fixes.
2019-10-01go get github.com/zclconf/go-cty@v1.1.0Martin Atkins
2019-09-09Unfold the "hcl" directory up into the rootMartin Atkins
The main HCL package is more visible this way, and so it's easier than having to pick it out from dozens of other package directories.
2019-09-09Change module path to github.com/hashicorp/hcl/v2Martin Atkins
This is in preparation for the first v2 release from the main HCL repository.
2019-08-21deps: Bump github.com/go-test/deep to 1.0.3Radek Simko
2019-06-07dependencies: go get github.com/zclconf/go-cty@v1.0.0Martin Atkins
This introduces only some minor bugfixes compared to the commit we selected before; the main goal here is to be on an actual tagged release rather than an arbitrary commit.
2019-05-03hcl/hclsyntax: Correct scanning of literal $ and % before quotesMartin Atkins
The TemplateStringLiteral production was not quite right, causing a literal $ or % immediately followed by " to consume the quotes and any following characters on the line if there were any more characters on the line. Now we match things more precisely, but at the expense of generating some redundant extra tokens when escapes and literal dollar/percent signs are present. Those extra tokens don't matter in practice because the resulting strings get concatenated together anyway, which is proven by the fact that this changeset includes changes only to the scanner and parser tests, and not to any of the expression result tests. While here, I also improved the error message for when the user attempts to split a quoted string over multiple lines. Previously it was just using the generic "invalid character" message, which isn't particularly actionable. Now we'll give the user a couple options of what to do instead.
2019-04-30go get github.com/zclconf/go-cty@masterMartin Atkins
This includes several upstream fixes and usability improvements.
2019-01-24dependencies: go get github.com/zclconf/go-cty@masterMartin Atkins
This includes a new function cty.ParseNumberVal which centralizes the standard way to produce a cty.Number from a string so we can be sure to always get comparable numbers.
2018-11-29update go.mod (#60)James Bardin
Fix import for howett.net/plist, and update go.mod.
2018-11-29convert to correct types in expressions (#59)James Bardin
* Add tests to cover new behavior introduced in cty Convert should now not convert null to DynamicPseudoType, and Equals will always compare Nulls as equal. * update go.mod
2018-11-11hclpack: Implement JSON marshaling (but not unmarshaling, yet)Martin Atkins
2018-11-03go mod tidyMartin Atkins
2018-08-17Get ready to be a Go moduleMartin Atkins
However, since this repository is only a temporary home for this module, the go.mod file carries a warning to that effect. It will move to its more permanent home as it transitions from experimental to released.