internal/getproviders: Functions to determine installation directories
The existing functionality in this package deals with finding packages that are either available for installation or already installed. In order to support installation we also need to determine the location where a package should be installed. This lives in the getproviders package because that way all of the logic related to the filesystem layout for local provider directories lives together here where they can be maintained together more easily in future.
This commit is contained in:
parent
072c6d9aed
commit
514184cc9d
|
@ -204,3 +204,17 @@ func SearchLocalDirectory(baseDir string) (map[addrs.Provider]PackageMetaList, e
|
||||||
}
|
}
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnpackedDirectoryPathForPackage is similar to
|
||||||
|
// PackageMeta.UnpackedDirectoryPath but makes its decision based on
|
||||||
|
// individually-passed provider address, version, and target platform so that
|
||||||
|
// it can be used by callers outside this package that may have other
|
||||||
|
// types that represent package identifiers.
|
||||||
|
func UnpackedDirectoryPathForPackage(baseDir string, provider addrs.Provider, version Version, platform Platform) string {
|
||||||
|
return filepath.ToSlash(filepath.Join(
|
||||||
|
baseDir,
|
||||||
|
provider.Hostname.ForDisplay(), provider.Namespace, provider.Type,
|
||||||
|
version.String(),
|
||||||
|
platform.String(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
|
@ -133,6 +133,17 @@ func (m PackageMeta) LessThan(other PackageMeta) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnpackedDirectoryPath determines the path under the given base
|
||||||
|
// directory where SearchLocalDirectory or the FilesystemMirrorSource would
|
||||||
|
// expect to find an unpacked copy of the receiving PackageMeta.
|
||||||
|
//
|
||||||
|
// The result always uses forward slashes as path separator, even on Windows,
|
||||||
|
// to produce a consistent result on all platforms. Windows accepts both
|
||||||
|
// direction of slash as long as each individual path string is self-consistent.
|
||||||
|
func (m PackageMeta) UnpackedDirectoryPath(baseDir string) string {
|
||||||
|
return UnpackedDirectoryPathForPackage(baseDir, m.Provider, m.Version, m.TargetPlatform)
|
||||||
|
}
|
||||||
|
|
||||||
// PackageLocation represents a location where a provider distribution package
|
// PackageLocation represents a location where a provider distribution package
|
||||||
// can be obtained. A value of this type contains one of the following
|
// can be obtained. A value of this type contains one of the following
|
||||||
// concrete types: PackageLocalArchive, PackageLocalDir, or PackageHTTPURL.
|
// concrete types: PackageLocalArchive, PackageLocalDir, or PackageHTTPURL.
|
||||||
|
|
Loading…
Reference in New Issue