github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/version/dependencies.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package version 5 6 import "runtime/debug" 7 8 // See the docs for InterestingDependencies to understand what "interesting" is 9 // intended to mean here. We should keep this set relatively small to avoid 10 // bloating the logs too much. 11 var interestingDependencies = map[string]struct{}{ 12 "github.com/hashicorp/hcl/v2": {}, 13 "github.com/zclconf/go-cty": {}, 14 "github.com/hashicorp/go-tfe": {}, 15 "github.com/hashicorp/terraform-svchost": {}, 16 } 17 18 // InterestingDependencies returns the compiled-in module version info for 19 // a small number of dependencies that Terraform uses broadly and which we 20 // tend to upgrade relatively often as part of improvements to Terraform. 21 // 22 // The set of dependencies this reports might change over time if our 23 // opinions change about what's "interesting". This is here only to create 24 // a small number of extra annotations in a debug log to help us more easily 25 // cross-reference bug reports with dependency changelogs. 26 func InterestingDependencies() []*debug.Module { 27 info, ok := debug.ReadBuildInfo() 28 if !ok { 29 // Weird to not be built in module mode, but not a big deal. 30 return nil 31 } 32 33 ret := make([]*debug.Module, 0, len(interestingDependencies)) 34 35 for _, mod := range info.Deps { 36 if _, ok := interestingDependencies[mod.Path]; !ok { 37 continue 38 } 39 if mod.Replace != nil { 40 mod = mod.Replace 41 } 42 ret = append(ret, mod) 43 } 44 45 return ret 46 }