From f8279c2d1c1c50aa1fd6892528a0feb51bea37ea Mon Sep 17 00:00:00 2001 From: Ian Wahbe Date: Thu, 5 Dec 2024 19:05:03 +0100 Subject: [PATCH] Remove unused TerraformVersion field from tf2pulumi and tfgen (#2684) The value of this field is never actually checked, so we can safely remove it. To prevent unexpected breaking changes, I have deprecated it where public. --- pkg/tf2pulumi/convert/convert.go | 3 +- pkg/tf2pulumi/convert/eject.go | 4 ++- pkg/tfgen/docs.go | 1 - pkg/tfgen/generate.go | 61 +++++++++++++++----------------- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/pkg/tf2pulumi/convert/convert.go b/pkg/tf2pulumi/convert/convert.go index 408749f24..f04aef4ca 100644 --- a/pkg/tf2pulumi/convert/convert.go +++ b/pkg/tf2pulumi/convert/convert.go @@ -89,7 +89,6 @@ func Convert(opts Options) (map[string][]byte, Diagnostics, error) { Logger: opts.Logger, SkipResourceTypechecking: opts.SkipResourceTypechecking, TargetSDKVersion: opts.TargetSDKVersion, - TerraformVersion: opts.TerraformVersion, } tfFiles, program, diagnostics, err := internalEject(ejectOpts) @@ -176,6 +175,8 @@ type Options struct { // The target SDK version. TargetSDKVersion string // The version of Terraform targeteds by the input configuration. + // + // Deprecated: This field no longer has any effect, and will be removed in a future version of the bridge. TerraformVersion string // TargetOptions captures any target-specific options. diff --git a/pkg/tf2pulumi/convert/eject.go b/pkg/tf2pulumi/convert/eject.go index 6bb94b701..eb7aff160 100644 --- a/pkg/tf2pulumi/convert/eject.go +++ b/pkg/tf2pulumi/convert/eject.go @@ -71,7 +71,9 @@ type EjectOptions struct { SkipResourceTypechecking bool // The target SDK version. TargetSDKVersion string - // The version of Terraform targeteds by the input configuration. + // The version of Terraform targeted by the input configuration. + // + // Deprecated: This field no longer has any effect, and will be removed in a future version of the bridge. TerraformVersion string } diff --git a/pkg/tfgen/docs.go b/pkg/tfgen/docs.go index 0dc0b6df9..2977e06f4 100644 --- a/pkg/tfgen/docs.go +++ b/pkg/tfgen/docs.go @@ -1764,7 +1764,6 @@ func (g *Generator) convert( PluginHost: g.pluginHost, ProviderInfoSource: g.infoSource, SkipResourceTypechecking: true, - TerraformVersion: g.terraformVersion, }) return diff --git a/pkg/tfgen/generate.go b/pkg/tfgen/generate.go index 80f451a63..2027b009a 100644 --- a/pkg/tfgen/generate.go +++ b/pkg/tfgen/generate.go @@ -58,21 +58,20 @@ const ( ) type Generator struct { - pkg tokens.Package // the Pulumi package name (e.g. `gcp`) - version string // the package version. - language Language // the language runtime to generate. - info tfbridge.ProviderInfo // the provider info for customizing code generation - root afero.Fs // the output virtual filesystem. - providerShim *inmemoryProvider // a provider shim to hold the provider schema during example conversion. - pluginHost plugin.Host // the plugin host for tf2pulumi. - packageCache *pcl.PackageCache // the package cache for tf2pulumi. - infoSource il.ProviderInfoSource // the provider info source for tf2pulumi. - terraformVersion string // the Terraform version to target for example codegen, if any - sink diag.Sink - skipDocs bool - skipExamples bool - coverageTracker *CoverageTracker - editRules editRules + pkg tokens.Package // the Pulumi package name (e.g. `gcp`) + version string // the package version. + language Language // the language runtime to generate. + info tfbridge.ProviderInfo // the provider info for customizing code generation + root afero.Fs // the output virtual filesystem. + providerShim *inmemoryProvider // a provider shim to hold the provider schema during example conversion. + pluginHost plugin.Host // the plugin host for tf2pulumi. + packageCache *pcl.PackageCache // the package cache for tf2pulumi. + infoSource il.ProviderInfoSource // the provider info source for tf2pulumi. + sink diag.Sink + skipDocs bool + skipExamples bool + coverageTracker *CoverageTracker + editRules editRules convertedCode map[string][]byte @@ -813,7 +812,6 @@ type GeneratorOptions struct { Root afero.Fs ProviderInfoSource il.ProviderInfoSource PluginHost plugin.Host - TerraformVersion string Sink diag.Sink Debug bool SkipDocs bool @@ -889,22 +887,21 @@ func NewGenerator(opts GeneratorOptions) (*Generator, error) { } return &Generator{ - pkg: pkg, - version: version, - language: lang, - info: info, - root: root, - providerShim: providerShim, - pluginHost: newCachingProviderHost(host), - packageCache: pcl.NewPackageCache(), - infoSource: host, - terraformVersion: opts.TerraformVersion, - sink: sink, - skipDocs: opts.SkipDocs, - skipExamples: opts.SkipExamples, - coverageTracker: opts.CoverageTracker, - editRules: getEditRules(info.DocRules), - noDocsRepo: opts.XInMemoryDocs, + pkg: pkg, + version: version, + language: lang, + info: info, + root: root, + providerShim: providerShim, + pluginHost: newCachingProviderHost(host), + packageCache: pcl.NewPackageCache(), + infoSource: host, + sink: sink, + skipDocs: opts.SkipDocs, + skipExamples: opts.SkipExamples, + coverageTracker: opts.CoverageTracker, + editRules: getEditRules(info.DocRules), + noDocsRepo: opts.XInMemoryDocs, }, nil }