Skip to content

Commit

Permalink
Remove unused TerraformVersion field from tf2pulumi and tfgen (#2684)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
iwahbe authored Dec 5, 2024
1 parent 8696ada commit f8279c2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 35 deletions.
3 changes: 2 additions & 1 deletion pkg/tf2pulumi/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion pkg/tf2pulumi/convert/eject.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 0 additions & 1 deletion pkg/tfgen/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,6 @@ func (g *Generator) convert(
PluginHost: g.pluginHost,
ProviderInfoSource: g.infoSource,
SkipResourceTypechecking: true,
TerraformVersion: g.terraformVersion,
})

return
Expand Down
61 changes: 29 additions & 32 deletions pkg/tfgen/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit f8279c2

Please sign in to comment.