Skip to content

Commit b1cf4b5

Browse files
authored
Merge pull request #1581 from snyk/fix_acc_tests
Fix acceptance tests
2 parents cc6e2ca + c370036 commit b1cf4b5

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

enumeration/resource/resource.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,18 @@ func (a *Attributes) GetBool(path string) *bool {
188188
}
189189

190190
func (a *Attributes) GetInt(path string) *int {
191-
// This is a nonsense, if we want to retrieve an int this is gonna fail
192-
// We were doing that because all numbers fields from cty are float64 but sometimes we want to retrieve an int
193-
// TODO Change this to be compatible with both int and float64 underlying type
194-
val := a.GetFloat64(path)
191+
val, exist := (*a)[path]
192+
if !exist {
193+
return nil
194+
}
195+
if v, isInt := val.(int); isInt {
196+
return &v
197+
}
198+
floatVal := a.GetFloat64(path)
195199
if val == nil {
196200
return nil
197201
}
198-
v := int(*val)
202+
v := int(*floatVal)
199203
return &v
200204
}
201205

pkg/resource/schemas/repository.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ func (r *SchemaRepository) fetchNestedBlocks(root string, metadata map[string]re
4747
}
4848

4949
func (r *SchemaRepository) Init(providerName, providerVersion string, schema map[string]providers.Schema) error {
50+
51+
if providerVersion == "" {
52+
switch providerName {
53+
case "aws":
54+
providerVersion = "3.19.0"
55+
case "github":
56+
providerVersion = "4.4.0"
57+
case "google":
58+
providerVersion = "3.78.0"
59+
case "azurerm":
60+
providerVersion = "2.71.0"
61+
default:
62+
return errors.Errorf("unsupported remote '%s'", providerName)
63+
}
64+
}
65+
5066
v, err := version.NewVersion(providerVersion)
5167
if err != nil {
5268
return err

0 commit comments

Comments
 (0)