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