From 92691868bbd0fab91fcb30c8a1bad0b15b9bc2dc Mon Sep 17 00:00:00 2001 From: sundowndev Date: Thu, 17 Jun 2021 14:15:45 +0200 Subject: [PATCH] feat: display terraform provider version in output --- pkg/cmd/scan.go | 3 +++ pkg/resource/schemas.go | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/scan.go b/pkg/cmd/scan.go index 453bdbd4..9816fcc8 100644 --- a/pkg/cmd/scan.go +++ b/pkg/cmd/scan.go @@ -9,6 +9,7 @@ import ( "syscall" "github.com/cloudskiff/driftctl/pkg/telemetry" + "github.com/fatih/color" "github.com/mitchellh/go-homedir" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -228,6 +229,8 @@ func scanRun(opts *pkg.ScanOptions) error { telemetry.SendTelemetry(analysis) } + globaloutput.Printf(color.WhiteString("Provider version used to scan: %s. Use --tf-provider-version to use another version.\n"), resourceSchemaRepository.ProviderVersion.String()) + if !analysis.IsSync() { globaloutput.Printf("\nHint: use gen-driftignore command to generate a .driftignore file based on your drifts\n") diff --git a/pkg/resource/schemas.go b/pkg/resource/schemas.go index 4a83fbb6..6ec10c80 100644 --- a/pkg/resource/schemas.go +++ b/pkg/resource/schemas.go @@ -46,7 +46,8 @@ type SchemaRepositoryInterface interface { } type SchemaRepository struct { - schemas map[string]*Schema + schemas map[string]*Schema + ProviderVersion *version.Version } func NewSchemaRepository() *SchemaRepository { @@ -81,6 +82,7 @@ func (r *SchemaRepository) Init(v string, schema map[string]providers.Schema) er if err != nil { return err } + r.ProviderVersion = providerVersion for typ, sch := range schema { attributeMetas := map[string]AttributeSchema{} for s, attribute := range sch.Block.Attributes { @@ -92,7 +94,7 @@ func (r *SchemaRepository) Init(v string, schema map[string]providers.Schema) er r.fetchNestedBlocks("", attributeMetas, sch.Block.BlockTypes) r.schemas[typ] = &Schema{ - ProviderVersion: providerVersion, + ProviderVersion: r.ProviderVersion, SchemaVersion: sch.Version, Attributes: attributeMetas, }