github.com/pulumi/terraform@v1.4.0/pkg/addrs/module_package.go (about) 1 package addrs 2 3 import ( 4 tfaddr "github.com/hashicorp/terraform-registry-address" 5 ) 6 7 // A ModulePackage represents a physical location where Terraform can retrieve 8 // a module package, which is an archive, repository, or other similar 9 // container which delivers the source code for one or more Terraform modules. 10 // 11 // A ModulePackage is a string in go-getter's address syntax. By convention, 12 // we use ModulePackage-typed values only for the result of successfully 13 // running the go-getter "detectors", which produces an address string which 14 // includes an explicit installation method prefix along with an address 15 // string in the format expected by that installation method. 16 // 17 // Note that although the "detector" phase of go-getter does do some simple 18 // normalization in certain cases, it isn't generally possible to compare 19 // two ModulePackage values to decide if they refer to the same package. Two 20 // equal ModulePackage values represent the same package, but there might be 21 // other non-equal ModulePackage values that also refer to that package, and 22 // there is no reliable way to determine that. 23 // 24 // Don't convert a user-provided string directly to ModulePackage. Instead, 25 // use ParseModuleSource with a remote module address and then access the 26 // ModulePackage value from the result, making sure to also handle the 27 // selected subdirectory if any. You should convert directly to ModulePackage 28 // only for a string that is hard-coded into the program (e.g. in a unit test) 29 // where you've ensured that it's already in the expected syntax. 30 type ModulePackage string 31 32 func (p ModulePackage) String() string { 33 return string(p) 34 } 35 36 // A ModuleRegistryPackage is an extra indirection over a ModulePackage where 37 // we use a module registry to translate a more symbolic address (and 38 // associated version constraint given out of band) into a physical source 39 // location. 40 // 41 // ModuleRegistryPackage is distinct from ModulePackage because they have 42 // disjoint use-cases: registry package addresses are only used to query a 43 // registry in order to find a real module package address. These being 44 // distinct is intended to help future maintainers more easily follow the 45 // series of steps in the module installer, with the help of the type checker. 46 type ModuleRegistryPackage = tfaddr.ModulePackage