Bump github.com/hashicorp/terraform-plugin-sdk/v2 from 2.24.1 to 2.26.0
Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.24.1 to 2.26.0. - [Release notes](https://github.com/hashicorp/terraform-plugin-sdk/releases) - [Changelog](https://github.com/hashicorp/terraform-plugin-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/terraform-plugin-sdk/compare/v2.24.1...v2.26.0) --- updated-dependencies: - dependency-name: github.com/hashicorp/terraform-plugin-sdk/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
2
vendor/github.com/hashicorp/hc-install/.go-version
generated
vendored
2
vendor/github.com/hashicorp/hc-install/.go-version
generated
vendored
@ -1 +1 @@
|
||||
1.17.3
|
||||
1.19.5
|
||||
|
29
vendor/github.com/hashicorp/hc-install/.goreleaser.yml
generated
vendored
29
vendor/github.com/hashicorp/hc-install/.goreleaser.yml
generated
vendored
@ -1,29 +0,0 @@
|
||||
project_name: tfinstall
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
main: ./cmd/hcinstall/main.go
|
||||
mod_timestamp: '{{ .CommitTimestamp }}'
|
||||
id: "tfinstall"
|
||||
binary: tfinstall
|
||||
flags:
|
||||
- -trimpath
|
||||
ldflags:
|
||||
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
- windows
|
||||
goarch:
|
||||
- amd64
|
||||
- arm
|
||||
- arm64
|
||||
archives:
|
||||
- files: []
|
||||
format: zip
|
||||
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
|
||||
checksum:
|
||||
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
|
||||
algorithm: sha256
|
||||
changelog:
|
||||
skip: true
|
2
vendor/github.com/hashicorp/hc-install/LICENSE
generated
vendored
2
vendor/github.com/hashicorp/hc-install/LICENSE
generated
vendored
@ -1,3 +1,5 @@
|
||||
Copyright (c) 2020 HashiCorp, Inc.
|
||||
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
|
5
vendor/github.com/hashicorp/hc-install/checkpoint/latest_version.go
generated
vendored
5
vendor/github.com/hashicorp/hc-install/checkpoint/latest_version.go
generated
vendored
@ -123,7 +123,10 @@ func (lv *LatestVersion) Install(ctx context.Context) (string, error) {
|
||||
if lv.ArmoredPublicKey != "" {
|
||||
d.ArmoredPublicKey = lv.ArmoredPublicKey
|
||||
}
|
||||
err = d.DownloadAndUnpack(ctx, pv, dstDir)
|
||||
zipFilePath, err := d.DownloadAndUnpack(ctx, pv, dstDir)
|
||||
if zipFilePath != "" {
|
||||
lv.pathsToRemove = append(lv.pathsToRemove, zipFilePath)
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
90
vendor/github.com/hashicorp/hc-install/internal/build/go_build.go
generated
vendored
90
vendor/github.com/hashicorp/hc-install/internal/build/go_build.go
generated
vendored
@ -11,6 +11,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hashicorp/go-version"
|
||||
"golang.org/x/mod/modfile"
|
||||
)
|
||||
|
||||
var discardLogger = log.New(ioutil.Discard, "", 0)
|
||||
@ -37,23 +38,47 @@ func (gb *GoBuild) log() *log.Logger {
|
||||
|
||||
// Build runs "go build" within a given repo to produce binaryName in targetDir
|
||||
func (gb *GoBuild) Build(ctx context.Context, repoDir, targetDir, binaryName string) (string, error) {
|
||||
goCmd, cleanupFunc, err := gb.ensureRequiredGoVersion(ctx, repoDir)
|
||||
reqGo, err := gb.ensureRequiredGoVersion(ctx, repoDir)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer cleanupFunc(ctx)
|
||||
defer reqGo.CleanupFunc(ctx)
|
||||
|
||||
goArgs := []string{"build", "-o", filepath.Join(targetDir, binaryName)}
|
||||
if reqGo.Version == nil {
|
||||
gb.logger.Println("building using default available Go")
|
||||
} else {
|
||||
gb.logger.Printf("building using Go %s", reqGo.Version)
|
||||
}
|
||||
|
||||
// `go build` would download dependencies as a side effect, but we attempt
|
||||
// to do it early in a separate step, such that we can easily distinguish
|
||||
// network failures from build failures.
|
||||
//
|
||||
// Note, that `go mod download` was introduced in Go 1.11
|
||||
// See https://github.com/golang/go/commit/9f4ea6c2
|
||||
minGoVersion := version.Must(version.NewVersion("1.11"))
|
||||
if reqGo.Version.GreaterThanOrEqual(minGoVersion) {
|
||||
downloadArgs := []string{"mod", "download"}
|
||||
gb.log().Printf("executing %s %q in %q", reqGo.Cmd, downloadArgs, repoDir)
|
||||
cmd := exec.CommandContext(ctx, reqGo.Cmd, downloadArgs...)
|
||||
cmd.Dir = repoDir
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to download dependencies: %w\n%s", err, out)
|
||||
}
|
||||
}
|
||||
|
||||
buildArgs := []string{"build", "-o", filepath.Join(targetDir, binaryName)}
|
||||
|
||||
if gb.DetectVendoring {
|
||||
vendorDir := filepath.Join(repoDir, "vendor")
|
||||
if fi, err := os.Stat(vendorDir); err == nil && fi.IsDir() {
|
||||
goArgs = append(goArgs, "-mod", "vendor")
|
||||
buildArgs = append(buildArgs, "-mod", "vendor")
|
||||
}
|
||||
}
|
||||
|
||||
gb.log().Printf("executing %s %q in %q", goCmd, goArgs, repoDir)
|
||||
cmd := exec.CommandContext(ctx, goCmd, goArgs...)
|
||||
gb.log().Printf("executing %s %q in %q", reqGo.Cmd, buildArgs, repoDir)
|
||||
cmd := exec.CommandContext(ctx, reqGo.Cmd, buildArgs...)
|
||||
cmd.Dir = repoDir
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
@ -71,35 +96,59 @@ func (gb *GoBuild) Remove(ctx context.Context) error {
|
||||
return os.RemoveAll(gb.pathToRemove)
|
||||
}
|
||||
|
||||
func (gb *GoBuild) ensureRequiredGoVersion(ctx context.Context, repoDir string) (string, CleanupFunc, error) {
|
||||
type Go struct {
|
||||
Cmd string
|
||||
CleanupFunc CleanupFunc
|
||||
Version *version.Version
|
||||
}
|
||||
|
||||
func (gb *GoBuild) ensureRequiredGoVersion(ctx context.Context, repoDir string) (Go, error) {
|
||||
cmdName := "go"
|
||||
noopCleanupFunc := func(context.Context) {}
|
||||
|
||||
var installedVersion *version.Version
|
||||
|
||||
if gb.Version != nil {
|
||||
gb.logger.Printf("attempting to satisfy explicit requirement for Go %s", gb.Version)
|
||||
goVersion, err := GetGoVersion(ctx)
|
||||
if err != nil {
|
||||
return cmdName, noopCleanupFunc, err
|
||||
return Go{
|
||||
Cmd: cmdName,
|
||||
CleanupFunc: noopCleanupFunc,
|
||||
}, err
|
||||
}
|
||||
|
||||
if !goVersion.GreaterThanOrEqual(gb.Version) {
|
||||
// found incompatible version, try downloading the desired one
|
||||
return gb.installGoVersion(ctx, gb.Version)
|
||||
}
|
||||
installedVersion = goVersion
|
||||
}
|
||||
|
||||
if requiredVersion, ok := guessRequiredGoVersion(repoDir); ok {
|
||||
gb.logger.Printf("attempting to satisfy guessed Go requirement %s", requiredVersion)
|
||||
goVersion, err := GetGoVersion(ctx)
|
||||
if err != nil {
|
||||
return cmdName, noopCleanupFunc, err
|
||||
return Go{
|
||||
Cmd: cmdName,
|
||||
CleanupFunc: noopCleanupFunc,
|
||||
}, err
|
||||
}
|
||||
|
||||
if !goVersion.GreaterThanOrEqual(requiredVersion) {
|
||||
// found incompatible version, try downloading the desired one
|
||||
return gb.installGoVersion(ctx, requiredVersion)
|
||||
}
|
||||
installedVersion = goVersion
|
||||
} else {
|
||||
gb.logger.Println("unable to guess Go requirement")
|
||||
}
|
||||
|
||||
return cmdName, noopCleanupFunc, nil
|
||||
return Go{
|
||||
Cmd: cmdName,
|
||||
CleanupFunc: noopCleanupFunc,
|
||||
Version: installedVersion,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CleanupFunc represents a function to be called once Go is no longer needed
|
||||
@ -119,5 +168,26 @@ func guessRequiredGoVersion(repoDir string) (*version.Version, bool) {
|
||||
}
|
||||
return requiredVersion, true
|
||||
}
|
||||
|
||||
goModFile := filepath.Join(repoDir, "go.mod")
|
||||
if fi, err := os.Stat(goModFile); err == nil && !fi.IsDir() {
|
||||
b, err := ioutil.ReadFile(goModFile)
|
||||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
f, err := modfile.ParseLax(fi.Name(), b, nil)
|
||||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
if f.Go == nil {
|
||||
return nil, false
|
||||
}
|
||||
requiredVersion, err := version.NewVersion(f.Go.Version)
|
||||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
return requiredVersion, true
|
||||
}
|
||||
|
||||
return nil, false
|
||||
}
|
||||
|
28
vendor/github.com/hashicorp/hc-install/internal/build/install_go_version.go
generated
vendored
28
vendor/github.com/hashicorp/hc-install/internal/build/install_go_version.go
generated
vendored
@ -12,28 +12,36 @@ import (
|
||||
|
||||
// installGoVersion installs given version of Go using Go
|
||||
// according to https://golang.org/doc/manage-install
|
||||
func (gb *GoBuild) installGoVersion(ctx context.Context, v *version.Version) (string, CleanupFunc, error) {
|
||||
// trim 0 patch versions as that's how Go does it :shrug:
|
||||
shortVersion := strings.TrimSuffix(v.String(), ".0")
|
||||
func (gb *GoBuild) installGoVersion(ctx context.Context, v *version.Version) (Go, error) {
|
||||
versionString := v.Core().String()
|
||||
|
||||
// trim 0 patch versions as that's how Go does it :shrug:
|
||||
shortVersion := strings.TrimSuffix(versionString, ".0")
|
||||
pkgURL := fmt.Sprintf("golang.org/dl/go%s", shortVersion)
|
||||
|
||||
gb.log().Printf("go getting %q", pkgURL)
|
||||
cmd := exec.CommandContext(ctx, "go", "get", pkgURL)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return "", nil, fmt.Errorf("unable to install Go %s: %w\n%s", v, err, out)
|
||||
return Go{}, fmt.Errorf("unable to get Go %s: %w\n%s", v, err, out)
|
||||
}
|
||||
|
||||
gb.log().Printf("go installing %q", pkgURL)
|
||||
cmd = exec.CommandContext(ctx, "go", "install", pkgURL)
|
||||
out, err = cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return Go{}, fmt.Errorf("unable to install Go %s: %w\n%s", v, err, out)
|
||||
}
|
||||
|
||||
cmdName := fmt.Sprintf("go%s", shortVersion)
|
||||
|
||||
gb.log().Printf("downloading go %q", shortVersion)
|
||||
gb.log().Printf("downloading go %q", v)
|
||||
cmd = exec.CommandContext(ctx, cmdName, "download")
|
||||
out, err = cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return "", nil, fmt.Errorf("unable to download Go %s: %w\n%s", v, err, out)
|
||||
return Go{}, fmt.Errorf("unable to download Go %s: %w\n%s", v, err, out)
|
||||
}
|
||||
gb.log().Printf("download of go %q finished", shortVersion)
|
||||
gb.log().Printf("download of go %q finished", v)
|
||||
|
||||
cleanupFunc := func(ctx context.Context) {
|
||||
cmd = exec.CommandContext(ctx, cmdName, "env", "GOROOT")
|
||||
@ -49,5 +57,9 @@ func (gb *GoBuild) installGoVersion(ctx context.Context, v *version.Version) (st
|
||||
}
|
||||
}
|
||||
|
||||
return cmdName, cleanupFunc, nil
|
||||
return Go{
|
||||
Cmd: cmdName,
|
||||
CleanupFunc: cleanupFunc,
|
||||
Version: v,
|
||||
}, nil
|
||||
}
|
||||
|
4
vendor/github.com/hashicorp/hc-install/internal/httpclient/httpclient.go
generated
vendored
4
vendor/github.com/hashicorp/hc-install/internal/httpclient/httpclient.go
generated
vendored
@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/hashicorp/go-cleanhttp"
|
||||
"github.com/hashicorp/hc-install/internal/version"
|
||||
"github.com/hashicorp/hc-install/version"
|
||||
)
|
||||
|
||||
// NewHTTPClient provides a pre-configured http.Client
|
||||
@ -13,7 +13,7 @@ import (
|
||||
func NewHTTPClient() *http.Client {
|
||||
client := cleanhttp.DefaultClient()
|
||||
|
||||
userAgent := fmt.Sprintf("hc-install/%s", version.ModuleVersion())
|
||||
userAgent := fmt.Sprintf("hc-install/%s", version.Version())
|
||||
|
||||
cli := cleanhttp.DefaultPooledClient()
|
||||
cli.Transport = &userAgentRoundTripper{
|
||||
|
18
vendor/github.com/hashicorp/hc-install/internal/releasesjson/checksum_downloader.go
generated
vendored
18
vendor/github.com/hashicorp/hc-install/internal/releasesjson/checksum_downloader.go
generated
vendored
@ -2,11 +2,13 @@ package releasesjson
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
@ -42,7 +44,7 @@ func HashSumFromHexDigest(hexDigest string) (HashSum, error) {
|
||||
return HashSum(sumBytes), nil
|
||||
}
|
||||
|
||||
func (cd *ChecksumDownloader) DownloadAndVerifyChecksums() (ChecksumFileMap, error) {
|
||||
func (cd *ChecksumDownloader) DownloadAndVerifyChecksums(ctx context.Context) (ChecksumFileMap, error) {
|
||||
sigFilename, err := cd.findSigFilename(cd.ProductVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -54,7 +56,12 @@ func (cd *ChecksumDownloader) DownloadAndVerifyChecksums() (ChecksumFileMap, err
|
||||
url.PathEscape(cd.ProductVersion.RawVersion),
|
||||
url.PathEscape(sigFilename))
|
||||
cd.Logger.Printf("downloading signature from %s", sigURL)
|
||||
sigResp, err := client.Get(sigURL)
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, sigURL, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create request for %q: %w", sigURL, err)
|
||||
}
|
||||
sigResp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -70,7 +77,12 @@ func (cd *ChecksumDownloader) DownloadAndVerifyChecksums() (ChecksumFileMap, err
|
||||
url.PathEscape(cd.ProductVersion.RawVersion),
|
||||
url.PathEscape(cd.ProductVersion.SHASUMS))
|
||||
cd.Logger.Printf("downloading checksums from %s", shasumsURL)
|
||||
sumsResp, err := client.Get(shasumsURL)
|
||||
|
||||
req, err = http.NewRequestWithContext(ctx, http.MethodGet, shasumsURL, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create request for %q: %w", shasumsURL, err)
|
||||
}
|
||||
sumsResp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
55
vendor/github.com/hashicorp/hc-install/internal/releasesjson/downloader.go
generated
vendored
55
vendor/github.com/hashicorp/hc-install/internal/releasesjson/downloader.go
generated
vendored
@ -8,10 +8,12 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/hc-install/internal/httpclient"
|
||||
)
|
||||
@ -23,14 +25,14 @@ type Downloader struct {
|
||||
BaseURL string
|
||||
}
|
||||
|
||||
func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, dstDir string) error {
|
||||
func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion, dstDir string) (zipFilePath string, err error) {
|
||||
if len(pv.Builds) == 0 {
|
||||
return fmt.Errorf("no builds found for %s %s", pv.Name, pv.Version)
|
||||
return "", 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 "", fmt.Errorf("no ZIP archive found for %s %s %s/%s",
|
||||
pv.Name, pv.Version, runtime.GOOS, runtime.GOARCH)
|
||||
}
|
||||
|
||||
@ -42,14 +44,14 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion,
|
||||
Logger: d.Logger,
|
||||
ArmoredPublicKey: d.ArmoredPublicKey,
|
||||
}
|
||||
verifiedChecksums, err := v.DownloadAndVerifyChecksums()
|
||||
verifiedChecksums, err := v.DownloadAndVerifyChecksums(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
var ok bool
|
||||
verifiedChecksum, ok = verifiedChecksums[pb.Filename]
|
||||
if !ok {
|
||||
return fmt.Errorf("no checksum found for %q", pb.Filename)
|
||||
return "", fmt.Errorf("no checksum found for %q", pb.Filename)
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,12 +63,12 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion,
|
||||
// are still pointing to the mock server if one is set
|
||||
baseURL, err := url.Parse(d.BaseURL)
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
|
||||
u, err := url.Parse(archiveURL)
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
u.Scheme = baseURL.Scheme
|
||||
u.Host = baseURL.Host
|
||||
@ -74,13 +76,18 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion,
|
||||
}
|
||||
|
||||
d.Logger.Printf("downloading archive from %s", archiveURL)
|
||||
resp, err := client.Get(archiveURL)
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, archiveURL, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
return "", fmt.Errorf("failed to create request for %q: %w", archiveURL, err)
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return fmt.Errorf("failed to download ZIP archive from %q: %s", archiveURL, resp.Status)
|
||||
return "", fmt.Errorf("failed to download ZIP archive from %q: %s", archiveURL, resp.Status)
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
@ -90,7 +97,7 @@ 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 "", fmt.Errorf("unexpected content-type: %s (expected any of %q)",
|
||||
contentType, zipMimeTypes)
|
||||
}
|
||||
|
||||
@ -105,15 +112,16 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion,
|
||||
|
||||
err := compareChecksum(d.Logger, r, verifiedChecksum, pb.Filename, expectedSize)
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
pkgFile, err := ioutil.TempFile("", pb.Filename)
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
defer pkgFile.Close()
|
||||
pkgFilePath, err := filepath.Abs(pkgFile.Name())
|
||||
|
||||
d.Logger.Printf("copying %q (%d bytes) to %s", pb.Filename, expectedSize, pkgFile.Name())
|
||||
// Unless the bytes were already downloaded above for checksum verification
|
||||
@ -122,43 +130,48 @@ func (d *Downloader) DownloadAndUnpack(ctx context.Context, pv *ProductVersion,
|
||||
// on demand over the network.
|
||||
bytesCopied, err := io.Copy(pkgFile, pkgReader)
|
||||
if err != nil {
|
||||
return err
|
||||
return pkgFilePath, err
|
||||
}
|
||||
d.Logger.Printf("copied %d bytes to %s", bytesCopied, pkgFile.Name())
|
||||
|
||||
if expectedSize != 0 && bytesCopied != int64(expectedSize) {
|
||||
return fmt.Errorf("unexpected size (downloaded: %d, expected: %d)",
|
||||
return pkgFilePath, fmt.Errorf("unexpected size (downloaded: %d, expected: %d)",
|
||||
bytesCopied, expectedSize)
|
||||
}
|
||||
|
||||
r, err := zip.OpenReader(pkgFile.Name())
|
||||
if err != nil {
|
||||
return err
|
||||
return pkgFilePath, err
|
||||
}
|
||||
defer r.Close()
|
||||
|
||||
for _, f := range r.File {
|
||||
if strings.Contains(f.Name, "..") {
|
||||
// While we generally trust the source ZIP file
|
||||
// we still reject path traversal attempts as a precaution.
|
||||
continue
|
||||
}
|
||||
srcFile, err := f.Open()
|
||||
if err != nil {
|
||||
return err
|
||||
return pkgFilePath, err
|
||||
}
|
||||
|
||||
d.Logger.Printf("unpacking %s to %s", f.Name, dstDir)
|
||||
dstPath := filepath.Join(dstDir, f.Name)
|
||||
dstFile, err := os.Create(dstPath)
|
||||
if err != nil {
|
||||
return err
|
||||
return pkgFilePath, err
|
||||
}
|
||||
|
||||
_, err = io.Copy(dstFile, srcFile)
|
||||
if err != nil {
|
||||
return err
|
||||
return pkgFilePath, err
|
||||
}
|
||||
srcFile.Close()
|
||||
dstFile.Close()
|
||||
}
|
||||
|
||||
return nil
|
||||
return pkgFilePath, nil
|
||||
}
|
||||
|
||||
// The production release site uses consistent single mime type
|
||||
|
13
vendor/github.com/hashicorp/hc-install/internal/releasesjson/releases.go
generated
vendored
13
vendor/github.com/hashicorp/hc-install/internal/releasesjson/releases.go
generated
vendored
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
@ -68,7 +69,11 @@ func (r *Releases) ListProductVersions(ctx context.Context, productName string)
|
||||
url.PathEscape(productName))
|
||||
r.logger.Printf("requesting versions from %s", productIndexURL)
|
||||
|
||||
resp, err := client.Get(productIndexURL)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, productIndexURL, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create request for %q: %w", productIndexURL, err)
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -133,7 +138,11 @@ func (r *Releases) GetProductVersion(ctx context.Context, product string, versio
|
||||
url.PathEscape(version.String()))
|
||||
r.logger.Printf("requesting version from %s", indexURL)
|
||||
|
||||
resp, err := client.Get(indexURL)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, indexURL, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create request for %q: %w", indexURL, err)
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
9
vendor/github.com/hashicorp/hc-install/internal/version/version.go
generated
vendored
9
vendor/github.com/hashicorp/hc-install/internal/version/version.go
generated
vendored
@ -1,9 +0,0 @@
|
||||
package version
|
||||
|
||||
const version = "0.1.0"
|
||||
|
||||
// ModuleVersion returns the current version of the github.com/hashicorp/hc-install Go module.
|
||||
// This is a function to allow for future possible enhancement using debug.BuildInfo.
|
||||
func ModuleVersion() string {
|
||||
return version
|
||||
}
|
2
vendor/github.com/hashicorp/hc-install/product/consul.go
generated
vendored
2
vendor/github.com/hashicorp/hc-install/product/consul.go
generated
vendored
@ -50,6 +50,6 @@ var Consul = Product{
|
||||
BuildInstructions: &BuildInstructions{
|
||||
GitRepoURL: "https://github.com/hashicorp/consul.git",
|
||||
PreCloneCheck: &build.GoIsInstalled{},
|
||||
Build: &build.GoBuild{Version: v1_18},
|
||||
Build: &build.GoBuild{},
|
||||
},
|
||||
}
|
||||
|
3
vendor/github.com/hashicorp/hc-install/product/vault.go
generated
vendored
3
vendor/github.com/hashicorp/hc-install/product/vault.go
generated
vendored
@ -14,7 +14,6 @@ import (
|
||||
|
||||
var (
|
||||
vaultVersionOutputRe = regexp.MustCompile(`Vault ` + simpleVersionRe)
|
||||
v1_17 = version.Must(version.NewVersion("1.17"))
|
||||
)
|
||||
|
||||
var Vault = Product{
|
||||
@ -49,6 +48,6 @@ var Vault = Product{
|
||||
BuildInstructions: &BuildInstructions{
|
||||
GitRepoURL: "https://github.com/hashicorp/vault.git",
|
||||
PreCloneCheck: &build.GoIsInstalled{},
|
||||
Build: &build.GoBuild{Version: v1_17},
|
||||
Build: &build.GoBuild{},
|
||||
},
|
||||
}
|
||||
|
5
vendor/github.com/hashicorp/hc-install/releases/exact_version.go
generated
vendored
5
vendor/github.com/hashicorp/hc-install/releases/exact_version.go
generated
vendored
@ -115,7 +115,10 @@ func (ev *ExactVersion) Install(ctx context.Context) (string, error) {
|
||||
d.BaseURL = ev.apiBaseURL
|
||||
}
|
||||
|
||||
err = d.DownloadAndUnpack(ctx, pv, dstDir)
|
||||
zipFilePath, err := d.DownloadAndUnpack(ctx, pv, dstDir)
|
||||
if zipFilePath != "" {
|
||||
ev.pathsToRemove = append(ev.pathsToRemove, zipFilePath)
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
5
vendor/github.com/hashicorp/hc-install/releases/latest_version.go
generated
vendored
5
vendor/github.com/hashicorp/hc-install/releases/latest_version.go
generated
vendored
@ -119,7 +119,10 @@ func (lv *LatestVersion) Install(ctx context.Context) (string, error) {
|
||||
if lv.apiBaseURL != "" {
|
||||
d.BaseURL = lv.apiBaseURL
|
||||
}
|
||||
err = d.DownloadAndUnpack(ctx, versionToInstall, dstDir)
|
||||
zipFilePath, err := d.DownloadAndUnpack(ctx, versionToInstall, dstDir)
|
||||
if zipFilePath != "" {
|
||||
lv.pathsToRemove = append(lv.pathsToRemove, zipFilePath)
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
1
vendor/github.com/hashicorp/hc-install/version/VERSION
generated
vendored
Normal file
1
vendor/github.com/hashicorp/hc-install/version/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
0.5.0
|
20
vendor/github.com/hashicorp/hc-install/version/version.go
generated
vendored
Normal file
20
vendor/github.com/hashicorp/hc-install/version/version.go
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/hashicorp/go-version"
|
||||
)
|
||||
|
||||
//go:embed VERSION
|
||||
var rawVersion string
|
||||
|
||||
// Version returns the version of the library
|
||||
//
|
||||
// Note: This is only exposed as public function/package
|
||||
// due to hard-coded constraints in the release tooling.
|
||||
// In general downstream should not implement version-specific
|
||||
// logic and rely on this function to be present in future releases.
|
||||
func Version() *version.Version {
|
||||
return version.Must(version.NewVersion(rawVersion))
|
||||
}
|
Reference in New Issue
Block a user