Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to failing tfgen by default on failed mapping errors #616

Merged
merged 1 commit into from Sep 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/tfgen/generate.go
Expand Up @@ -954,9 +954,9 @@ func (g *Generator) gatherResources() (moduleMap, error) {
}
modules := make(moduleMap)

failBuildOnMissingMapError := isTruthy(os.Getenv("PULUMI_MISSING_MAPPING_ERROR")) ||
isTruthy(os.Getenv("PULUMI_PROVIDER_MAP_ERROR"))
failBuildOnExtraMapError := isTruthy(os.Getenv("PULUMI_EXTRA_MAPPING_ERROR"))
skipFailBuildOnMissingMapError := isTruthy(os.Getenv("PULUMI_SKIP_MISSING_MAPPING_ERROR")) || isTruthy(os.Getenv(
"PULUMI_SKIP_PROVIDER_MAP_ERROR"))
skipFailBuildOnExtraMapError := isTruthy(os.Getenv("PULUMI_SKIP_EXTRA_MAPPING_ERROR"))

// let's keep a list of TF mapping errors that we can present to the user
var resourceMappingErrors error
Expand All @@ -972,7 +972,7 @@ func (g *Generator) gatherResources() (moduleMap, error) {
continue
}

if failBuildOnMissingMapError && !ignoreMappingError(g.info.IgnoreMappings, r) {
if !ignoreMappingError(g.info.IgnoreMappings, r) && !skipFailBuildOnMissingMapError {
resourceMappingErrors = multierror.Append(resourceMappingErrors,
fmt.Errorf("TF resource %q not mapped to the Pulumi provider", r))
} else {
Expand Down Expand Up @@ -1003,7 +1003,7 @@ func (g *Generator) gatherResources() (moduleMap, error) {
sort.Strings(names)
for _, name := range names {
if !seen[name] {
if failBuildOnExtraMapError {
if !skipFailBuildOnExtraMapError {
resourceMappingErrors = multierror.Append(resourceMappingErrors,
fmt.Errorf("Pulumi token %q is mapped to TF provider resource %q, but no such "+
"resource found. The mapping will be ignored in the generated provider",
Expand Down