mirror of https://github.com/hashicorp/terraform
parent
e1ad6a6fd6
commit
91b1dd3cc3
@ -0,0 +1,41 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package pluginshared
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
svchost "github.com/hashicorp/terraform-svchost"
|
||||
)
|
||||
|
||||
// CloudBinaryManager downloads, caches, and returns information about the
|
||||
// terraform-cloudplugin binary downloaded from the specified backend.
|
||||
type CloudBinaryManager struct {
|
||||
BinaryManager
|
||||
}
|
||||
|
||||
// NewCloudBinaryManager initializes a new BinaryManager to broker data between the
|
||||
// specified directory location containing cloudplugin package data and a
|
||||
// HCP Terraform backend URL.
|
||||
func NewCloudBinaryManager(ctx context.Context, cloudPluginDataDir, overridePath string, serviceURL *url.URL, goos, arch string) (*CloudBinaryManager, error) {
|
||||
client, err := NewCloudPluginClient(ctx, serviceURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not initialize cloudplugin version manager: %w", err)
|
||||
}
|
||||
|
||||
return &CloudBinaryManager{
|
||||
BinaryManager{
|
||||
pluginDataDir: cloudPluginDataDir,
|
||||
overridePath: overridePath,
|
||||
host: svchost.Hostname(serviceURL.Host),
|
||||
client: client,
|
||||
binaryName: "terraform-cloudplugin",
|
||||
pluginName: "cloudplugin",
|
||||
goos: goos,
|
||||
arch: arch,
|
||||
ctx: ctx,
|
||||
}}, nil
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package pluginshared
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
|
||||
"github.com/hashicorp/go-retryablehttp"
|
||||
"github.com/hashicorp/terraform/internal/httpclient"
|
||||
"github.com/hashicorp/terraform/internal/logging"
|
||||
)
|
||||
|
||||
// type CloudPluginClient struct {
|
||||
// BasePluginClient
|
||||
// }
|
||||
|
||||
// NewCloudPluginClient creates a new client for downloading and verifying
|
||||
// terraform-cloudplugin archives
|
||||
func NewCloudPluginClient(ctx context.Context, serviceURL *url.URL) (*BasePluginClient, error) {
|
||||
httpClient := httpclient.New()
|
||||
httpClient.Timeout = defaultRequestTimeout
|
||||
|
||||
retryableClient := retryablehttp.NewClient()
|
||||
retryableClient.HTTPClient = httpClient
|
||||
retryableClient.RetryMax = 3
|
||||
retryableClient.RequestLogHook = requestLogHook
|
||||
retryableClient.Logger = logging.HCLogger()
|
||||
|
||||
client := BasePluginClient{
|
||||
ctx: ctx,
|
||||
serviceURL: serviceURL,
|
||||
httpClient: retryableClient,
|
||||
pluginName: "cloudplugin",
|
||||
}
|
||||
|
||||
// return &CloudPluginClient{BasePluginClient: client}, nil
|
||||
return &client, nil
|
||||
}
|
||||
@ -1,12 +1,12 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package cloudplugin
|
||||
package pluginshared
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
type Cloud1 interface {
|
||||
type CustomPluginClient interface {
|
||||
Execute(args []string, stdout, stderr io.Writer) int
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package cloudplugin
|
||||
package pluginshared
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
Loading…
Reference in new issue