Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
issues:
max-per-linter: 0
max-issues-per-linter: 0
max-same-issues: 0

linters:
disable-all: true
enable:
- copyloopvar
- durationcheck
- errcheck
- exportloopref
- forcetypeassert
- gofmt
- gosimple
Expand All @@ -19,10 +19,10 @@ linters:
- paralleltest
- predeclared
- staticcheck
- tenv
- unconvert
- unparam
- unused
- usetesting

run:
# Prevent false positive timeouts in CI
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you meant to do this explicitly, although it doesn't really matter since this is a binary 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my IDE automatically upgraded the toolchain 😆

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module github.com/hashicorp/terraform-plugin-codegen-openapi

go 1.22.7
toolchain go1.23.1
go 1.23.0

toolchain go1.24.0

require (
github.com/google/go-cmp v0.6.0
Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/cli"

"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/cmd"
)

Expand Down Expand Up @@ -48,7 +49,7 @@ func TestGenerate_WithConfig(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions internal/config/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ data_sources:
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -448,7 +448,7 @@ data_sources:
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

errRegex := regexp.MustCompile(testCase.expectedErrRegex)

t.Run(name, func(t *testing.T) {
Expand Down
18 changes: 8 additions & 10 deletions internal/explorer/config_explorer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"fmt"
"testing"

"gopkg.in/yaml.v3"

"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/config"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer"
"gopkg.in/yaml.v3"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
Expand Down Expand Up @@ -321,13 +322,12 @@ func Test_ConfigExplorer_FindResources(t *testing.T) {
}

for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

explorer := explorer.NewConfigExplorer(high.Document{Paths: &high.Paths{PathItems: testCase.pathItems}}, testCase.config)
got, err := explorer.FindResources()
configExplorer := explorer.NewConfigExplorer(high.Document{Paths: &high.Paths{PathItems: testCase.pathItems}}, testCase.config)
got, err := configExplorer.FindResources()

if testCase.expectedErr != nil {
if err == nil {
Expand Down Expand Up @@ -515,13 +515,12 @@ func Test_ConfigExplorer_FindDataSources(t *testing.T) {
}

for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

explorer := explorer.NewConfigExplorer(high.Document{Paths: &high.Paths{PathItems: testCase.pathItems}}, testCase.config)
got, err := explorer.FindDataSources()
configExplorer := explorer.NewConfigExplorer(high.Document{Paths: &high.Paths{PathItems: testCase.pathItems}}, testCase.config)
got, err := configExplorer.FindDataSources()

if testCase.expectedErr != nil {
if err == nil {
Expand Down Expand Up @@ -576,7 +575,6 @@ func Test_ConfigExplorer_FindProvider(t *testing.T) {
}

for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()
Expand All @@ -586,8 +584,8 @@ func Test_ConfigExplorer_FindProvider(t *testing.T) {
t.Fatal(err)
}

explorer := explorer.NewConfigExplorer(oasModel, testCase.config)
got, err := explorer.FindProvider()
configExplorer := explorer.NewConfigExplorer(oasModel, testCase.config)
got, err := configExplorer.FindProvider()

if err != nil {
t.Fatalf("was not expecting error, got: %s", err)
Expand Down
11 changes: 6 additions & 5 deletions internal/explorer/explorer_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/util"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/pb33f/libopenapi/datamodel/high/base"
high "github.com/pb33f/libopenapi/datamodel/high/v3"

"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/util"
)

func TestReadOpParameters_Resource(t *testing.T) {
Expand Down Expand Up @@ -324,7 +326,6 @@ func TestReadOpParameters_Resource(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand All @@ -335,7 +336,7 @@ func TestReadOpParameters_Resource(t *testing.T) {

mergedParameters := resource.ReadOpParameters()

if diff := cmp.Diff(mergedParameters, testCase.want, cmp.AllowUnexported(base.Schema{}, base.SchemaProxy{}, sync.Mutex{}, high.Parameter{})); diff != "" {
if diff := cmp.Diff(mergedParameters, testCase.want, cmpopts.IgnoreUnexported(sync.Mutex{}), cmp.AllowUnexported(base.Schema{}, base.SchemaProxy{}, high.Parameter{})); diff != "" {
t.Errorf("unexpected difference for resource: %s", diff)
}
})
Expand Down Expand Up @@ -653,7 +654,7 @@ func TestReadOpParameters_DataSource(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand All @@ -664,7 +665,7 @@ func TestReadOpParameters_DataSource(t *testing.T) {

mergedParameters := dataSource.ReadOpParameters()

if diff := cmp.Diff(mergedParameters, testCase.want, cmp.AllowUnexported(base.Schema{}, base.SchemaProxy{}, sync.Mutex{}, high.Parameter{})); diff != "" {
if diff := cmp.Diff(mergedParameters, testCase.want, cmpopts.IgnoreUnexported(sync.Mutex{}), cmp.AllowUnexported(base.Schema{}, base.SchemaProxy{}, high.Parameter{})); diff != "" {
t.Errorf("unexpected difference for data source: %s", diff)
}
})
Expand Down
2 changes: 0 additions & 2 deletions internal/explorer/guesstimator_explorer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func Test_GuesstimatorExplorer_FindResources(t *testing.T) {
}

for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -196,7 +195,6 @@ func Test_GuesstimatorExplorer_FindDataSources(t *testing.T) {
}

for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()
Expand Down
13 changes: 7 additions & 6 deletions internal/mapper/attrmapper/bool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper"
"github.com/hashicorp/terraform-plugin-codegen-spec/datasource"
"github.com/hashicorp/terraform-plugin-codegen-spec/resource"
"github.com/hashicorp/terraform-plugin-codegen-spec/schema"

"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper"
)

func TestResourceBoolAttribute_Merge(t *testing.T) {
Expand Down Expand Up @@ -113,7 +114,7 @@ func TestResourceBoolAttribute_Merge(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -155,7 +156,7 @@ func TestResourceBoolAttribute_ApplyOverride(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -267,7 +268,7 @@ func TestDataSourceBoolAttribute_Merge(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -309,7 +310,7 @@ func TestDataSourceBoolAttribute_ApplyOverride(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
9 changes: 5 additions & 4 deletions internal/mapper/attrmapper/data_source_attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper"
"github.com/hashicorp/terraform-plugin-codegen-spec/datasource"
"github.com/hashicorp/terraform-plugin-codegen-spec/schema"

"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper"
)

func TestDataSourceAttributes_Merge(t *testing.T) {
Expand Down Expand Up @@ -187,7 +188,7 @@ func TestDataSourceAttributes_Merge(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -355,7 +356,7 @@ func TestDataSourceAttributes_ApplyOverrides(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
13 changes: 7 additions & 6 deletions internal/mapper/attrmapper/float64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper"
"github.com/hashicorp/terraform-plugin-codegen-spec/datasource"
"github.com/hashicorp/terraform-plugin-codegen-spec/resource"
"github.com/hashicorp/terraform-plugin-codegen-spec/schema"

"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper"
)

func TestResourceFloat64Attribute_Merge(t *testing.T) {
Expand Down Expand Up @@ -113,7 +114,7 @@ func TestResourceFloat64Attribute_Merge(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -155,7 +156,7 @@ func TestResourceFloat64Attribute_ApplyOverride(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -267,7 +268,7 @@ func TestDataSourceFloat64Attribute_Merge(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -309,7 +310,7 @@ func TestDataSourceFloat64Attribute_ApplyOverride(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
13 changes: 7 additions & 6 deletions internal/mapper/attrmapper/int64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper"
"github.com/hashicorp/terraform-plugin-codegen-spec/datasource"
"github.com/hashicorp/terraform-plugin-codegen-spec/resource"
"github.com/hashicorp/terraform-plugin-codegen-spec/schema"

"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer"
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper"
)

func TestResourceInt64Attribute_Merge(t *testing.T) {
Expand Down Expand Up @@ -113,7 +114,7 @@ func TestResourceInt64Attribute_Merge(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -155,7 +156,7 @@ func TestResourceInt64Attribute_ApplyOverride(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -267,7 +268,7 @@ func TestDataSourceInt64Attribute_Merge(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -309,7 +310,7 @@ func TestDataSourceInt64Attribute_ApplyOverride(t *testing.T) {
},
}
for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
Loading
Loading