opentofu/vendor/github.com/jen20/riviera/azure/client.go
Peter McAtominey 0284138440 provider/azurerm: support non public clouds (#11026)
* vendor: update jen20/riviera to pull in endpoints change

* provider/auzrerm: support non public clouds

Ran tests below with ARM_ENVIRONMENT=german and changes the location to Germany
Central in the test config. The virtual network tests cover both Riviera (resource
groups) and the official SDK client.

TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMVirtualNetwork_ -timeout 120m
=== RUN   TestAccAzureRMVirtualNetwork_importBasic
--- PASS: TestAccAzureRMVirtualNetwork_importBasic (81.84s)
=== RUN   TestAccAzureRMVirtualNetwork_basic
--- PASS: TestAccAzureRMVirtualNetwork_basic (78.14s)
=== RUN   TestAccAzureRMVirtualNetwork_disappears
--- PASS: TestAccAzureRMVirtualNetwork_disappears (78.45s)
=== RUN   TestAccAzureRMVirtualNetwork_withTags
--- PASS: TestAccAzureRMVirtualNetwork_withTags (81.78s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	320.310s
2017-01-04 12:00:14 +00:00

67 lines
1.4 KiB
Go

package azure
import (
"io/ioutil"
"log"
"net/http"
"github.com/hashicorp/go-retryablehttp"
)
type Client struct {
logger *log.Logger
subscriptionID string
resourceManagerEndpoint string
tokenRequester *tokenRequester
httpClient *retryablehttp.Client
}
func NewClient(creds *AzureResourceManagerCredentials) (*Client, error) {
defaultLogger := log.New(ioutil.Discard, "", 0)
httpClient := retryablehttp.NewClient()
httpClient.Logger = defaultLogger
if creds.ResourceManagerEndpoint == "" {
creds.ResourceManagerEndpoint = defaultResourceManagerEndpoint
}
if creds.ActiveDirectoryEndpoint == "" {
creds.ActiveDirectoryEndpoint = defaultActiveDirectoryEndpoint
}
tr := newTokenRequester(httpClient, creds)
return &Client{
subscriptionID: creds.SubscriptionID,
resourceManagerEndpoint: creds.ResourceManagerEndpoint,
httpClient: httpClient,
tokenRequester: tr,
logger: defaultLogger,
}, nil
}
func (c *Client) SetRequestLoggingHook(hook func(*log.Logger, *http.Request, int)) {
c.httpClient.RequestLogHook = hook
}
func (c *Client) SetLogger(newLogger *log.Logger) {
c.logger = newLogger
c.httpClient.Logger = newLogger
}
func (c *Client) NewRequest() *Request {
return &Request{
client: c,
}
}
func (c *Client) NewRequestForURI(resourceURI string) *Request {
return &Request{
URI: &resourceURI,
client: c,
}
}