diff --git a/enumeration/resource/resource.go b/enumeration/resource/resource.go index e7279276..3621171e 100644 --- a/enumeration/resource/resource.go +++ b/enumeration/resource/resource.go @@ -188,14 +188,18 @@ func (a *Attributes) GetBool(path string) *bool { } func (a *Attributes) GetInt(path string) *int { - // This is a nonsense, if we want to retrieve an int this is gonna fail - // We were doing that because all numbers fields from cty are float64 but sometimes we want to retrieve an int - // TODO Change this to be compatible with both int and float64 underlying type - val := a.GetFloat64(path) + val, exist := (*a)[path] + if !exist { + return nil + } + if v, isInt := val.(int); isInt { + return &v + } + floatVal := a.GetFloat64(path) if val == nil { return nil } - v := int(*val) + v := int(*floatVal) return &v } diff --git a/pkg/resource/schemas/repository.go b/pkg/resource/schemas/repository.go index fe09f15b..b1ad485a 100644 --- a/pkg/resource/schemas/repository.go +++ b/pkg/resource/schemas/repository.go @@ -47,6 +47,22 @@ func (r *SchemaRepository) fetchNestedBlocks(root string, metadata map[string]re } func (r *SchemaRepository) Init(providerName, providerVersion string, schema map[string]providers.Schema) error { + + if providerVersion == "" { + switch providerName { + case "aws": + providerVersion = "3.19.0" + case "github": + providerVersion = "4.4.0" + case "google": + providerVersion = "3.78.0" + case "azurerm": + providerVersion = "2.71.0" + default: + return errors.Errorf("unsupported remote '%s'", providerName) + } + } + v, err := version.NewVersion(providerVersion) if err != nil { return err