(body hcl.Body, _ string, override bool)
| 64 | } |
| 65 | |
| 66 | func loadConfigFileBody(body hcl.Body, _ string, override bool) (*File, hcl.Diagnostics) { |
| 67 | var diags hcl.Diagnostics |
| 68 | file := &File{} |
| 69 | |
| 70 | // We check for version compatibility constraints in the module first, using |
| 71 | // some code designed to be as resilient as possible to unpredictable |
| 72 | // future extensions to the language, so that we have the best possible |
| 73 | // chance of returning a version compatibility error if someone intentionally |
| 74 | // excluded the current version due to the module using newer features. |
| 75 | reqDiags := checkVersionRequirements(body, version.SemVer) |
| 76 | diags = append(diags, reqDiags...) |
| 77 | |
| 78 | // We still continue here even if there was a version compatibility problem |
| 79 | // because we want to gather as complete as possible a map of the content |
| 80 | // of the valid parts of the module in case a caller wants to use that |
| 81 | // for careful partial analysis. Note though that if we have at least one |
| 82 | // version compatibility diagnostic in diags then any other diagnostics |
| 83 | // added later will eventually be discarded by [finalizeModuleLoadDiagnostics]. |
| 84 | |
| 85 | content, contentDiags := body.Content(configFileSchema) |
| 86 | diags = append(diags, contentDiags...) |
| 87 | |
| 88 | for _, block := range content.Blocks { |
| 89 | switch block.Type { |
| 90 | |
| 91 | case "language": |
| 92 | cfgDiags := validateLanguageBlock(block, override) |
| 93 | diags = append(diags, cfgDiags...) |
| 94 | |
| 95 | case "terraform": |
| 96 | content, contentDiags := block.Body.Content(terraformBlockSchema) |
| 97 | diags = append(diags, contentDiags...) |
| 98 | |
| 99 | // We ignore the "required_version", "language" and "experiments" |
| 100 | // attributes here because checkVersionRequirements above deals |
| 101 | // with "required_version" and the other two are not relevant |
| 102 | // to OpenTofu. ("language" blocks contain OpenTofu's equivalents.) |
| 103 | |
| 104 | for _, innerBlock := range content.Blocks { |
| 105 | switch innerBlock.Type { |
| 106 | |
| 107 | case "backend": |
| 108 | backendCfg, cfgDiags := decodeBackendBlock(innerBlock) |
| 109 | diags = append(diags, cfgDiags...) |
| 110 | if backendCfg != nil { |
| 111 | file.Backends = append(file.Backends, backendCfg) |
| 112 | } |
| 113 | |
| 114 | case "cloud": |
| 115 | cloudCfg, cfgDiags := decodeCloudBlock(innerBlock) |
| 116 | diags = append(diags, cfgDiags...) |
| 117 | if cloudCfg != nil { |
| 118 | file.CloudConfigs = append(file.CloudConfigs, cloudCfg) |
| 119 | } |
| 120 | |
| 121 | case "required_providers": |
| 122 | reqs, reqsDiags := decodeRequiredProvidersBlock(innerBlock) |
| 123 | diags = append(diags, reqsDiags...) |
no test coverage detected