fix(terraform): parse provider lock entries without constraints (#3934)

In a .terraform.lock.hcl file in a provider block the `constraints` attribute is actually not required (=optional).

Signed-off-by: Thomas Gosteli <thomas.gosteli@protonmail.ch>
This commit is contained in:
Thomas Gosteli 2025-05-27 20:55:19 +02:00 committed by GitHub
parent bbf3bb5856
commit 684e1e963d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 2 additions and 3 deletions

View File

@ -59,7 +59,7 @@ func TestTerraformCataloger(t *testing.T) {
Metadata: pkg.TerraformLockProviderEntry{
URL: "registry.terraform.io/hashicorp/google",
Version: "6.8.0",
Constraints: "6.8.0",
Constraints: "",
Hashes: []string{
"h1:GlCaVPk6eKMg2ZbRY7C5tUeHGNIABT+qFtMl8+XWZHM=",
"zh:1b78f4451f1617092eb6891c9c13eda79671060601c40947feea6794c732157a",

View File

@ -26,7 +26,6 @@ provider "registry.terraform.io/hashicorp/aws" {
provider "registry.terraform.io/hashicorp/google" {
version = "6.8.0"
constraints = "6.8.0"
hashes = [
"h1:GlCaVPk6eKMg2ZbRY7C5tUeHGNIABT+qFtMl8+XWZHM=",
"zh:1b78f4451f1617092eb6891c9c13eda79671060601c40947feea6794c732157a",

View File

@ -3,7 +3,7 @@ package pkg
// TerraformLockProviderEntry represents a single provider entry in a Terraform dependency lock file (.terraform.lock.hcl).
type TerraformLockProviderEntry struct {
URL string `hcl:",label" json:"url"`
Constraints string `hcl:"constraints" json:"constraints"`
Constraints string `hcl:"constraints,optional" json:"constraints"`
Version string `hcl:"version" json:"version"`
Hashes []string `hcl:"hashes" json:"hashes"`
}