diff --git a/go.mod b/go.mod index c7f95fd3..9a33ce37 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.0 require ( github.com/go-chef/chef v0.29.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 - github.com/hashicorp/terraform-plugin-docs v0.19.2 + github.com/hashicorp/terraform-plugin-docs v0.19.4 github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 ) @@ -37,7 +37,7 @@ require ( github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.7.0 // indirect - github.com/hashicorp/hc-install v0.6.4 // indirect + github.com/hashicorp/hc-install v0.7.0 // indirect github.com/hashicorp/hcl/v2 v2.21.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.21.0 // indirect diff --git a/go.sum b/go.sum index 9d8eed2b..26bae80e 100644 --- a/go.sum +++ b/go.sum @@ -94,8 +94,8 @@ github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/C github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.6.4 h1:QLqlM56/+SIIGvGcfFiwMY3z5WGXT066suo/v9Km8e0= -github.com/hashicorp/hc-install v0.6.4/go.mod h1:05LWLy8TD842OtgcfBbOT0WMoInBMUSHjmDx10zuBIA= +github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk= +github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA= github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14= github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= @@ -104,8 +104,8 @@ github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVW github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg= github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec= github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A= -github.com/hashicorp/terraform-plugin-docs v0.19.2 h1:YjdKa1vuqt9EnPYkkrv9HnGZz175HhSJ7Vsn8yZeWus= -github.com/hashicorp/terraform-plugin-docs v0.19.2/go.mod h1:gad2aP6uObFKhgNE8DR9nsEuEQnibp7il0jZYYOunWY= +github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSeyEljqjH3G39w28JK4c= +github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA= github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co= github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= diff --git a/vendor/github.com/hashicorp/hc-install/README.md b/vendor/github.com/hashicorp/hc-install/README.md index 6e78b5a6..0d55191b 100644 --- a/vendor/github.com/hashicorp/hc-install/README.md +++ b/vendor/github.com/hashicorp/hc-install/README.md @@ -14,55 +14,55 @@ the library in ad-hoc or CI shell scripting outside of Go. `hc-install` does **not**: - - Determine suitable installation path based on target system. e.g. in `/usr/bin` or `/usr/local/bin` on Unix based system. - - Deal with execution of installed binaries (via service files or otherwise). - - Upgrade existing binaries on your system. - - Add nor link downloaded binaries to your `$PATH`. +- Determine suitable installation path based on target system. e.g. in `/usr/bin` or `/usr/local/bin` on Unix based system. +- Deal with execution of installed binaries (via service files or otherwise). +- Upgrade existing binaries on your system. +- Add nor link downloaded binaries to your `$PATH`. ## API The `Installer` offers a few high-level methods: - - `Ensure(context.Context, []src.Source)` to find, install, or build a product version - - `Install(context.Context, []src.Installable)` to install a product version +- `Ensure(context.Context, []src.Source)` to find, install, or build a product version +- `Install(context.Context, []src.Installable)` to install a product version ### Sources The `Installer` methods accept number of different `Source` types. Each comes with different trade-offs described below. - - `fs.{AnyVersion,ExactVersion,Version}` - Finds a binary in `$PATH` (or additional paths) - - **Pros:** - - This is most convenient when you already have the product installed on your system +- `fs.{AnyVersion,ExactVersion,Version}` - Finds a binary in `$PATH` (or additional paths) + - **Pros:** + - This is most convenient when you already have the product installed on your system which you already manage. - - **Cons:** - - Only relies on a single version, expects _you_ to manage the installation - - _Not recommended_ for any environment where product installation is not controlled or managed by you (e.g. default GitHub Actions image managed by GitHub) - - `releases.{LatestVersion,ExactVersion}` - Downloads, verifies & installs any known product from `releases.hashicorp.com` - - **Pros:** - - Fast and reliable way of obtaining any pre-built version of any product - - Allows installation of enterprise versions - - **Cons:** - - Installation may consume some bandwidth, disk space and a little time - - Potentially less stable builds (see `checkpoint` below) - - `checkpoint.LatestVersion` - Downloads, verifies & installs any known product available in HashiCorp Checkpoint - - **Pros:** - - Checkpoint typically contains only product versions considered stable - - **Cons:** - - Installation may consume some bandwidth, disk space and a little time - - Currently doesn't allow installation of old versions or enterprise versions (see `releases` above) - - `build.GitRevision` - Clones raw source code and builds the product from it - - **Pros:** - - Useful for catching bugs and incompatibilities as early as possible (prior to product release). - - **Cons:** - - Building from scratch can consume significant amount of time & resources (CPU, memory, bandwith, disk space) - - There are no guarantees that build instructions will always be up-to-date - - There's increased likelihood of build containing bugs prior to release - - Any CI builds relying on this are likely to be fragile + - **Cons:** + - Only relies on a single version, expects _you_ to manage the installation + - _Not recommended_ for any environment where product installation is not controlled or managed by you (e.g. default GitHub Actions image managed by GitHub) +- `releases.{LatestVersion,ExactVersion}` - Downloads, verifies & installs any known product from `releases.hashicorp.com` + - **Pros:** + - Fast and reliable way of obtaining any pre-built version of any product + - Allows installation of enterprise versions + - **Cons:** + - Installation may consume some bandwidth, disk space and a little time + - Potentially less stable builds (see `checkpoint` below) +- `checkpoint.LatestVersion` - Downloads, verifies & installs any known product available in HashiCorp Checkpoint + - **Pros:** + - Checkpoint typically contains only product versions considered stable + - **Cons:** + - Installation may consume some bandwidth, disk space and a little time + - Currently doesn't allow installation of old versions or enterprise versions (see `releases` above) +- `build.GitRevision` - Clones raw source code and builds the product from it + - **Pros:** + - Useful for catching bugs and incompatibilities as early as possible (prior to product release). + - **Cons:** + - Building from scratch can consume significant amount of time & resources (CPU, memory, bandwidth, disk space) + - There are no guarantees that build instructions will always be up-to-date + - There's increased likelihood of build containing bugs prior to release + - Any CI builds relying on this are likely to be fragile ## Example Usage -See examples at https://pkg.go.dev/github.com/hashicorp/hc-install#example-Installer. +See examples at . ## CLI @@ -70,9 +70,9 @@ In addition to the Go library, which is the intended primary use case of `hc-ins The CLI comes with some trade-offs: - - more limited interface compared to the flexible Go API (installs specific versions of products via `releases.ExactVersion`) - - minimal environment pre-requisites (no need to compile Go code) - - see ["hc-install is not a package manager"](https://github.com/hashicorp/hc-install#hc-install-is-not-a-package-manager) +- more limited interface compared to the flexible Go API (installs specific versions of products via `releases.ExactVersion`) +- minimal environment pre-requisites (no need to compile Go code) +- see ["hc-install is not a package manager"](https://github.com/hashicorp/hc-install#hc-install-is-not-a-package-manager) ### Installation @@ -82,7 +82,7 @@ Given that one of the key roles of the CLI/library is integrity checking, you sh [Homebrew](https://brew.sh) -``` +```sh brew install hashicorp/tap/hc-install ``` @@ -102,19 +102,23 @@ You can follow the instructions in the [Official Packaging Guide](https://www.ha ### Usage -``` +```text Usage: hc-install install [options] -version This command installs a HashiCorp product. Options: -version [REQUIRED] Version of product to install. - -path Path to directory where the product will be installed. Defaults - to current working directory. + -path Path to directory where the product will be installed. + Defaults to current working directory. + -log-file Path to file where logs will be written. /dev/stdout + or /dev/stderr can be used to log to STDOUT/STDERR. ``` + ```sh hc-install install -version 1.3.7 terraform ``` -``` + +```sh hc-install: will install terraform@1.3.7 installed terraform@1.3.7 to /current/working/dir/terraform ``` diff --git a/vendor/github.com/hashicorp/hc-install/checkpoint/latest_version.go b/vendor/github.com/hashicorp/hc-install/checkpoint/latest_version.go index 2cd5379f..7a8aa3d9 100644 --- a/vendor/github.com/hashicorp/hc-install/checkpoint/latest_version.go +++ b/vendor/github.com/hashicorp/hc-install/checkpoint/latest_version.go @@ -6,7 +6,7 @@ package checkpoint import ( "context" "fmt" - "io/ioutil" + "io" "log" "os" "path/filepath" @@ -24,7 +24,7 @@ import ( var ( defaultTimeout = 30 * time.Second - discardLogger = log.New(ioutil.Discard, "", 0) + discardLogger = log.New(io.Discard, "", 0) ) // LatestVersion installs the latest version known to Checkpoint @@ -101,7 +101,7 @@ func (lv *LatestVersion) Install(ctx context.Context) (string, error) { if dstDir == "" { var err error dirName := fmt.Sprintf("%s_*", lv.Product.Name) - dstDir, err = ioutil.TempDir("", dirName) + dstDir, err = os.MkdirTemp("", dirName) if err != nil { return "", err } @@ -126,9 +126,9 @@ func (lv *LatestVersion) Install(ctx context.Context) (string, error) { if lv.ArmoredPublicKey != "" { d.ArmoredPublicKey = lv.ArmoredPublicKey } - zipFilePath, err := d.DownloadAndUnpack(ctx, pv, dstDir, "") - if zipFilePath != "" { - lv.pathsToRemove = append(lv.pathsToRemove, zipFilePath) + up, err := d.DownloadAndUnpack(ctx, pv, dstDir, "") + if up != nil { + lv.pathsToRemove = append(lv.pathsToRemove, up.PathsToRemove...) } if err != nil { return "", err diff --git a/vendor/github.com/hashicorp/hc-install/fs/fs.go b/vendor/github.com/hashicorp/hc-install/fs/fs.go index 216df2c2..ac6f5cf9 100644 --- a/vendor/github.com/hashicorp/hc-install/fs/fs.go +++ b/vendor/github.com/hashicorp/hc-install/fs/fs.go @@ -4,14 +4,14 @@ package fs import ( - "io/ioutil" + "io" "log" "time" ) var ( defaultTimeout = 10 * time.Second - discardLogger = log.New(ioutil.Discard, "", 0) + discardLogger = log.New(io.Discard, "", 0) ) type fileCheckFunc func(path string) error diff --git a/vendor/github.com/hashicorp/hc-install/fs/fs_unix.go b/vendor/github.com/hashicorp/hc-install/fs/fs_unix.go index eebd98b8..5aed8444 100644 --- a/vendor/github.com/hashicorp/hc-install/fs/fs_unix.go +++ b/vendor/github.com/hashicorp/hc-install/fs/fs_unix.go @@ -16,9 +16,7 @@ import ( func lookupDirs(extraDirs []string) []string { pathVar := os.Getenv("PATH") dirs := filepath.SplitList(pathVar) - for _, ep := range extraDirs { - dirs = append(dirs, ep) - } + dirs = append(dirs, extraDirs...) return dirs } diff --git a/vendor/github.com/hashicorp/hc-install/installer.go b/vendor/github.com/hashicorp/hc-install/installer.go index 6c704eed..01c1fdee 100644 --- a/vendor/github.com/hashicorp/hc-install/installer.go +++ b/vendor/github.com/hashicorp/hc-install/installer.go @@ -6,7 +6,7 @@ package install import ( "context" "fmt" - "io/ioutil" + "io" "log" "github.com/hashicorp/go-multierror" @@ -23,7 +23,7 @@ type Installer struct { type RemoveFunc func(ctx context.Context) error func NewInstaller() *Installer { - discardLogger := log.New(ioutil.Discard, "", 0) + discardLogger := log.New(io.Discard, "", 0) return &Installer{ logger: discardLogger, } diff --git a/vendor/github.com/hashicorp/hc-install/internal/build/go_build.go b/vendor/github.com/hashicorp/hc-install/internal/build/go_build.go index 504bf45a..6eef755b 100644 --- a/vendor/github.com/hashicorp/hc-install/internal/build/go_build.go +++ b/vendor/github.com/hashicorp/hc-install/internal/build/go_build.go @@ -7,7 +7,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "io" "log" "os" "os/exec" @@ -17,7 +17,7 @@ import ( "golang.org/x/mod/modfile" ) -var discardLogger = log.New(ioutil.Discard, "", 0) +var discardLogger = log.New(io.Discard, "", 0) // GoBuild represents a Go builder (to run "go build") type GoBuild struct { @@ -161,7 +161,7 @@ type CleanupFunc func(context.Context) func guessRequiredGoVersion(repoDir string) (*version.Version, bool) { goEnvFile := filepath.Join(repoDir, ".go-version") if fi, err := os.Stat(goEnvFile); err == nil && !fi.IsDir() { - b, err := ioutil.ReadFile(goEnvFile) + b, err := os.ReadFile(goEnvFile) if err != nil { return nil, false } @@ -174,7 +174,7 @@ func guessRequiredGoVersion(repoDir string) (*version.Version, bool) { goModFile := filepath.Join(repoDir, "go.mod") if fi, err := os.Stat(goModFile); err == nil && !fi.IsDir() { - b, err := ioutil.ReadFile(goModFile) + b, err := os.ReadFile(goModFile) if err != nil { return nil, false } diff --git a/vendor/github.com/hashicorp/hc-install/internal/releasesjson/checksum_downloader.go b/vendor/github.com/hashicorp/hc-install/internal/releasesjson/checksum_downloader.go index 843de8cd..59dd1a1f 100644 --- a/vendor/github.com/hashicorp/hc-install/internal/releasesjson/checksum_downloader.go +++ b/vendor/github.com/hashicorp/hc-install/internal/releasesjson/checksum_downloader.go @@ -55,7 +55,7 @@ func (cd *ChecksumDownloader) DownloadAndVerifyChecksums(ctx context.Context) (C client := httpclient.NewHTTPClient() sigURL := fmt.Sprintf("%s/%s/%s/%s", cd.BaseURL, url.PathEscape(cd.ProductVersion.Name), - url.PathEscape(cd.ProductVersion.RawVersion), + url.PathEscape(cd.ProductVersion.Version.String()), url.PathEscape(sigFilename)) cd.Logger.Printf("downloading signature from %s", sigURL) @@ -76,7 +76,7 @@ func (cd *ChecksumDownloader) DownloadAndVerifyChecksums(ctx context.Context) (C shasumsURL := fmt.Sprintf("%s/%s/%s/%s", cd.BaseURL, url.PathEscape(cd.ProductVersion.Name), - url.PathEscape(cd.ProductVersion.RawVersion), + url.PathEscape(cd.ProductVersion.Version.String()), url.PathEscape(cd.ProductVersion.SHASUMS)) cd.Logger.Printf("downloading checksums from %s", shasumsURL) diff --git a/vendor/github.com/hashicorp/hc-install/internal/releasesjson/downloader.go b/vendor/github.com/hashicorp/hc-install/internal/releasesjson/downloader.go index 146c1cf0..a1139b58 100644 --- a/vendor/github.com/hashicorp/hc-install/internal/releasesjson/downloader.go +++ b/vendor/github.com/hashicorp/hc-install/internal/releasesjson/downloader.go @@ -10,7 +10,6 @@ import ( "crypto/sha256" "fmt" "io" - "io/ioutil" "log" "net/http" "net/url" @@ -29,14 +28,18 @@ type Downloader struct { BaseURL string } -func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, binDir string, licenseDir string) (zipFilePath string, err error) { +type UnpackedProduct struct { + PathsToRemove []string +} + +func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, binDir string, licenseDir string) (up *UnpackedProduct, err error) { if len(pv.Builds) == 0 { - return "", fmt.Errorf("no builds found for %s %s", pv.Name, pv.Version) + return nil, fmt.Errorf("no builds found for %s %s", pv.Name, pv.Version) } pb, ok := pv.Builds.FilterBuild(runtime.GOOS, runtime.GOARCH, "zip") if !ok { - return "", fmt.Errorf("no ZIP archive found for %s %s %s/%s", + return nil, fmt.Errorf("no ZIP archive found for %s %s %s/%s", pv.Name, pv.Version, runtime.GOOS, runtime.GOARCH) } @@ -50,12 +53,12 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, } verifiedChecksums, err := v.DownloadAndVerifyChecksums(ctx) if err != nil { - return "", err + return nil, err } var ok bool verifiedChecksum, ok = verifiedChecksums[pb.Filename] if !ok { - return "", fmt.Errorf("no checksum found for %q", pb.Filename) + return nil, fmt.Errorf("no checksum found for %q", pb.Filename) } } @@ -63,16 +66,17 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, archiveURL := pb.URL if d.BaseURL != "" { - // ensure that absolute download links from mocked responses - // are still pointing to the mock server if one is set + // If custom URL is set, use that instead of the one from the JSON. + // Also ensures that absolute download links from mocked responses + // are still pointing to the mock server if one is set. baseURL, err := url.Parse(d.BaseURL) if err != nil { - return "", err + return nil, err } u, err := url.Parse(archiveURL) if err != nil { - return "", err + return nil, err } u.Scheme = baseURL.Scheme u.Host = baseURL.Host @@ -83,15 +87,15 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, req, err := http.NewRequestWithContext(ctx, http.MethodGet, archiveURL, nil) if err != nil { - return "", fmt.Errorf("failed to create request for %q: %w", archiveURL, err) + return nil, fmt.Errorf("failed to create request for %q: %w", archiveURL, err) } resp, err := client.Do(req) if err != nil { - return "", err + return nil, err } if resp.StatusCode != 200 { - return "", fmt.Errorf("failed to download ZIP archive from %q: %s", archiveURL, resp.Status) + return nil, fmt.Errorf("failed to download ZIP archive from %q: %s", archiveURL, resp.Status) } defer resp.Body.Close() @@ -100,19 +104,22 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, contentType := resp.Header.Get("content-type") if !contentTypeIsZip(contentType) { - return "", fmt.Errorf("unexpected content-type: %s (expected any of %q)", + return nil, fmt.Errorf("unexpected content-type: %s (expected any of %q)", contentType, zipMimeTypes) } expectedSize := resp.ContentLength - pkgFile, err := ioutil.TempFile("", pb.Filename) + pkgFile, err := os.CreateTemp("", pb.Filename) if err != nil { - return "", err + return nil, err } defer pkgFile.Close() pkgFilePath, err := filepath.Abs(pkgFile.Name()) + up = &UnpackedProduct{} + up.PathsToRemove = append(up.PathsToRemove, pkgFilePath) + d.Logger.Printf("copying %q (%d bytes) to %s", pb.Filename, expectedSize, pkgFile.Name()) var bytesCopied int64 @@ -123,12 +130,12 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, bytesCopied, err = io.Copy(h, r) if err != nil { - return "", err + return nil, err } calculatedSum := h.Sum(nil) if !bytes.Equal(calculatedSum, verifiedChecksum) { - return pkgFilePath, fmt.Errorf( + return up, fmt.Errorf( "checksum mismatch (expected: %x, got: %x)", verifiedChecksum, calculatedSum, ) @@ -136,14 +143,14 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, } else { bytesCopied, err = io.Copy(pkgFile, pkgReader) if err != nil { - return pkgFilePath, err + return up, err } } d.Logger.Printf("copied %d bytes to %s", bytesCopied, pkgFile.Name()) if expectedSize != 0 && bytesCopied != int64(expectedSize) { - return pkgFilePath, fmt.Errorf( + return up, fmt.Errorf( "unexpected size (downloaded: %d, expected: %d)", bytesCopied, expectedSize, ) @@ -151,7 +158,7 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, r, err := zip.OpenReader(pkgFile.Name()) if err != nil { - return pkgFilePath, err + return up, err } defer r.Close() @@ -163,7 +170,7 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, } srcFile, err := f.Open() if err != nil { - return pkgFilePath, err + return up, err } // Determine the appropriate destination file path @@ -174,20 +181,25 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, d.Logger.Printf("unpacking %s to %s", f.Name, dstDir) dstPath := filepath.Join(dstDir, f.Name) + + if isLicenseFile(f.Name) { + up.PathsToRemove = append(up.PathsToRemove, dstPath) + } + dstFile, err := os.Create(dstPath) if err != nil { - return pkgFilePath, err + return up, err } _, err = io.Copy(dstFile, srcFile) if err != nil { - return pkgFilePath, err + return up, err } srcFile.Close() dstFile.Close() } - return pkgFilePath, nil + return up, nil } // The production release site uses consistent single mime type @@ -207,11 +219,13 @@ func contentTypeIsZip(contentType string) bool { return false } -// Enterprise products have a few additional license files -// that need to be extracted to a separate directory +// Product archives may have a few license files +// which may be extracted to a separate directory +// and may need to be tracked for later cleanup. var licenseFiles = []string{ "EULA.txt", "TermsOfEvaluation.txt", + "LICENSE.txt", } func isLicenseFile(filename string) bool { diff --git a/vendor/github.com/hashicorp/hc-install/internal/releasesjson/product_version.go b/vendor/github.com/hashicorp/hc-install/internal/releasesjson/product_version.go index 99b811a6..94152b13 100644 --- a/vendor/github.com/hashicorp/hc-install/internal/releasesjson/product_version.go +++ b/vendor/github.com/hashicorp/hc-install/internal/releasesjson/product_version.go @@ -9,8 +9,7 @@ import "github.com/hashicorp/go-version" // "consul 0.5.1". A ProductVersion may have one or more builds. type ProductVersion struct { Name string `json:"name"` - RawVersion string `json:"version"` - Version *version.Version `json:"-"` + Version *version.Version `json:"version"` SHASUMS string `json:"shasums,omitempty"` SHASUMSSig string `json:"shasums_signature,omitempty"` SHASUMSSigs []string `json:"shasums_signatures,omitempty"` diff --git a/vendor/github.com/hashicorp/hc-install/internal/releasesjson/releases.go b/vendor/github.com/hashicorp/hc-install/internal/releasesjson/releases.go index 755019f2..4c0bab00 100644 --- a/vendor/github.com/hashicorp/hc-install/internal/releasesjson/releases.go +++ b/vendor/github.com/hashicorp/hc-install/internal/releasesjson/releases.go @@ -7,7 +7,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "log" "net/http" "net/url" @@ -55,7 +55,7 @@ type Releases struct { func NewReleases() *Releases { return &Releases{ - logger: log.New(ioutil.Discard, "", 0), + logger: log.New(io.Discard, "", 0), BaseURL: defaultBaseURL, } } @@ -95,7 +95,7 @@ func (r *Releases) ListProductVersions(ctx context.Context, productName string) r.logger.Printf("received %s", resp.Status) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } @@ -153,7 +153,7 @@ func (r *Releases) GetProductVersion(ctx context.Context, product string, versio r.logger.Printf("received %s", resp.Status) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/vendor/github.com/hashicorp/hc-install/releases/exact_version.go b/vendor/github.com/hashicorp/hc-install/releases/exact_version.go index e42f4d23..179f0b4b 100644 --- a/vendor/github.com/hashicorp/hc-install/releases/exact_version.go +++ b/vendor/github.com/hashicorp/hc-install/releases/exact_version.go @@ -6,7 +6,6 @@ package releases import ( "context" "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -37,7 +36,10 @@ type ExactVersion struct { // instead of built-in pubkey to verify signature of downloaded checksums ArmoredPublicKey string - apiBaseURL string + // ApiBaseURL is an optional field that specifies a custom URL to download the product from. + // If ApiBaseURL is set, the product will be downloaded from this base URL instead of the default site. + // Note: The directory structure of the custom URL must match the HashiCorp releases site (including the index.json files). + ApiBaseURL string logger *log.Logger pathsToRemove []string } @@ -93,7 +95,7 @@ func (ev *ExactVersion) Install(ctx context.Context) (string, error) { if dstDir == "" { var err error dirName := fmt.Sprintf("%s_*", ev.Product.Name) - dstDir, err = ioutil.TempDir("", dirName) + dstDir, err = os.MkdirTemp("", dirName) if err != nil { return "", err } @@ -103,8 +105,8 @@ func (ev *ExactVersion) Install(ctx context.Context) (string, error) { ev.log().Printf("will install into dir at %s", dstDir) rels := rjson.NewReleases() - if ev.apiBaseURL != "" { - rels.BaseURL = ev.apiBaseURL + if ev.ApiBaseURL != "" { + rels.BaseURL = ev.ApiBaseURL } rels.SetLogger(ev.log()) installVersion := ev.Version @@ -125,17 +127,17 @@ func (ev *ExactVersion) Install(ctx context.Context) (string, error) { if ev.ArmoredPublicKey != "" { d.ArmoredPublicKey = ev.ArmoredPublicKey } - if ev.apiBaseURL != "" { - d.BaseURL = ev.apiBaseURL + if ev.ApiBaseURL != "" { + d.BaseURL = ev.ApiBaseURL } licenseDir := "" if ev.Enterprise != nil { licenseDir = ev.Enterprise.LicenseDir } - zipFilePath, err := d.DownloadAndUnpack(ctx, pv, dstDir, licenseDir) - if zipFilePath != "" { - ev.pathsToRemove = append(ev.pathsToRemove, zipFilePath) + up, err := d.DownloadAndUnpack(ctx, pv, dstDir, licenseDir) + if up != nil { + ev.pathsToRemove = append(ev.pathsToRemove, up.PathsToRemove...) } if err != nil { return "", err diff --git a/vendor/github.com/hashicorp/hc-install/releases/latest_version.go b/vendor/github.com/hashicorp/hc-install/releases/latest_version.go index 9893b223..c4888f4a 100644 --- a/vendor/github.com/hashicorp/hc-install/releases/latest_version.go +++ b/vendor/github.com/hashicorp/hc-install/releases/latest_version.go @@ -6,7 +6,6 @@ package releases import ( "context" "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -37,7 +36,10 @@ type LatestVersion struct { // instead of built-in pubkey to verify signature of downloaded checksums ArmoredPublicKey string - apiBaseURL string + // ApiBaseURL is an optional field that specifies a custom URL to download the product from. + // If ApiBaseURL is set, the product will be downloaded from this base URL instead of the default site. + // Note: The directory structure of the custom URL must match the HashiCorp releases site (including the index.json files). + ApiBaseURL string logger *log.Logger pathsToRemove []string } @@ -89,7 +91,7 @@ func (lv *LatestVersion) Install(ctx context.Context) (string, error) { if dstDir == "" { var err error dirName := fmt.Sprintf("%s_*", lv.Product.Name) - dstDir, err = ioutil.TempDir("", dirName) + dstDir, err = os.MkdirTemp("", dirName) if err != nil { return "", err } @@ -99,8 +101,8 @@ func (lv *LatestVersion) Install(ctx context.Context) (string, error) { lv.log().Printf("will install into dir at %s", dstDir) rels := rjson.NewReleases() - if lv.apiBaseURL != "" { - rels.BaseURL = lv.apiBaseURL + if lv.ApiBaseURL != "" { + rels.BaseURL = lv.ApiBaseURL } rels.SetLogger(lv.log()) versions, err := rels.ListProductVersions(ctx, lv.Product.Name) @@ -126,16 +128,16 @@ func (lv *LatestVersion) Install(ctx context.Context) (string, error) { if lv.ArmoredPublicKey != "" { d.ArmoredPublicKey = lv.ArmoredPublicKey } - if lv.apiBaseURL != "" { - d.BaseURL = lv.apiBaseURL + if lv.ApiBaseURL != "" { + d.BaseURL = lv.ApiBaseURL } licenseDir := "" if lv.Enterprise != nil { licenseDir = lv.Enterprise.LicenseDir } - zipFilePath, err := d.DownloadAndUnpack(ctx, versionToInstall, dstDir, licenseDir) - if zipFilePath != "" { - lv.pathsToRemove = append(lv.pathsToRemove, zipFilePath) + up, err := d.DownloadAndUnpack(ctx, versionToInstall, dstDir, licenseDir) + if up != nil { + lv.pathsToRemove = append(lv.pathsToRemove, up.PathsToRemove...) } if err != nil { return "", err diff --git a/vendor/github.com/hashicorp/hc-install/releases/releases.go b/vendor/github.com/hashicorp/hc-install/releases/releases.go index 7bef49ba..a24db6c6 100644 --- a/vendor/github.com/hashicorp/hc-install/releases/releases.go +++ b/vendor/github.com/hashicorp/hc-install/releases/releases.go @@ -4,7 +4,7 @@ package releases import ( - "io/ioutil" + "io" "log" "time" ) @@ -12,5 +12,5 @@ import ( var ( defaultInstallTimeout = 30 * time.Second defaultListTimeout = 10 * time.Second - discardLogger = log.New(ioutil.Discard, "", 0) + discardLogger = log.New(io.Discard, "", 0) ) diff --git a/vendor/github.com/hashicorp/hc-install/version/VERSION b/vendor/github.com/hashicorp/hc-install/version/VERSION index d2b13eb6..faef31a4 100644 --- a/vendor/github.com/hashicorp/hc-install/version/VERSION +++ b/vendor/github.com/hashicorp/hc-install/version/VERSION @@ -1 +1 @@ -0.6.4 +0.7.0 diff --git a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/check/directory.go b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/check/directory.go index 3aefa6a1..3c3183b7 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/check/directory.go +++ b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/check/directory.go @@ -118,42 +118,6 @@ func MixedDirectoriesCheck(docFiles []string) error { return nil } -// NumberOfFilesCheck verifies that documentation is below the Terraform Registry storage limit. -// This check presumes that all provided directories are valid, e.g. that directory checking -// for invalid or mixed directory structures was previously completed. -func NumberOfFilesCheck(docFiles []string) error { - var numberOfFiles int - - directoryCounts := make(map[string]int) - for _, file := range docFiles { - directory := filepath.Dir(file) - - // Ignore CDKTF files. The file limit is per-language and presumably there is one CDKTF file per source HCL file. - if IsValidCdktfDirectory(directory) { - continue - } - - if directory == RegistryIndexDirectory || directory == filepath.FromSlash(LegacyIndexDirectory) { - continue - } - - directoryCounts[directory]++ - } - - for directory, count := range directoryCounts { - - log.Printf("[TRACE] Found %d documentation files in directory: %s", count, directory) - numberOfFiles = numberOfFiles + count - } - - log.Printf("[DEBUG] Found %d documentation files with limit of %d", numberOfFiles, RegistryMaximumNumberOfFiles) - if numberOfFiles >= RegistryMaximumNumberOfFiles { - return fmt.Errorf("exceeded maximum (%d) number of documentation files for Terraform Registry: %d", RegistryMaximumNumberOfFiles, numberOfFiles) - } - - return nil -} - func IsValidLegacyDirectory(directory string) bool { for _, validLegacyDirectory := range ValidLegacyDirectories { if directory == filepath.FromSlash(validLegacyDirectory) { diff --git a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/generate.go b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/generate.go index 1a0c7f15..77dbc96f 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/generate.go +++ b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/generate.go @@ -72,7 +72,7 @@ func (cmd *generateCmd) Help() string { func (cmd *generateCmd) Flags() *flag.FlagSet { fs := flag.NewFlagSet("generate", flag.ExitOnError) - fs.StringVar(&cmd.flagProviderName, "provider-name", "", "provider name, as used in Terraform configurations") + fs.StringVar(&cmd.flagProviderName, "provider-name", "", "provider name, as used in Terraform configurations; defaults to the --provider-dir short name (after removing `terraform-provider-` prefix)") fs.StringVar(&cmd.flagProviderDir, "provider-dir", "", "relative or absolute path to the root provider code directory when running the command outside the root provider code directory") fs.StringVar(&cmd.flagProvidersSchema, "providers-schema", "", "path to the providers schema JSON file, which contains the output of the terraform providers schema -json command. Setting this flag will skip building the provider and calling Terraform CLI") fs.StringVar(&cmd.flagRenderedProviderName, "rendered-provider-name", "", "provider name, as generated in documentation (ex. page titles, ...)") diff --git a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/migrate.go b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/migrate.go index d0e9ca3a..14e39ec1 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/migrate.go +++ b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/migrate.go @@ -68,7 +68,7 @@ func (cmd *migrateCmd) Flags() *flag.FlagSet { fs.StringVar(&cmd.flagProviderDir, "provider-dir", "", "relative or absolute path to the root provider code directory; this will default to the current working directory if not set") fs.StringVar(&cmd.flagTemplatesDir, "templates-dir", "templates", "new website templates directory based on provider-dir; files will be migrated to this directory") fs.StringVar(&cmd.flagExamplesDir, "examples-dir", "examples", "examples directory based on provider-dir; extracted code examples will be migrated to this directory") - fs.StringVar(&cmd.flagProviderName, "provider-name", "", "provider name, as used in Terraform configurations; this will default to provider-dir basename if not set") + fs.StringVar(&cmd.flagProviderName, "provider-name", "", "provider name, as used in Terraform configurations; defaults to the --provider-dir short name (after removing `terraform-provider-` prefix)") return fs } diff --git a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/validate.go b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/validate.go index 8999c4e8..55107f3c 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/validate.go +++ b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/cmd/validate.go @@ -65,7 +65,7 @@ func (cmd *validateCmd) Help() string { func (cmd *validateCmd) Flags() *flag.FlagSet { fs := flag.NewFlagSet("validate", flag.ExitOnError) - fs.StringVar(&cmd.flagProviderName, "provider-name", "", "provider name, as used in Terraform configurations") + fs.StringVar(&cmd.flagProviderName, "provider-name", "", "provider name, as used in Terraform configurations; defaults to the --provider-dir short name (after removing `terraform-provider-` prefix)") fs.StringVar(&cmd.flagProviderDir, "provider-dir", "", "relative or absolute path to the root provider code directory; this will default to the current working directory if not set") fs.StringVar(&cmd.flagProvidersSchema, "providers-schema", "", "path to the providers schema JSON file, which contains the output of the terraform providers schema -json command. Setting this flag will skip building the provider and calling Terraform CLI") fs.StringVar(&cmd.tfVersion, "tf-version", "", "terraform binary version to download. If not provided, will look for a terraform binary in the local environment. If not found in the environment, will download the latest version of Terraform") diff --git a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/provider/validate.go b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/provider/validate.go index 6732091e..a72be373 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/provider/validate.go +++ b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/provider/validate.go @@ -139,6 +139,10 @@ func (v *validator) validate(ctx context.Context) error { var err error + if v.providerName == "" { + v.providerName = filepath.Base(v.providerDir) + } + if v.providersSchemaPath == "" { v.logger.infof("exporting schema from Terraform") v.providerSchema, err = TerraformProviderSchemaFromTerraform(ctx, v.providerName, v.providerDir, v.tfVersion, v.logger) @@ -166,10 +170,6 @@ func (v *validator) validate(ctx context.Context) error { err = check.MixedDirectoriesCheck(files) result = errors.Join(result, err) - v.logger.infof("running number of files check") - err = check.NumberOfFilesCheck(files) - result = errors.Join(result, err) - if dirExists(filepath.Join(v.providerDir, "docs")) { v.logger.infof("detected static docs directory, running checks") err = v.validateStaticDocs(filepath.Join(v.providerDir, "docs")) diff --git a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/schemamd/render.go b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/schemamd/render.go index 210ede34..a459d0ba 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-docs/internal/schemamd/render.go +++ b/vendor/github.com/hashicorp/terraform-plugin-docs/internal/schemamd/render.go @@ -466,7 +466,9 @@ func writeObjectChildren(w io.Writer, parents []string, ty cty.Type, group group for _, name := range sortedNames { att := atts[name] - path := append(parents, name) + path := make([]string, len(parents), len(parents)+1) + copy(path, parents) + path = append(path, name) nt, err := writeObjectAttribute(w, path, att, group) if err != nil { @@ -522,7 +524,9 @@ func writeNestedAttributeChildren(w io.Writer, parents []string, nestedAttribute for _, name := range names { att := nestedAttributes.Attributes[name] - path := append(parents, name) + path := make([]string, len(parents), len(parents)+1) + copy(path, parents) + path = append(path, name) nt, err := writeAttribute(w, path, att, group) if err != nil { diff --git a/vendor/github.com/posener/complete/readme.md b/vendor/github.com/posener/complete/README.md similarity index 100% rename from vendor/github.com/posener/complete/readme.md rename to vendor/github.com/posener/complete/README.md diff --git a/vendor/modules.txt b/vendor/modules.txt index 5837b0fa..44407fba 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -126,7 +126,7 @@ github.com/hashicorp/go-uuid # github.com/hashicorp/go-version v1.7.0 ## explicit github.com/hashicorp/go-version -# github.com/hashicorp/hc-install v0.6.4 +# github.com/hashicorp/hc-install v0.7.0 ## explicit; go 1.18 github.com/hashicorp/hc-install github.com/hashicorp/hc-install/checkpoint @@ -157,7 +157,7 @@ github.com/hashicorp/terraform-exec/tfexec # github.com/hashicorp/terraform-json v0.22.1 ## explicit; go 1.18 github.com/hashicorp/terraform-json -# github.com/hashicorp/terraform-plugin-docs v0.19.2 +# github.com/hashicorp/terraform-plugin-docs v0.19.4 ## explicit; go 1.21 github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs/build