govendor: update `go-tfe`
This commit is contained in:
parent
f74774ff4f
commit
cdf997a97c
|
@ -1,7 +1,6 @@
|
|||
package tfe
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -87,14 +86,30 @@ func (r *LogReader) read(l []byte) (int, error) {
|
|||
|
||||
if written > 0 {
|
||||
// Check for an STX (Start of Text) ASCII control marker.
|
||||
if !r.startOfText && bytes.Contains(l, []byte("\x02")) {
|
||||
if !r.startOfText && l[0] == byte(2) {
|
||||
r.startOfText = true
|
||||
|
||||
// Remove the STX marker from the received chunk.
|
||||
copy(l[:written-1], l[1:])
|
||||
l[written-1] = byte(0)
|
||||
r.offset++
|
||||
written--
|
||||
|
||||
// Return early if we only received the STX marker.
|
||||
if written == 0 {
|
||||
return 0, io.ErrNoProgress
|
||||
}
|
||||
}
|
||||
|
||||
// If we found an STX ASCII control character, start looking for
|
||||
// the ETX (End of Text) control character.
|
||||
if r.startOfText && bytes.Contains(l, []byte("\x03")) {
|
||||
if r.startOfText && l[written-1] == byte(3) {
|
||||
r.endOfText = true
|
||||
|
||||
// Remove the ETX marker from the received chunk.
|
||||
l[written-1] = byte(0)
|
||||
r.offset++
|
||||
written--
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ type Config struct {
|
|||
// API token used to access the Terraform Enterprise API.
|
||||
Token string
|
||||
|
||||
// Headers that will be added to every request.
|
||||
Headers http.Header
|
||||
|
||||
// A custom HTTP client to use.
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
@ -58,6 +61,7 @@ func DefaultConfig() *Config {
|
|||
Address: os.Getenv("TFE_ADDRESS"),
|
||||
BasePath: DefaultBasePath,
|
||||
Token: os.Getenv("TFE_TOKEN"),
|
||||
Headers: make(http.Header),
|
||||
HTTPClient: cleanhttp.DefaultPooledClient(),
|
||||
}
|
||||
|
||||
|
@ -66,16 +70,19 @@ func DefaultConfig() *Config {
|
|||
config.Address = DefaultAddress
|
||||
}
|
||||
|
||||
// Set the default user agent.
|
||||
config.Headers.Set("User-Agent", userAgent)
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
// Client is the Terraform Enterprise API client. It provides the basic
|
||||
// connectivity and configuration for accessing the TFE API.
|
||||
type Client struct {
|
||||
baseURL *url.URL
|
||||
token string
|
||||
http *http.Client
|
||||
userAgent string
|
||||
baseURL *url.URL
|
||||
token string
|
||||
headers http.Header
|
||||
http *http.Client
|
||||
|
||||
Applies Applies
|
||||
ConfigurationVersions ConfigurationVersions
|
||||
|
@ -113,6 +120,9 @@ func NewClient(cfg *Config) (*Client, error) {
|
|||
if cfg.Token != "" {
|
||||
config.Token = cfg.Token
|
||||
}
|
||||
for k, v := range cfg.Headers {
|
||||
config.Headers[k] = v
|
||||
}
|
||||
if cfg.HTTPClient != nil {
|
||||
config.HTTPClient = cfg.HTTPClient
|
||||
}
|
||||
|
@ -136,10 +146,10 @@ func NewClient(cfg *Config) (*Client, error) {
|
|||
|
||||
// Create the client.
|
||||
client := &Client{
|
||||
baseURL: baseURL,
|
||||
token: config.Token,
|
||||
http: config.HTTPClient,
|
||||
userAgent: userAgent,
|
||||
baseURL: baseURL,
|
||||
token: config.Token,
|
||||
headers: config.Headers,
|
||||
http: config.HTTPClient,
|
||||
}
|
||||
|
||||
// Create the services.
|
||||
|
@ -208,6 +218,11 @@ func (c *Client) newRequest(method, path string, v interface{}) (*http.Request,
|
|||
Host: u.Host,
|
||||
}
|
||||
|
||||
// Set default headers.
|
||||
for k, v := range c.headers {
|
||||
req.Header[k] = v
|
||||
}
|
||||
|
||||
switch method {
|
||||
case "GET":
|
||||
req.Header.Set("Accept", "application/vnd.api+json")
|
||||
|
@ -249,9 +264,8 @@ func (c *Client) newRequest(method, path string, v interface{}) (*http.Request,
|
|||
}
|
||||
}
|
||||
|
||||
// Set required headers.
|
||||
// Set the authorization header.
|
||||
req.Header.Set("Authorization", "Bearer "+c.token)
|
||||
req.Header.Set("User-Agent", c.userAgent)
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
|
|
@ -1804,10 +1804,10 @@
|
|||
"revisionTime": "2018-07-12T07:51:27Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "bZzpA/TNWpYzVGIFEWLpOz7AXCU=",
|
||||
"checksumSHA1": "WLjiFy8H9n3V2yn4nxMMhm0J8jo=",
|
||||
"path": "github.com/hashicorp/go-tfe",
|
||||
"revision": "937a37d8d40df424b1e47fe05de0548727154efc",
|
||||
"revisionTime": "2018-10-11T20:03:11Z"
|
||||
"revision": "faae81b2a4b7a955bd8566f4df8f317b7d1ddcd6",
|
||||
"revisionTime": "2018-10-15T17:21:27Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "85XUnluYJL7F55ptcwdmN8eSOsk=",
|
||||
|
|
Loading…
Reference in New Issue