From 2aac8cf8124d7dfd601ea7b7273c5427bdd73700 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 9 Jan 2020 17:54:16 -0800 Subject: [PATCH] internal/getproviders: Distinguished packed vs. unpacked local packages Our local filesystem mirror mechanism will allow provider packages to be given either in packed form as an archive directly downloaded to disk or in an unpacked form where the archive is extracted. Distinguishing these two cases in the concrete Location types will allow callers to reliably select the mode chosen by the selected installation source and handle it appropriately, rather than resorting to out-of-band heuristics like checking whether the object is a directory or a file. --- internal/getproviders/types.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/internal/getproviders/types.go b/internal/getproviders/types.go index b2faf3808..3cfce0c12 100644 --- a/internal/getproviders/types.go +++ b/internal/getproviders/types.go @@ -59,19 +59,27 @@ type PackageMeta struct { } // PackageLocation represents a location where a provider distribution package -// can be obtained. A value of this type contains either a PackageLocalPath or a -// PackageHTTPURL value. +// can be obtained. A value of this type contains one of the following +// concrete types: PackageLocalArchive, PackageLocalDir, or PackageHTTPURL. type PackageLocation interface { packageLocation() } -// PackageLocalPath is a provider package location in the local filesystem. -// Its value is a local filesystem path using the syntax understood by Go's -// standard path/filepath package on the operating system where Terraform is -// running. -type PackageLocalPath string +// PackageLocalArchive is the location of a provider distribution archive file +// in the local filesystem. Its value is a local filesystem path using the +// syntax understood by Go's standard path/filepath package on the operating +// system where Terraform is running. +type PackageLocalArchive string -func (p PackageLocalPath) packageLocation() {} +func (p PackageLocalArchive) packageLocation() {} + +// PackageLocalDir is the location of a directory containing an unpacked +// provider distribution archive in the local filesystem. Its value is a local +// filesystem path using the syntax understood by Go's standard path/filepath +// package on the operating system where Terraform is running. +type PackageLocalDir string + +func (p PackageLocalDir) packageLocation() {} // PackageHTTPURL is a provider package location accessible via HTTP. // Its value is a URL string using either the http: scheme or the https: scheme.